Bump actions/checkout from 4.1.2 to 4.1.5 #33
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: release | |
#on: | |
# push: | |
# tags: | |
# - '*' | |
# FIXME(vdemeester) Add commit + tag | |
jobs: | |
goreleaser: | |
outputs: | |
hashes: ${{ steps.hash.outputs.hashes }} | |
tag_name: ${{ steps.tag.outputs.tag_name }} | |
defaults: | |
run: | |
working-directory: image/git-init | |
permissions: | |
packages: write | |
id-token: write | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 | |
- run: git fetch --prune --unshallow | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version: '1.20' | |
check-latest: true | |
# This installs the current latest release. | |
- uses: ko-build/setup-ko@ace48d793556083a76f1e3e6068850c1f4a369aa # v0.6 | |
with: | |
version: v0.13.0 | |
- uses: imjasonh/setup-crane@00c9e93efa4e1138c9a7a5c594acd6c75a2fbf0c # v0.3 | |
- uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 # v3.1.1 | |
- name: Set tag output | |
id: tag | |
run: echo "tag_name=${GITHUB_REF#refs/*/}" >> "$GITHUB_OUTPUT" | |
- uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 | |
id: run-goreleaser | |
with: | |
version: latest | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: sign ko-image | |
run: | | |
digest=$(crane digest "${REGISTRY}":"${GIT_TAG}") | |
cosign sign --yes \ | |
-a GIT_HASH="${GIT_HASH}" \ | |
-a GIT_TAG="${GIT_TAG}" \ | |
-a RUN_ID="${RUN_ID}" \ | |
-a RUN_ATTEMPT="${RUN_ATTEMPT}" \ | |
"${REGISTRY}@${digest}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GIT_HASH: ${{ github.sha }} | |
GIT_TAG: ${{ steps.tag.outputs.tag_name }} | |
RUN_ATTEMPT: ${{ github.run_attempt }} | |
RUN_ID: ${{ github.run_id }} | |
REGISTRY: "ghcr.io/${{ github.repository }}" | |
- 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/[email protected] | |
with: | |
base64-subjects: "${{ needs.goreleaser.outputs.hashes }}" | |
upload-assets: true | |
upload-tag-name: "${{ needs.release.outputs.tag_name }}" | |
verification: | |
needs: | |
- goreleaser | |
- provenance | |
runs-on: ubuntu-latest | |
permissions: read-all | |
steps: | |
# Note: this will be replaced with the GHA in the future. | |
- name: Install the verifier | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set -euo pipefail | |
gh -R slsa-framework/slsa-verifier release download v1.3.2 -p "slsa-verifier-linux-amd64" | |
chmod ug+x slsa-verifier-linux-amd64 | |
# Note: see https://github.com/slsa-framework/slsa-verifier/blob/main/SHA256SUM.md | |
COMPUTED_HASH=$(sha256sum slsa-verifier-linux-amd64 | cut -d ' ' -f1) | |
EXPECTED_HASH="b1d6c9bbce6274e253f0be33158cacd7fb894c5ebd643f14a911bfe55574f4c0" | |
if [[ "$EXPECTED_HASH" != "$COMPUTED_HASH" ]];then | |
echo "error: expected $EXPECTED_HASH, computed $COMPUTED_HASH" | |
exit 1 | |
fi | |
- name: Download assets | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_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 "$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-linux-amd64 -artifact-path "$fn" \ | |
-provenance "$PROVENANCE" \ | |
-source "github.com/$GITHUB_REPOSITORY" \ | |
-tag "$GITHUB_REF_NAME" | |
done <<<"$checksums" |