|
| 1 | +# This workflow uses actions that are not certified by GitHub. |
| 2 | +# They are provided by a third-party and are governed by |
| 3 | +# separate terms of service, privacy policy, and support |
| 4 | +# documentation. |
| 5 | + |
| 6 | +# This workflow lets you generate SLSA provenance file for your project. |
| 7 | +# The generation satisfies level 3 for the provenance requirements - see https://slsa.dev/spec/v0.1/requirements |
| 8 | +# The project is an initiative of the OpenSSF (openssf.org) and is developed at |
| 9 | +# https://github.com/slsa-framework/slsa-github-generator. |
| 10 | +# The provenance file can be verified using https://github.com/slsa-framework/slsa-verifier. |
| 11 | +# For more information about SLSA and how it improves the supply-chain, visit slsa.dev. |
| 12 | + |
| 13 | +name: SLSA generic generator |
| 14 | +on: |
| 15 | + workflow_dispatch: |
| 16 | + release: |
| 17 | + types: [created] |
| 18 | + |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + outputs: |
| 23 | + digests: ${{ steps.hash.outputs.digests }} |
| 24 | + |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + |
| 28 | + # ======================================================== |
| 29 | + # |
| 30 | + # Step 1: Build your artifacts. |
| 31 | + # |
| 32 | + # ======================================================== |
| 33 | + - name: Build artifacts |
| 34 | + run: | |
| 35 | + # These are some amazing artifacts. |
| 36 | + echo "artifact1" > artifact1 |
| 37 | + echo "artifact2" > artifact2 |
| 38 | +
|
| 39 | + # ======================================================== |
| 40 | + # |
| 41 | + # Step 2: Add a step to generate the provenance subjects |
| 42 | + # as shown below. Update the sha256 sum arguments |
| 43 | + # to include all binaries that you generate |
| 44 | + # provenance for. |
| 45 | + # |
| 46 | + # ======================================================== |
| 47 | + - name: Generate subject for provenance |
| 48 | + id: hash |
| 49 | + run: | |
| 50 | + set -euo pipefail |
| 51 | +
|
| 52 | + # List the artifacts the provenance will refer to. |
| 53 | + files=$(ls artifact*) |
| 54 | + # Generate the subjects (base64 encoded). |
| 55 | + echo "hashes=$(sha256sum $files | base64 -w0)" >> "${GITHUB_OUTPUT}" |
| 56 | +
|
| 57 | + provenance: |
| 58 | + needs: [build] |
| 59 | + permissions: |
| 60 | + actions: read # To read the workflow path. |
| 61 | + id-token: write # To sign the provenance. |
| 62 | + contents: write # To add assets to a release. |
| 63 | + uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] |
| 64 | + with: |
| 65 | + base64-subjects: "${{ needs.build.outputs.digests }}" |
| 66 | + upload-assets: true # Optional: Upload to a new release |
0 commit comments