|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +permissions: {} |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + name: Build, Sign & Release |
| 11 | + runs-on: ubuntu-latest |
| 12 | + environment: release |
| 13 | + permissions: |
| 14 | + contents: write # create tag, release, and upload assets |
| 15 | + id-token: write # Sigstore OIDC keyless signing |
| 16 | + attestations: write # SLSA build provenance |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Harden the runner (Audit all outbound calls) |
| 20 | + uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1 |
| 21 | + with: |
| 22 | + egress-policy: audit |
| 23 | + |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 26 | + |
| 27 | + - name: Extract version from script |
| 28 | + id: version |
| 29 | + run: | |
| 30 | + version=$(grep -m1 '^AGENT_VERSION=' stepsecurity-dev-machine-guard.sh | sed 's/AGENT_VERSION="//;s/"//') |
| 31 | + if [ -z "$version" ]; then |
| 32 | + echo "::error::Could not extract AGENT_VERSION from script" |
| 33 | + exit 1 |
| 34 | + fi |
| 35 | + tag="v${version}" |
| 36 | + echo "version=${version}" >> "$GITHUB_OUTPUT" |
| 37 | + echo "tag=${tag}" >> "$GITHUB_OUTPUT" |
| 38 | + echo "Detected version: ${version} (tag: ${tag})" |
| 39 | +
|
| 40 | + - name: Check tag does not already exist |
| 41 | + run: | |
| 42 | + if git rev-parse "refs/tags/${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then |
| 43 | + echo "::error::Tag ${{ steps.version.outputs.tag }} already exists. Bump AGENT_VERSION in the script before releasing." |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | +
|
| 47 | + - name: Install cosign |
| 48 | + uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0 |
| 49 | + |
| 50 | + - name: Sign script with Sigstore (keyless) |
| 51 | + run: | |
| 52 | + cosign sign-blob stepsecurity-dev-machine-guard.sh \ |
| 53 | + --bundle stepsecurity-dev-machine-guard.sh.bundle \ |
| 54 | + --yes |
| 55 | +
|
| 56 | + - name: Verify signature |
| 57 | + run: | |
| 58 | + cosign verify-blob stepsecurity-dev-machine-guard.sh \ |
| 59 | + --bundle stepsecurity-dev-machine-guard.sh.bundle \ |
| 60 | + --certificate-identity-regexp "github.com/step-security/dev-machine-guard" \ |
| 61 | + --certificate-oidc-issuer "https://token.actions.githubusercontent.com" |
| 62 | +
|
| 63 | + - name: Generate checksums |
| 64 | + run: | |
| 65 | + sha256sum stepsecurity-dev-machine-guard.sh > checksums.txt |
| 66 | + sha256sum stepsecurity-dev-machine-guard.sh.bundle >> checksums.txt |
| 67 | + echo "Checksums:" |
| 68 | + cat checksums.txt |
| 69 | +
|
| 70 | + - name: Create tag |
| 71 | + run: | |
| 72 | + git config user.name "github-actions[bot]" |
| 73 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 74 | + git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}" |
| 75 | + git push origin "${{ steps.version.outputs.tag }}" |
| 76 | +
|
| 77 | + - name: Create GitHub Release |
| 78 | + uses: step-security/action-gh-release@d45511d7589f080cf54961ff056b9705a74fd160 # v2.5.0 |
| 79 | + with: |
| 80 | + tag_name: ${{ steps.version.outputs.tag }} |
| 81 | + name: ${{ steps.version.outputs.tag }} |
| 82 | + generate_release_notes: true |
| 83 | + files: | |
| 84 | + stepsecurity-dev-machine-guard.sh |
| 85 | + stepsecurity-dev-machine-guard.sh.bundle |
| 86 | + checksums.txt |
| 87 | +
|
| 88 | + - name: Attest build provenance |
| 89 | + uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0 |
| 90 | + with: |
| 91 | + subject-path: stepsecurity-dev-machine-guard.sh |
0 commit comments