|
| 1 | +# SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | +# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk> |
| 3 | +# |
| 4 | +# Release workflow — triggered by version tags (v*). |
| 5 | +# Builds release binary for Linux x86_64, generates changelog via git-cliff, |
| 6 | +# creates a GitHub Release with the binary attached, and produces SLSA provenance. |
| 7 | +name: Release |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + tags: |
| 12 | + - 'v*' |
| 13 | + |
| 14 | +permissions: read-all |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: Build Release Binary |
| 19 | + runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + outputs: |
| 23 | + hashes: ${{ steps.hash.outputs.hashes }} |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 |
| 26 | + |
| 27 | + - name: Install Rust toolchain |
| 28 | + uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable |
| 29 | + with: |
| 30 | + toolchain: stable |
| 31 | + |
| 32 | + - name: Cache cargo registry |
| 33 | + uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2 |
| 34 | + |
| 35 | + - name: Run tests |
| 36 | + run: cargo test --verbose |
| 37 | + |
| 38 | + - name: Build release binary |
| 39 | + run: cargo build --release --verbose |
| 40 | + |
| 41 | + - name: Build release binary with http feature |
| 42 | + run: cargo build --release --features http --verbose |
| 43 | + |
| 44 | + - name: Package release artifacts |
| 45 | + run: | |
| 46 | + mkdir -p dist |
| 47 | + cp target/release/panic-attack dist/panic-attack-linux-x86_64 |
| 48 | + strip dist/panic-attack-linux-x86_64 |
| 49 | + chmod +x dist/panic-attack-linux-x86_64 |
| 50 | + # Create tarball |
| 51 | + tar -czf dist/panic-attack-${GITHUB_REF_NAME}-linux-x86_64.tar.gz \ |
| 52 | + -C dist panic-attack-linux-x86_64 \ |
| 53 | + -C "${GITHUB_WORKSPACE}" LICENSE README.md ROADMAP.md SECURITY.md |
| 54 | +
|
| 55 | + - name: Generate artifact hashes |
| 56 | + id: hash |
| 57 | + run: | |
| 58 | + cd dist |
| 59 | + HASHES=$(sha256sum panic-attack-*.tar.gz | base64 -w0) |
| 60 | + echo "hashes=$HASHES" >> "$GITHUB_OUTPUT" |
| 61 | +
|
| 62 | + - name: Upload build artifacts |
| 63 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 64 | + with: |
| 65 | + name: release-artifacts |
| 66 | + path: dist/panic-attack-*.tar.gz |
| 67 | + retention-days: 5 |
| 68 | + |
| 69 | + changelog: |
| 70 | + name: Generate Changelog |
| 71 | + runs-on: ubuntu-latest |
| 72 | + permissions: |
| 73 | + contents: read |
| 74 | + outputs: |
| 75 | + changelog: ${{ steps.cliff.outputs.content }} |
| 76 | + version: ${{ steps.version.outputs.version }} |
| 77 | + steps: |
| 78 | + - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 |
| 79 | + with: |
| 80 | + fetch-depth: 0 |
| 81 | + |
| 82 | + - name: Extract version from tag |
| 83 | + id: version |
| 84 | + run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" |
| 85 | + |
| 86 | + - name: Install git-cliff |
| 87 | + run: | |
| 88 | + curl -sSfL https://github.com/orhun/git-cliff/releases/latest/download/git-cliff-$(uname -m)-unknown-linux-gnu.tar.gz \ |
| 89 | + | tar -xz --strip-components=1 -C /usr/local/bin/ git-cliff-*/git-cliff |
| 90 | +
|
| 91 | + - name: Generate changelog for this release |
| 92 | + id: cliff |
| 93 | + run: | |
| 94 | + CHANGELOG=$(git cliff --latest --strip header) |
| 95 | + { |
| 96 | + echo "content<<CLIFF_EOF" |
| 97 | + echo "$CHANGELOG" |
| 98 | + echo "CLIFF_EOF" |
| 99 | + } >> "$GITHUB_OUTPUT" |
| 100 | +
|
| 101 | + - name: Update full CHANGELOG.md |
| 102 | + run: | |
| 103 | + git cliff --output CHANGELOG.md |
| 104 | +
|
| 105 | + - name: Upload updated CHANGELOG.md |
| 106 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 107 | + with: |
| 108 | + name: changelog |
| 109 | + path: CHANGELOG.md |
| 110 | + retention-days: 5 |
| 111 | + |
| 112 | + release: |
| 113 | + name: Create GitHub Release |
| 114 | + needs: [build, changelog] |
| 115 | + runs-on: ubuntu-latest |
| 116 | + permissions: |
| 117 | + contents: write |
| 118 | + steps: |
| 119 | + - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 |
| 120 | + |
| 121 | + - name: Download build artifacts |
| 122 | + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 |
| 123 | + with: |
| 124 | + name: release-artifacts |
| 125 | + path: artifacts/ |
| 126 | + |
| 127 | + - name: Create GitHub Release |
| 128 | + uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2 |
| 129 | + with: |
| 130 | + body: ${{ needs.changelog.outputs.changelog }} |
| 131 | + draft: false |
| 132 | + prerelease: ${{ contains(github.ref_name, '-rc') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-alpha') }} |
| 133 | + generate_release_notes: false |
| 134 | + files: | |
| 135 | + artifacts/* |
| 136 | + env: |
| 137 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 138 | + |
| 139 | + provenance: |
| 140 | + name: SLSA Provenance |
| 141 | + needs: [build] |
| 142 | + permissions: |
| 143 | + actions: read |
| 144 | + id-token: write |
| 145 | + contents: write |
| 146 | + uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@f7dd8c54c2067bafc12ca7a55595d5ee9b75204a # v2.1.0 |
| 147 | + with: |
| 148 | + base64-subjects: ${{ needs.build.outputs.hashes }} |
0 commit comments