SLSA Provenance #9
This file contains 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 Provenance | |
on: | |
workflow_dispatch: | |
permissions: read-all | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [macos-13, macos-14] | |
runs-on: ${{ matrix.os }} | |
outputs: | |
hash-darwin-x86_64: ${{ steps.hash.outputs.hash-darwin-x86_64 }} | |
hash-darwin-arm64: ${{ steps.hash.outputs.hash-darwin-arm64 }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | |
- name: Install dependencies | |
run: brew install popt | |
- id: arch | |
name: Get machine hardware name | |
run: | | |
arch=$(uname -m) | |
if [[ "${arch}" != "x86_64" && "${arch}" != "arm64" ]]; then | |
echo "Unexpected machine hardware name: ${arch}" | |
exit 1 | |
fi | |
echo "name=${arch}" >> "$GITHUB_OUTPUT" | |
- id: artifact | |
name: Generate build artifact | |
run: | | |
cmake -S . -B build | |
cmake --build build | |
output_dir="build/src" | |
artifact="${output_dir}/flog" | |
if [[ ! -f "${output_dir}/${artifact}" ]]; then | |
echo "Failed to generate build artifact: ${output_dir}/${artifact}" | |
exit 1 | |
fi | |
echo "dir=${output_dir}" >> "$GITHUB_OUTPUT" | |
echo "name=${artifact}" >> "$GITHUB_OUTPUT" | |
- id: archive | |
name: Compress build artifact | |
run: | | |
archive="flog-darwin-${{ steps.arch.outputs.name }}.tar.xz" | |
tar -cvJf "${archive}" -C "${{ steps.artifact.outputs.dir }}" "${{ steps.artifact.outputs.name }}" | |
echo "name=${archive}" >> "$GITHUB_OUTPUT" | |
- id: hash | |
name: Generate build artifact hash | |
run: | | |
set -o pipefail | |
b64_hash=$(shasum -a 256 "${{ steps.archive.outputs.name }}" | base64) | |
echo "hash-darwin-${{ steps.arch.outputs.name }}=${b64_hash}" >> "$GITHUB_OUTPUT" | |
- name: Upload build artifact | |
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 | |
with: | |
name: ${{ steps.archive.outputs.name }} | |
path: ${{ steps.archive.outputs.name }} | |
if-no-files-found: error | |
retention-days: 7 | |
combine_hashes: | |
needs: [build] | |
runs-on: ubuntu-latest | |
outputs: | |
hashes: ${{ steps.hashes.outputs.hashes }} | |
env: | |
HASHES: ${{ toJSON(needs.build.outputs) }} | |
steps: | |
- id: hashes | |
run: | | |
echo "$HASHES" | jq -r '.[] | @base64d' | sed "/^$/d" > hashes.txt | |
echo "hashes=$(cat hashes.txt | base64 -w0)" >> "$GITHUB_OUTPUT" | |
provenance: | |
needs: [combine_hashes] | |
permissions: | |
actions: read | |
id-token: write | |
contents: write | |
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] # Must specify version tag; see https://github.com/slsa-framework/slsa-verifier/issues/12 | |
with: | |
base64-subjects: ${{ needs.combine_hashes.outputs.hashes }} |