Skip to content

Commit

Permalink
chore: add slsa provenance back (#326)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
eddycharly authored May 30, 2023
1 parent 12e67ed commit 644832c
Showing 1 changed file with 50 additions and 24 deletions.
74 changes: 50 additions & 24 deletions .github/workflows/release-goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
packages: write
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
image: ${{ steps.digest.outputs.image }}
digest: ${{ steps.digest.outputs.digest }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -51,22 +53,11 @@ jobs:
# args: release --clean --timeout 90m
# workdir: backend
run: |
set -e
go install github.com/goreleaser/goreleaser@d0cf457136ebae8ced6b64c9be061ab302cbb1a8
cd backend && goreleaser release --clean --timeout 90m
cd backend && goreleaser release --clean --timeout 90m && echo "artifacts=$(cat dist/artifacts.json)" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Generate subject
# id: hash
# env:
# ARTIFACTS: "${{ steps.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
- name: Upload artifacts.json
uses: svenstaro/upload-release-action@58d525808845e4c8ff229ea1d5d7c496504a79bc # 2.6.0
with:
Expand All @@ -81,15 +72,50 @@ jobs:
file: backend/dist/metadata.json
asset_name: metadata.json
tag: ${{ github.ref }}
- name: Generate subject
id: hash
env:
ARTIFACTS: "${{ steps.goreleaser.outputs.artifacts }}"
run: |
set -euo pipefail
checksum_file=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Checksum") | .path')
hashes=$(cat $checksum_file | base64 -w0)
echo "hashes=$hashes" >> $GITHUB_OUTPUT
- name: Image digest
id: digest
env:
ARTIFACTS: "${{ steps.goreleaser.outputs.artifacts }}"
run: |
set -euo pipefail
image_and_digest=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Docker Manifest") | .path')
image=$(echo "${image_and_digest}" | cut -d'@' -f1 | cut -d':' -f1)
digest=$(echo "${image_and_digest}" | cut -d'@' -f2)
echo "image=$image" >> "$GITHUB_OUTPUT"
echo "digest=$digest" >> "$GITHUB_OUTPUT"
provenance:
needs:
- goreleaser
permissions:
actions: read
id-token: write
contents: write
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
base64-subjects: "${{ needs.goreleaser.outputs.hashes }}"
upload-assets: true

# provenance:
# needs:
# - goreleaser
# permissions:
# actions: read
# id-token: write
# contents: write
# uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
# with:
# base64-subjects: "${{ needs.goreleaser.outputs.hashes }}"
# upload-assets: true
image-provenance:
needs:
- goreleaser
permissions:
actions: read
id-token: write
packages: write
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
image: ${{ needs.goreleaser.outputs.image }}
digest: ${{ needs.goreleaser.outputs.digest }}
registry-username: ${{ github.actor }}
secrets:
registry-password: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 644832c

Please sign in to comment.