|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + id-token: write |
| 11 | + attestations: write |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: release-${{ github.ref }} |
| 15 | + |
| 16 | +jobs: |
| 17 | + release: |
| 18 | + name: Build release artifacts |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout release tag |
| 23 | + uses: actions/checkout@v7 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - name: Build release artifacts |
| 28 | + run: | |
| 29 | + DOCKER_BUILDKIT=1 docker build . \ |
| 30 | + --file Dockerfile.packaging \ |
| 31 | + --target artifacts \ |
| 32 | + --output type=local,dest=release-artifacts |
| 33 | +
|
| 34 | + - name: Verify checksums |
| 35 | + working-directory: release-artifacts |
| 36 | + run: sha256sum --check SHA256SUMS |
| 37 | + |
| 38 | + - name: Verify embedded version |
| 39 | + working-directory: release-artifacts |
| 40 | + env: |
| 41 | + RELEASE_TAG: ${{ github.ref_name }} |
| 42 | + run: | |
| 43 | + # Match build.sh, which strips every "v" from the tag to form the version. |
| 44 | + expected_version=$(echo "${RELEASE_TAG}" | tr -d 'v') |
| 45 | +
|
| 46 | + # linux-amd64 runs on the runner, so assert the reported version exactly. |
| 47 | + tar -xzf gh-ost-linux-amd64.tar.gz |
| 48 | + actual_version=$(./gh-ost --version) |
| 49 | + test "${actual_version%% *}" = "${expected_version}" |
| 50 | + rm -f gh-ost |
| 51 | +
|
| 52 | + # The other platforms can't execute here, so assert the version string is |
| 53 | + # embedded in each binary instead. |
| 54 | + for tarball in gh-ost-linux-arm64.tar.gz gh-ost-darwin-amd64.tar.gz gh-ost-darwin-arm64.tar.gz; do |
| 55 | + tar -xzf "${tarball}" |
| 56 | + grep -a -q -- "${expected_version}" gh-ost |
| 57 | + rm -f gh-ost |
| 58 | + done |
| 59 | +
|
| 60 | + - name: Attest release artifacts |
| 61 | + uses: actions/attest-build-provenance@v4 |
| 62 | + with: |
| 63 | + subject-path: release-artifacts/* |
| 64 | + |
| 65 | + - name: Create draft release |
| 66 | + env: |
| 67 | + GH_TOKEN: ${{ github.token }} |
| 68 | + RELEASE_TAG: ${{ github.ref_name }} |
| 69 | + run: | |
| 70 | + if ! gh release view "${RELEASE_TAG}" >/dev/null 2>&1; then |
| 71 | + gh release create "${RELEASE_TAG}" \ |
| 72 | + --verify-tag \ |
| 73 | + --draft \ |
| 74 | + --generate-notes \ |
| 75 | + --title "${RELEASE_TAG}" |
| 76 | + fi |
| 77 | +
|
| 78 | + - name: Upload release artifacts |
| 79 | + env: |
| 80 | + GH_TOKEN: ${{ github.token }} |
| 81 | + RELEASE_TAG: ${{ github.ref_name }} |
| 82 | + run: | |
| 83 | + test "$(gh release view "${RELEASE_TAG}" --json isDraft --jq '.isDraft')" = "true" |
| 84 | + gh release upload "${RELEASE_TAG}" release-artifacts/* --clobber |
0 commit comments