Debian Codegraph @

.github/workflows/release.yml

raw symbols SCIP
1 # To run the release workflow push a tag with the expected SHA256SUMS as tag message body.
2
3 name: Release
4
5 on:
6 push:
7 tags: '*'
8 jobs:
9 build:
10 runs-on: ubuntu-24.04
11 permissions: {}
12
13 steps:
14 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
15 with:
16 persist-credentials: false
17
18 - name: Sanity checks
19 run: |
20 # GHA makes the tag point to the commit rather than the tag object.
21 # Remove the tag and fetch it again to get the real tag object.
22 git tag -d "$(echo "$GITHUB_REF" | sed 's/refs\/tags\///')"
23 git fetch https://github.com/trifectatechfoundation/sudo-rs.git --tags
24
25 # Check if the tag has a signature to prevent accidentally pushing an unsigned tag.
26 git tag -l --format='%(contents:signature)' "$(echo "$GITHUB_REF" | sed 's/refs\/tags\///')" | grep --quiet SIGNATURE || (echo "Tag not signed"; exit 1)
27
28 - name: Run build
29 run: ./util/build-release.sh
30
31 # Upload the built tarballs first before comparing checksums to help with debugging.
32 - name: Upload artifacts
33 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
34 with:
35 name: release_files
36 path: |
37 target/pkg/SHA256SUMS
38 target/pkg/*.tar.gz
39
40 - name: Compare checksums
41 run: |
42 # Get the expected checksums from the tag message.
43 git tag -l --format='%(contents:body)' "$(echo "$GITHUB_REF" | sed 's/refs\/tags\///')" | tr -s '\n' > expected_checksums.txt
44
45 # Check that the actual checksums match what we expected. If not fail
46 # the release and have the person doing the release check again for
47 # reproducibility problems.
48 cat expected_checksums.txt
49 diff -u expected_checksums.txt target/pkg/SHA256SUMS
50
51 release:
52 runs-on: ubuntu-24.04
53 permissions:
54 contents: write
55 needs: build
56
57 steps:
58 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
59 with:
60 persist-credentials: false
61
62 - name: Download artifacts
63 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
64 with:
65 name: release_files
66 path: release_files
67
68 - name: Prepare release
69 env:
70 GH_TOKEN: ${{ github.token }}
71 run: |
72 echo "Release files:"
73 ls -l release_files
74 echo
75
76 # Add the fixed header to the release notes
77 echo 'To use the precompiled binaries attached below, consult our [manual installation instructions](https://github.com/trifectatechfoundation/sudo-rs?tab=readme-ov-file#installing-our-pre-compiled-x86-64-binaries)' > notes.md
78
79 # Extract the first changelog entry from CHANGELOG.md
80 echo "Changelog:"
81 sed -n '4,${ /^## /q; p; }' CHANGELOG.md | tee -a notes.md
82
83 util/gh-credits.sh >> notes.md
84
85 - name: Create release
86 env:
87 GH_TOKEN: ${{ github.token }}
88 run: |
89 # GHA makes the tag point to the commit rather than the tag object.
90 # Remove the tag and fetch it again to get the real tag object.
91 RELEASE="$(echo "$GITHUB_REF" | sed 's/refs\/tags\///')"
92 git tag -d "$RELEASE"
93 git fetch https://github.com/trifectatechfoundation/sudo-rs.git --tags
94
95 gh release create "$RELEASE" --draft \
96 --title "Version ${RELEASE#v}" \
97 --notes-file notes.md release_files/* \
98 --verify-tag
99 echo "Draft release successfully created. Please review and publish."