This repository has been archived by the owner on Nov 25, 2024. It is now read-only.
build: remove before
hook from GoReleaser
#3
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
name: goreleaser | |
on: | |
push: | |
tags: | |
- "v*" | |
permissions: | |
contents: read | |
jobs: | |
goreleaser: | |
outputs: | |
hashes: ${{ steps.hash.outputs.hashes }} | |
permissions: | |
contents: write # for goreleaser/goreleaser-action to create a GitHub release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe | |
with: | |
go-version: "1.18" | |
check-latest: true | |
- name: Install gopherjs | |
run: go install github.com/gopherjs/gopherjs@v1.18.0-beta3 | |
- name: Transpile gojs-cvss | |
run: gopherjs build . | |
- name: Install Syft | |
run: | | |
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin | |
- name: Run GoReleaser | |
id: run-goreleaser | |
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 | |
with: | |
version: latest | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
VERSION_LDFLAGS: ${{ steps.ldflags.outputs.version }} | |
- name: Generate subject | |
id: hash | |
env: | |
ARTIFACTS: "${{ steps.run-goreleaser.outputs.artifacts }}" | |
run: | | |
set -euo pipefail | |
checksum_file=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Checksum") | .path') | |
echo "hashes=$(cat $checksum_file | base64 -w0)" >> "$GITHUB_OUTPUT" | |
provenance: | |
needs: [goreleaser] | |
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.9.0 | |
with: | |
base64-subjects: "${{ needs.goreleaser.outputs.hashes }}" | |
upload-assets: true # upload to a new release | |
verification: | |
needs: [goreleaser, provenance] | |
runs-on: ubuntu-latest | |
permissions: read-all | |
steps: | |
- name: Install the verifier | |
uses: slsa-framework/slsa-verifier/actions/installer@v2.4.0 | |
- name: Download assets | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
PROVENANCE: "${{ needs.provenance.outputs.provenance-name }}" | |
run: | | |
set -euo pipefail | |
gh -R "$GITHUB_REPOSITORY" release download "$GITHUB_REF_NAME" -p "*.tar.gz" | |
gh -R "$GITHUB_REPOSITORY" release download "$GITHUB_REF_NAME" -p "*.sbom" | |
gh -R "$GITHUB_REPOSITORY" release download "$GITHUB_REF_NAME" -p "gojs-cvss.js*" | |
gh -R "$GITHUB_REPOSITORY" release download "$GITHUB_REF_NAME" -p "$PROVENANCE" | |
- name: Verify assets | |
env: | |
CHECKSUMS: ${{ needs.goreleaser.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 $fn" | |
slsa-verifier verify-artifact --provenance-path "$PROVENANCE" \ | |
--source-uri "github.com/$GITHUB_REPOSITORY" \ | |
--source-tag "$GITHUB_REF_NAME" \ | |
"$fn" | |
done <<<"$checksums" |