Files
starter-workflows/ci/generator-generic-ossf-slsa3-publish.yml
T

67 lines
2.4 KiB
YAML
Raw Normal View History

2022-07-19 00:59:05 +00:00
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
2022-08-01 15:00:08 +00:00
# This workflow lets you generate SLSA provenance file for your project.
# The generation satisfies level 3 for the provenance requirements - see https://slsa.dev/spec/v0.1/requirements
2022-07-19 15:55:40 +00:00
# The project is an initiative of the OpenSSF (openssf.org) and is developed at
2022-07-19 00:59:05 +00:00
# https://github.com/slsa-framework/slsa-github-generator.
# The provenance file can be verified using https://github.com/slsa-framework/slsa-verifier.
# For more information about SLSA and how it improves the supply-chain, visit slsa.dev.
name: SLSA generic generator
on:
workflow_dispatch:
release:
types: [created]
jobs:
build:
2022-07-19 01:14:33 +00:00
runs-on: ubuntu-latest
2022-07-19 00:59:05 +00:00
outputs:
digests: ${{ steps.hash.outputs.digests }}
steps:
2022-08-11 13:32:01 +00:00
- uses: actions/checkout@v3
2022-07-19 15:55:40 +00:00
2022-07-19 00:59:05 +00:00
# ========================================================
#
# Step 1: Build your artifacts.
#
2022-07-19 15:55:40 +00:00
# ========================================================
2022-07-19 00:59:05 +00:00
- name: Build artifacts
run: |
# These are some amazing artifacts.
echo "artifact1" > artifact1
echo "artifact2" > artifact2
# ========================================================
#
# Step 2: Add a step to generate the provenance subjects
# as shown below. Update the sha256 sum arguments
# to include all binaries that you generate
# provenance for.
#
# ========================================================
2023-01-03 00:18:37 -08:00
- name: Generate subject for provenance
2022-07-19 00:59:05 +00:00
id: hash
run: |
set -euo pipefail
2022-08-01 15:00:08 +00:00
# List the artifacts the provenance will refer to.
files=$(ls artifact*)
# Generate the subjects (base64 encoded).
2023-01-03 00:18:37 -08:00
echo "hashes=$(sha256sum $files | base64 -w0)" >> "${GITHUB_OUTPUT}"
2022-07-19 00:59:05 +00:00
provenance:
needs: [build]
permissions:
2022-07-19 01:21:35 +00:00
actions: read # To read the workflow path.
id-token: write # To sign the provenance.
contents: write # To add assets to a release.
2023-01-03 00:18:37 -08:00
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
2022-07-19 00:59:05 +00:00
with:
base64-subjects: "${{ needs.build.outputs.digests }}"
2022-07-19 01:06:11 +00:00
upload-assets: true # Optional: Upload to a new release