Skip to content

Commit 1436b65

Browse files
MatteoPologrutofacchinm
authored andcommitted
Add workflow to promote a release to Stable (qualcomm-linux#150)
* Add workflow to promote a release to Stable * Make a release when an image is promoted and generate a summary after each build * Promote the release as the last step to avoid pushing on S3 if something else fails * Add a release to releases only if it is not already there * Fix CHANGELOG file path
1 parent eb08d09 commit 1436b65

File tree

2 files changed

+106
-46
lines changed

2 files changed

+106
-46
lines changed

.github/workflows/build-tester-images.yaml

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ on:
3333

3434
# implicitely set all other permissions to none
3535
permissions:
36-
contents: write # to push the tag and make the release
36+
contents: read
3737
id-token: write
3838

3939
# cancel in progress builds for this workflow triggered by the same ref
@@ -50,8 +50,6 @@ jobs:
5050
options: --privileged # Required for chroot creation
5151
env:
5252
TARGET: ${{ github.run_number }}
53-
outputs:
54-
tag: ${{ steps.buildtag.outputs.BUILD_ID }}
5553
steps:
5654
- name: Update OS packages
5755
run: |
@@ -214,6 +212,7 @@ jobs:
214212
jq --arg target "$BUILD_ID" '.latest.version |= $target' info.json > info.json.tmp && mv info.json.tmp info.json
215213
jq --arg url "$URL" '.latest.url |= $url' info.json > info.json.tmp && mv info.json.tmp info.json
216214
jq --arg sha256 "$CHECKSUM" '.latest.sha256 |= $sha256' info.json > info.json.tmp && mv info.json.tmp info.json
215+
jq '.releases += [.latest]' info.json > info.json.tmp && mv info.json.tmp info.json
217216
env:
218217
BUILD_ID: ${{ steps.buildtag.outputs.BUILD_ID }}
219218
URL: https://downloads.oniudra.cc/${{ env.RELEASE_DIR }}/${{ steps.buildtag.outputs.BUILD_ID }}/arduino-unoq-debian-image-${{ steps.buildtag.outputs.BUILD_ID }}.tar.zst
@@ -279,47 +278,6 @@ jobs:
279278
aws s3 cp sboms s3://${{ secrets.S3_BUCKET }}/${{ env.RELEASE_DIR }}/${{ env.BUILD_ID }}/sboms/ --recursive
280279
if: ${{ github.event.inputs.release == 'true' }}
281280

282-
- name: Upload sboms artifact to make a release
283-
uses: actions/upload-artifact@v4
284-
with:
285-
if-no-files-found: error
286-
name: sboms
287-
overwrite: true
288-
path: sboms/*
289-
if: ${{ github.event.inputs.release == 'true' }}
290-
291-
release:
292-
runs-on: ubuntu-latest
293-
needs: build-and-push-debian-image
294-
if: ${{ github.event.inputs.release == 'true' }}
295-
env:
296-
TAG: ${{ needs.build-and-push-debian-image.outputs.tag }}
297-
steps:
298-
- name: Checkout
299-
uses: actions/checkout@v4
300-
with:
301-
fetch-depth: 0 # fetch all history for the create changelog step to work properly
302-
303-
- name: Download artifact
304-
uses: actions/download-artifact@v5
305-
with:
306-
merge-multiple: true
307-
path: sboms
308-
309-
- name: Tag release to bind tag and commit
281+
- name: Build summary
310282
run: |
311-
git config --global user.email "[email protected]"
312-
git config --global user.name "${{ env.GITHUB_USERNAME }}"
313-
git tag ${{ env.TAG }} -m "${{ env.TAG }}"
314-
git push origin ${{ env.TAG }}
315-
316-
- name: Create Github Release and upload artifacts
317-
uses: ncipollo/release-action@v1
318-
with:
319-
token: ${{ env.GITHUB_TOKEN }}
320-
draft: false
321-
prerelease: true
322-
# NOTE: "Artifact is a directory" warnings are expected and don't indicate a problem
323-
# (all the files we need are in the DIST_DIR root)
324-
artifacts: sboms/*
325-
tag: ${{ env.TAG }}
283+
echo "Release available here: https://downloads.oniudra.cc/${{ env.RELEASE_DIR }}/${{ steps.buildtag.outputs.BUILD_ID }}/arduino-unoq-debian-image-${{ steps.buildtag.outputs.BUILD_ID }}.tar.zst" >> $GITHUB_STEP_SUMMARY

.github/workflows/promote.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Promote a release to Stable
2+
3+
env:
4+
GITHUB_TOKEN: ${{ secrets.ARDUINOBOT_TOKEN }}
5+
GITHUB_USERNAME: ArduinoBot
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
type: string
12+
description: version of the image to promote
13+
required: true
14+
15+
# cancel in progress builds for this workflow
16+
concurrency:
17+
group: ${{ github.workflow }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
promote-release:
22+
environment: staging
23+
runs-on: ubuntu-latest
24+
permissions:
25+
id-token: write # Required for OIDC authentication
26+
contents: write # Required to tag the release
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Authenticate AWS
35+
uses: aws-actions/configure-aws-credentials@v4
36+
with:
37+
aws-region: 'us-east-1'
38+
role-to-assume: ${{ secrets.AWS_IAM_ROLE }}
39+
role-session-name: GHA_DebianImages_via_FederatedOIDC
40+
mask-aws-account-id: true
41+
42+
- name: Get unstable and stable info.json
43+
env:
44+
VERSION: ${{ github.event.inputs.version }}
45+
run: |
46+
aws s3 cp s3://${{ secrets.S3_BUCKET }}/debian-im/Unstable/info.json staging.json
47+
aws s3 cp s3://${{ secrets.S3_BUCKET }}/debian-im/Unstable/${{ env.VERSION }}/sboms/ sboms --recursive
48+
aws s3 cp s3://${{ secrets.S3_BUCKET }}/debian-im/Stable/info.json prod.json
49+
50+
- name: Add release to stable/production json
51+
run: |
52+
RELEASE=$(jq --arg target_version "$VERSION" '(.releases[] | select(.version == $target_version))' staging.json)
53+
RELEASE=$(jq --arg url "$URL" '.url |= $url' <<< $RELEASE)
54+
jq --argjson release "$RELEASE" '.latest = $release | if .releases | any(.version == $release.version) then . else .releases += [$release] end' prod.json > prod.json.tmp \
55+
&& mv prod.json.tmp prod.json
56+
env:
57+
VERSION: ${{ github.event.inputs.version }}
58+
URL: https://downloads.arduino.cc/debian-im/Stable/${{ github.event.inputs.version }}/arduino-unoq-debian-image-${{ github.event.inputs.version }}.tar.zst
59+
60+
- name: Tag release to bind tag and commit
61+
env:
62+
TAG: ${{ github.event.inputs.version }}
63+
run: |
64+
git config --global user.email "[email protected]"
65+
git config --global user.name "${{ env.GITHUB_USERNAME }}"
66+
git tag ${{ env.TAG }} -m "${{ env.TAG }}"
67+
git push origin ${{ env.TAG }}
68+
69+
- name: Create changelog
70+
uses: arduino/create-changelog@v1
71+
with:
72+
tag-regex: '^[0-9]{8}-[0-9]+$'
73+
changelog-file-path: "./CHANGELOG.md"
74+
75+
- name: Add download link to the changelog
76+
env:
77+
VERSION: ${{ github.event.inputs.version }}
78+
run: |
79+
echo >> "CHANGELOG.md"
80+
echo "## Download Release" >> "CHANGELOG.md"
81+
echo "Release available here: https://downloads.arduino.cc/debian-im/Stable/${{ env.VERSION }}/arduino-unoq-debian-image-${{ env.VERSION }}.tar.zst" >> "CHANGELOG.md"
82+
83+
- name: Create Github Release and upload artifacts
84+
uses: ncipollo/release-action@v1
85+
with:
86+
token: ${{ env.GITHUB_TOKEN }}
87+
bodyFile: CHANGELOG.md
88+
draft: false
89+
prerelease: true
90+
# NOTE: "Artifact is a directory" warnings are expected and don't indicate a problem
91+
# (all the files we need are in the DIST_DIR root)
92+
artifacts: sboms/*
93+
tag: ${{ github.event.inputs.version }}
94+
95+
- name: Promote release
96+
env:
97+
VERSION: ${{ github.event.inputs.version }}
98+
run: |
99+
aws s3 cp s3://${{ secrets.S3_BUCKET }}/debian-im/Unstable/${{ env.VERSION }}/ \
100+
s3://${{ secrets.S3_BUCKET }}/debian-im/Stable/${{ env.VERSION }}/ \
101+
--recursive
102+
aws s3 cp prod.json s3://${{ secrets.S3_BUCKET }}/debian-im/Stable/info.json

0 commit comments

Comments
 (0)