SLSA generic generator #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SLSA generic generator | |
on: | |
workflow_dispatch: | |
release: | |
types: [created] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
digests: ${{ steps.generate-hash.outputs.digests }} | |
steps: | |
- uses: actions/checkout@v4 | |
# Step 1: Build your artifacts. | |
- name: Build artifacts | |
run: | | |
# Assuming maze0.py is your main script | |
cp maze0.py artifact1 | |
echo "artifact2" > artifact2 | |
# Step 2: Generate the provenance subjects. | |
- name: Generate subject for provenance | |
id: generate-hash | |
run: | | |
set -euo pipefail | |
# List the artifacts the provenance will refer to. | |
files=$(ls artifact1 artifact2) | |
# Generate the subjects (base64 encoded). | |
hashes=$(sha256sum $files | base64 -w0) | |
echo "hashes=$hashes" >> $GITHUB_ENV | |
echo "::set-output name=digests::$hashes" # Deprecated but included for compatibility | |
provenance: | |
needs: [build] | |
permissions: | |
actions: read # To read the workflow path. | |
id-token: write # To sign the provenance. | |
contents: write # To add assets to a release. | |
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.4.0 | |
with: | |
base64-subjects: "${{ needs.build.outputs.digests }}" | |
upload-assets: true # Optional: Upload to a new release |