v0.0.75 #78
Workflow file for this run
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
# SPDX-FileCopyrightText: Copyright 2023 The Minder Authors | |
# SPDX-License-Identifier: Apache-2.0 | |
# This workflow compiles your minder server and client using a SLSA3 compliant | |
# build and then verifies the provenance of the built artifacts. | |
# It releases the following architectures: amd64, arm64, and armv7 on Linux, | |
# Windows, and macOS. | |
# 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: Release | |
on: | |
workflow_dispatch: | |
release: | |
types: [created] | |
permissions: | |
contents: write | |
jobs: | |
ldflags_args: | |
runs-on: ubuntu-latest | |
outputs: | |
commit-date: ${{ steps.ldflags.outputs.commit-date }} | |
commit: ${{ steps.ldflags.outputs.commit }} | |
version: ${{ steps.ldflags.outputs.version }} | |
tree-state: ${{ steps.ldflags.outputs.tree-state }} | |
steps: | |
- id: checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- id: ldflags | |
run: | | |
echo "commit=$GITHUB_SHA" >> $GITHUB_OUTPUT | |
echo "commit-date=$(git log --date=iso8601-strict -1 --pretty=%ct)" >> $GITHUB_OUTPUT | |
echo "version=$(git describe --tags --always --dirty | cut -c2-)" >> $GITHUB_OUTPUT | |
echo "tree-state=$(if git diff --quiet; then echo "clean"; else echo "dirty"; fi)" >> $GITHUB_OUTPUT | |
release: | |
name: Build and release | |
needs: | |
- ldflags_args | |
outputs: | |
hashes: ${{ steps.hash.outputs.hashes }} | |
permissions: | |
contents: write # To add assets to a release. | |
id-token: write # To do keyless signing with cosign | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- name: Install Syft | |
uses: anchore/sbom-action/download-syft@55dc4ee22412511ee8c3142cbea40418e6cec693 # v0.17.8 | |
- name: Install Cosign | |
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0 | |
- name: Run GoReleaser | |
id: run-goreleaser | |
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0 | |
with: | |
distribution: goreleaser | |
version: "~> v2" | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WINGET_GITHUB_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }} | |
VERSION: ${{ needs.ldflags_args.outputs.version }} | |
COMMIT: ${{ needs.ldflags_args.outputs.commit }} | |
COMMIT_DATE: ${{ needs.ldflags_args.outputs.commit-date }} | |
TREE_STATE: ${{ needs.ldflags_args.outputs.tree-state }} | |
- name: Generate subject | |
id: hash | |
env: | |
ARTIFACTS: "${{ steps.run-goreleaser.outputs.artifacts }}" | |
run: | | |
set -euo pipefail | |
hashes=$(echo $ARTIFACTS | jq --raw-output '.[] | {name, "digest": (.extra.Digest // .extra.Checksum)} | select(.digest) | {digest} + {name} | join(" ") | sub("^sha256:";"")' | base64 -w0) | |
if test "$hashes" = ""; then # goreleaser < v1.13.0 | |
checksum_file=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Checksum") | .path') | |
hashes=$(cat $checksum_file | base64 -w0) | |
fi | |
echo "hashes=$hashes" >> $GITHUB_OUTPUT | |
provenance: | |
name: Generate provenance (SLSA3) | |
needs: | |
- release | |
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/[email protected] | |
with: | |
base64-subjects: "${{ needs.release.outputs.hashes }}" | |
upload-assets: true # upload to a new release | |
verification: | |
name: Verify provenance of assets (SLSA3) | |
needs: | |
- release | |
- provenance | |
runs-on: ubuntu-latest | |
permissions: read-all | |
steps: | |
- name: Install the SLSA verifier | |
uses: slsa-framework/slsa-verifier/actions/installer@3714a2a4684014deb874a0e737dffa0ee02dd647 # v2.6.0 | |
- name: Download assets | |
env: | |
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
CHECKSUMS: "${{ needs.release.outputs.hashes }}" | |
ATT_FILE_NAME: "${{ needs.provenance.outputs.provenance-name }}" | |
run: | | |
set -euo pipefail | |
checksums=$(echo "$CHECKSUMS" | base64 -d) | |
while read -r line; do | |
fn=$(echo $line | cut -d ' ' -f2) | |
echo "Downloading $fn" | |
gh -R "$GITHUB_REPOSITORY" release download "$GITHUB_REF_NAME" -p "$fn" | |
done <<<"$checksums" | |
gh -R "$GITHUB_REPOSITORY" release download "$GITHUB_REF_NAME" -p "$ATT_FILE_NAME" | |
- name: Verify assets | |
env: | |
CHECKSUMS: "${{ needs.release.outputs.hashes }}" | |
PROVENANCE: "${{ needs.provenance.outputs.provenance-name }}" | |
run: | | |
set -euo pipefail | |
checksums=$(echo "$CHECKSUMS" | base64 -d) | |
while read -r line; do | |
fn=$(echo $line | cut -d ' ' -f2) | |
echo "Verifying SLSA provenance for $fn" | |
slsa-verifier verify-artifact --provenance-path "$PROVENANCE" \ | |
--source-uri "github.com/$GITHUB_REPOSITORY" \ | |
--source-tag "$GITHUB_REF_NAME" \ | |
"$fn" | |
done <<<"$checksums" |