|
| 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