Repository navigation
168 lines (155 loc) · 6.4 KB
/
Copy pathrelease.yml
File metadata and controls
168 lines (155 loc) · 6.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Release
# Cut a release by pushing an annotated tag that matches VERSION, e.g.:
# git tag -a v1.0.0 -m "RigForge v1.0.0" && git push origin v1.0.0
# This packages the deploy bundle, checksums it, pulls notes from CHANGELOG.md, and publishes a
# GitHub Release. See RELEASING.md.
on:
push:
tags:
- "v*"
permissions:
contents: read
jobs:
build-x86_64:
name: Build the x86_64 release binary
runs-on: ubuntu-24.04
timeout-minutes: 30
env:
TAG: ${{ github.ref_name }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false # zizmor: artipacked
- name: Install the pinned toolchain
run: rustup toolchain install
- name: Build the static, stripped binary
run: make rust-musl
- name: Assert the binary reports the repository VERSION
run: make rust-version
- name: Stage the release asset
run: |
set -euo pipefail
install -m 0755 target/x86_64-unknown-linux-musl/release/rigforge-rs \
"rigforge-$TAG-x86_64-unknown-linux-musl"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-binary-x86_64
path: rigforge-${{ env.TAG }}-x86_64-unknown-linux-musl
if-no-files-found: error
build-aarch64:
name: Build the aarch64 release binary (best effort)
runs-on: ubuntu-24.04-arm
continue-on-error: true
timeout-minutes: 30
env:
TAG: ${{ github.ref_name }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false # zizmor: artipacked
- name: Install the pinned toolchain
run: rustup toolchain install
- name: Add the aarch64 musl target
run: rustup target add aarch64-unknown-linux-musl
- name: Build the static, stripped binary
run: make rust-musl MUSL_TARGET=aarch64-unknown-linux-musl
- name: Assert the binary reports the repository VERSION
run: make rust-version MUSL_TARGET=aarch64-unknown-linux-musl
- name: Stage the release asset
run: |
set -euo pipefail
install -m 0755 target/aarch64-unknown-linux-musl/release/rigforge-rs \
"rigforge-$TAG-aarch64-unknown-linux-musl"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-binary-aarch64
path: rigforge-${{ env.TAG }}-aarch64-unknown-linux-musl
if-no-files-found: error
release:
name: Build & publish release
needs: [build-x86_64, build-aarch64]
if: ${{ !cancelled() && needs.build-x86_64.result == 'success' }}
runs-on: ubuntu-24.04
permissions:
contents: write
actions: read
env:
TAG: ${{ github.ref_name }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Releasing goes through `gh` with GH_TOKEN below, not `git push`, so the checkout never
# needs the token left in .git/config (zizmor: artipacked).
persist-credentials: false
fetch-depth: 0
- name: Require the tag to be on main
run: |
set -euo pipefail
git fetch --no-tags origin main:refs/remotes/origin/main
if ! git merge-base --is-ancestor HEAD refs/remotes/origin/main; then
echo "::error::Tag '$TAG' is not on main. Tag from main and retag."
exit 1
fi
- name: Verify the tag matches VERSION
run: |
set -euo pipefail
want="v$(tr -d '[:space:]' < VERSION)"
if [ "$TAG" != "$want" ]; then
echo "::error::Tag '$TAG' does not match VERSION ('$want'). Bump VERSION or retag."
exit 1
fi
- name: Download the release binaries
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
rm -rf relbin
mkdir relbin
gh run download "$GITHUB_RUN_ID" -n release-binary-x86_64 -D relbin
if ! gh run download "$GITHUB_RUN_ID" -n release-binary-aarch64 -D relbin 2>"$RUNNER_TEMP/aarch64.err"; then
printf '::warning::aarch64 binary not bundled: %s\n' "$(tr '\n' ' ' <"$RUNNER_TEMP/aarch64.err")"
rm -f relbin/rigforge-"$TAG"-aarch64-unknown-linux-musl
fi
chmod 0755 relbin/rigforge-"$TAG"-*-unknown-linux-musl
- name: Build the deploy bundle (.zip + .tar.gz + checksums)
run: |
set -euo pipefail
bash scripts/build-release-bundle.sh "$TAG" relbin/rigforge-"$TAG"-*-unknown-linux-musl
bash scripts/build-homebrew-formula.sh "$TAG" SHA256SUMS rigforge.rb "rigforge-$TAG.tar.gz"
- name: Build the .deb package
run: |
set -euo pipefail
deb=$(SOURCE_DATE_EPOCH=$(git log -1 --format=%ct) bash scripts/build-deb.sh "rigforge-$TAG.tar.gz" "$TAG")
sha256sum "$deb" >> SHA256SUMS
echo "--- SHA256SUMS (with .deb) ---"; cat SHA256SUMS
- name: Extract release notes from CHANGELOG.md
run: |
set -euo pipefail
ver="${TAG#v}"
# Print the body of this version's "## [x.y.z]" section (up to the next "## " heading).
awk -v ver="$ver" '
index($0, "## [" ver "]") == 1 { grab = 1; next }
grab && /^## / { exit }
grab { print }
' CHANGELOG.md > RELEASE_NOTES.md
# Fall back to a generic note if that version has no changelog section yet.
if ! grep -q '[^[:space:]]' RELEASE_NOTES.md; then
printf 'RigForge %s\n' "$TAG" > RELEASE_NOTES.md
fi
echo "--- notes ---"; cat RELEASE_NOTES.md
- name: Publish the GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
# Mark 0.x tags as pre-releases.
pre=""
case "${TAG#v}" in 0.*) pre="--prerelease" ;; esac
assets=("rigforge-$TAG.zip" "rigforge-$TAG.tar.gz" "rigforge_${TAG#v}_all.deb" SHA256SUMS rigforge.rb)
for binary in relbin/rigforge-"$TAG"-*-unknown-linux-musl; do
[ -e "$binary" ] && assets+=("$binary")
done
gh release create "$TAG" $pre --draft \
--title "RigForge $TAG" \
--notes-file RELEASE_NOTES.md \
"${assets[@]}"