88permissions :
99 contents : write
1010 packages : write
11+ id-token : write
1112
1213jobs :
13- # Builds the x64 and arm64 binaries for Linux, for all 3 crates, via the Docker builder
14+ # Builds the x64 and arm64 binary for Linux via the Docker builder
1415 build-binaries-linux :
1516 strategy :
1617 matrix :
1718 target :
1819 - amd64
1920 - arm64
2021 name :
21- - commit-boost-cli
22- - commit-boost-pbs
23- - commit-boost-signer
22+ - commit-boost
2423 include :
2524 - target : amd64
2625 package-suffix : x86-64
2726 - target : arm64
2827 package-suffix : arm64
29- - name : commit-boost-cli
30- target-crate : cli
31- - name : commit-boost-pbs
32- target-crate : pbs
33- - name : commit-boost-signer
34- target-crate : signer
28+ - name : commit-boost
29+ target-crate : commit-boost
3530 runs-on : ubuntu-latest
3631 steps :
3732 - name : Checkout code
4439 run : |
4540 echo "Releasing commit: $(git rev-parse HEAD)"
4641
42+ - name : Set lowercase owner
43+ run : echo "OWNER=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
44+
4745 - name : Set up QEMU
4846 uses : docker/setup-qemu-action@v3
4947
6361 context : .
6462 push : false
6563 platforms : linux/amd64,linux/arm64
66- cache-from : type=registry,ref=ghcr.io/commit-boost /buildcache:${{ matrix.target-crate}}
67- cache-to : type=registry,ref=ghcr.io/commit-boost /buildcache:${{ matrix.target-crate }},mode=max
64+ cache-from : type=registry,ref=ghcr.io/${{ env.OWNER }} /buildcache:${{ matrix.target-crate}}
65+ cache-to : type=registry,ref=ghcr.io/${{ env.OWNER }} /buildcache:${{ matrix.target-crate }},mode=max
6866 file : provisioning/build.Dockerfile
6967 outputs : type=local,dest=build
7068 build-args : |
8381 path : |
8482 ${{ matrix.name }}-${{ github.ref_name }}-linux_${{ matrix.package-suffix }}.tar.gz
8583
86- # Builds the arm64 binaries for Darwin, for all 3 crates, natively
84+ # Builds the arm64 binary for Darwin natively
8785 build-binaries-darwin :
8886 strategy :
8987 matrix :
9290 # - x86_64-apple-darwin
9391 - aarch64-apple-darwin
9492 name :
95- - commit-boost-cli
96- - commit-boost-pbs
97- - commit-boost-signer
93+ - commit-boost
9894 include :
9995 # - target: x86_64-apple-darwin
10096 # os: macos-latest-large
@@ -158,6 +154,31 @@ jobs:
158154 path : |
159155 ${{ matrix.name }}-${{ github.ref_name }}-darwin_${{ matrix.package-suffix }}.tar.gz
160156
157+ # Signs the binaries
158+ sign-binaries :
159+ needs :
160+ - build-binaries-linux
161+ - build-binaries-darwin
162+ runs-on : ubuntu-latest
163+ steps :
164+ - name : Download artifacts
165+ uses : actions/download-artifact@v4
166+ with :
167+ path : ./artifacts
168+ pattern : " commit-boost*"
169+
170+ - name : Sign binaries
171+ uses : sigstore/gh-action-sigstore-python@a5caf349bc536fbef3668a10ed7f5cd309a4b53d # v3.2.0
172+ with :
173+ inputs : ./artifacts/**/*.tar.gz
174+
175+ - name : Upload signatures
176+ uses : actions/upload-artifact@v4
177+ with :
178+ name : signatures-${{ github.ref_name }}
179+ path : |
180+ ./artifacts/**/*.sigstore.json
181+
161182 # Builds the PBS Docker image
162183 build-and-push-pbs-docker :
163184 needs : [build-binaries-linux]
@@ -173,16 +194,19 @@ jobs:
173194 uses : actions/download-artifact@v4
174195 with :
175196 path : ./artifacts
176- pattern : " commit-boost- *"
197+ pattern : " commit-boost*"
177198
178199 - name : Extract binaries
179200 run : |
180201 mkdir -p ./artifacts/bin/linux_amd64
181202 mkdir -p ./artifacts/bin/linux_arm64
182- tar -xzf ./artifacts/commit-boost-pbs-${{ github.ref_name }}-linux_x86-64/commit-boost-pbs-${{ github.ref_name }}-linux_x86-64.tar.gz -C ./artifacts/bin
183- mv ./artifacts/bin/commit-boost-pbs ./artifacts/bin/linux_amd64/commit-boost-pbs
184- tar -xzf ./artifacts/commit-boost-pbs-${{ github.ref_name }}-linux_arm64/commit-boost-pbs-${{ github.ref_name }}-linux_arm64.tar.gz -C ./artifacts/bin
185- mv ./artifacts/bin/commit-boost-pbs ./artifacts/bin/linux_arm64/commit-boost-pbs
203+ tar -xzf ./artifacts/commit-boost-${{ github.ref_name }}-linux_x86-64/commit-boost-${{ github.ref_name }}-linux_x86-64.tar.gz -C ./artifacts/bin
204+ mv ./artifacts/bin/commit-boost ./artifacts/bin/linux_amd64/commit-boost
205+ tar -xzf ./artifacts/commit-boost-${{ github.ref_name }}-linux_arm64/commit-boost-${{ github.ref_name }}-linux_arm64.tar.gz -C ./artifacts/bin
206+ mv ./artifacts/bin/commit-boost ./artifacts/bin/linux_arm64/commit-boost
207+
208+ - name : Set lowercase owner
209+ run : echo "OWNER=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
186210
187211 - name : Set up QEMU
188212 uses : docker/setup-qemu-action@v3
@@ -206,8 +230,8 @@ jobs:
206230 build-args : |
207231 BINARIES_PATH=./artifacts/bin
208232 tags : |
209- ghcr.io/commit-boost /pbs:${{ github.ref_name }}
210- ${{ !contains(github.ref_name, 'rc') && 'ghcr.io/commit-boost /pbs:latest' || '' }}
233+ ghcr.io/${{ env.OWNER }} /pbs:${{ github.ref_name }}
234+ ${{ !contains(github.ref_name, 'rc') && format( 'ghcr.io/{0} /pbs:latest', env.OWNER) || '' }}
211235 file : provisioning/pbs.Dockerfile
212236
213237 # Builds the Signer Docker image
@@ -225,16 +249,19 @@ jobs:
225249 uses : actions/download-artifact@v4
226250 with :
227251 path : ./artifacts
228- pattern : " commit-boost- *"
252+ pattern : " commit-boost*"
229253
230254 - name : Extract binaries
231255 run : |
232256 mkdir -p ./artifacts/bin/linux_amd64
233257 mkdir -p ./artifacts/bin/linux_arm64
234- tar -xzf ./artifacts/commit-boost-signer-${{ github.ref_name }}-linux_x86-64/commit-boost-signer-${{ github.ref_name }}-linux_x86-64.tar.gz -C ./artifacts/bin
235- mv ./artifacts/bin/commit-boost-signer ./artifacts/bin/linux_amd64/commit-boost-signer
236- tar -xzf ./artifacts/commit-boost-signer-${{ github.ref_name }}-linux_arm64/commit-boost-signer-${{ github.ref_name }}-linux_arm64.tar.gz -C ./artifacts/bin
237- mv ./artifacts/bin/commit-boost-signer ./artifacts/bin/linux_arm64/commit-boost-signer
258+ tar -xzf ./artifacts/commit-boost-${{ github.ref_name }}-linux_x86-64/commit-boost-${{ github.ref_name }}-linux_x86-64.tar.gz -C ./artifacts/bin
259+ mv ./artifacts/bin/commit-boost ./artifacts/bin/linux_amd64/commit-boost
260+ tar -xzf ./artifacts/commit-boost-${{ github.ref_name }}-linux_arm64/commit-boost-${{ github.ref_name }}-linux_arm64.tar.gz -C ./artifacts/bin
261+ mv ./artifacts/bin/commit-boost ./artifacts/bin/linux_arm64/commit-boost
262+
263+ - name : Set lowercase owner
264+ run : echo "OWNER=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
238265
239266 - name : Set up QEMU
240267 uses : docker/setup-qemu-action@v3
@@ -258,32 +285,110 @@ jobs:
258285 build-args : |
259286 BINARIES_PATH=./artifacts/bin
260287 tags : |
261- ghcr.io/commit-boost /signer:${{ github.ref_name }}
262- ${{ !contains(github.ref_name, 'rc') && 'ghcr.io/commit-boost /signer:latest' || '' }}
288+ ghcr.io/${{ env.OWNER }} /signer:${{ github.ref_name }}
289+ ${{ !contains(github.ref_name, 'rc') && format( 'ghcr.io/{0} /signer:latest', env.OWNER) || '' }}
263290 file : provisioning/signer.Dockerfile
264291
265292 # Creates a draft release on GitHub with the binaries
266293 finalize-release :
267294 needs :
268295 - build-binaries-linux
269296 - build-binaries-darwin
297+ - sign-binaries
270298 - build-and-push-pbs-docker
271299 - build-and-push-signer-docker
272300 runs-on : ubuntu-latest
273301 steps :
274- - name : Download artifacts
302+ - name : Download binaries
303+ uses : actions/download-artifact@v4
304+ with :
305+ path : ./artifacts
306+ pattern : " commit-boost*"
307+
308+ - name : Download signatures
275309 uses : actions/download-artifact@v4
276310 with :
277311 path : ./artifacts
278- pattern : " commit-boost- *"
312+ pattern : " signatures-${{ github.ref_name }} *"
279313
280314 - name : Finalize Release
281315 uses : softprops/action-gh-release@v2
282316 with :
283317 files : ./artifacts/**/*
284318 draft : true
285- prerelease : false
319+ prerelease : ${{ contains(github.ref_name, '-rc') }}
286320 tag_name : ${{ github.ref_name }}
287321 name : ${{ github.ref_name }}
288322 env :
289323 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
324+
325+ # Fast-forwards stable (full release) or beta (RC) to the new tag.
326+ # Runs after all artifacts are built and the draft release is created,
327+ # so stable/beta are never touched if any part of the pipeline fails.
328+ fast-forward-branch :
329+ needs :
330+ - finalize-release
331+ runs-on : ubuntu-latest
332+ steps :
333+ - uses : actions/create-github-app-token@v1
334+ id : app-token
335+ with :
336+ app-id : ${{ secrets.APP_ID }}
337+ private-key : ${{ secrets.APP_PRIVATE_KEY }}
338+
339+ - uses : actions/checkout@v4
340+ with :
341+ fetch-depth : 0
342+ token : ${{ steps.app-token.outputs.token }}
343+
344+ - name : Configure git
345+ run : |
346+ git config user.name "commit-boost-release-bot[bot]"
347+ git config user.email "commit-boost-release-bot[bot]@users.noreply.github.com"
348+
349+ - name : Fast-forward beta branch (RC releases)
350+ if : contains(github.ref_name, '-rc')
351+ run : |
352+ git checkout beta
353+ git merge --ff-only "${{ github.ref_name }}"
354+ git push origin beta
355+
356+ - name : Fast-forward stable branch (full releases)
357+ if : " !contains(github.ref_name, '-rc')"
358+ run : |
359+ git checkout stable
360+ git merge --ff-only "${{ github.ref_name }}"
361+ git push origin stable
362+
363+ # Deletes the tag if any job in the release pipeline fails.
364+ # This keeps the tag and release artifacts in sync — a tag should only
365+ # exist if the full pipeline completed successfully.
366+ # stable/beta are never touched on failure since fast-forward-branch
367+ # only runs after finalize-release succeeds.
368+ #
369+ # Note: if finalize-release specifically fails, a draft release may already
370+ # exist on GitHub pointing at the now-deleted tag and will need manual cleanup.
371+ cleanup-on-failure :
372+ needs :
373+ - build-binaries-linux
374+ - build-binaries-darwin
375+ - sign-binaries
376+ - build-and-push-pbs-docker
377+ - build-and-push-signer-docker
378+ - finalize-release
379+ - fast-forward-branch
380+ runs-on : ubuntu-latest
381+ if : failure()
382+ steps :
383+ - uses : actions/create-github-app-token@v1
384+ id : app-token
385+ with :
386+ app-id : ${{ secrets.APP_ID }}
387+ private-key : ${{ secrets.APP_PRIVATE_KEY }}
388+
389+ - uses : actions/checkout@v4
390+ with :
391+ token : ${{ steps.app-token.outputs.token }}
392+
393+ - name : Delete tag
394+ run : git push origin --delete ${{ github.ref_name }}
0 commit comments