Skip to content

Commit d4761fe

Browse files
authored
Merge pull request #840 from google/signing
ci: Sign release artifacts.
2 parents 1eb4b8a + 11752bb commit d4761fe

1 file changed

Lines changed: 29 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ on:
99
tags:
1010
- v*
1111

12-
env:
13-
# Use docker.io for Docker Hub if empty
14-
REGISTRY: ghcr.io
15-
# github.repository as <account>/<repo>
16-
IMAGE_NAME: ${{ github.repository }}
17-
1812
jobs:
1913
goreleaser:
2014
runs-on: ubuntu-latest
@@ -23,6 +17,8 @@ jobs:
2317
contents: write
2418
env:
2519
flags: ""
20+
outputs:
21+
hashes: ${{ steps.hash.outputs.hashes }}
2622
steps:
2723
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
2824
run: echo "flags=--snapshot" >> $GITHUB_ENV
@@ -35,16 +31,42 @@ jobs:
3531
go-version-file: 'go.mod'
3632
cache: true
3733
- uses: goreleaser/goreleaser-action@v5
34+
id: run-goreleaser
3835
with:
3936
version: latest
40-
args: release --rm-dist ${{ env.flags }}
37+
args: release --clean ${{ env.flags }}
4138
env:
4239
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
- name: Generate subject
41+
id: hash
42+
env:
43+
ARTIFACTS: "${{ steps.run-goreleaser.outputs.artifacts }}"
44+
run: |
45+
set -euo pipefail
46+
hashes=$(echo $ARTIFACTS | jq --raw-output '.[] | {name, "digest": (.extra.Digest // .extra.Checksum)} | select(.digest) | {digest} + {name} | join(" ") | sub("^sha256:";"")' | base64 -w0)
47+
echo "hashes=$hashes" >> $GITHUB_OUTPUT
48+
49+
provenance:
50+
needs: [goreleaser]
51+
permissions:
52+
actions: read # To read the workflow path.
53+
id-token: write # To sign the provenance.
54+
contents: write # To add assets to a release.
55+
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
56+
with:
57+
base64-subjects: "${{ needs.goreleaser.outputs.hashes }}"
58+
upload-assets: true # upload to a new release
59+
4360
docker-release:
4461
runs-on: ubuntu-latest
4562
permissions:
4663
# docker writes packages to container registry
4764
packages: write
65+
env:
66+
# Use docker.io for Docker Hub if empty
67+
REGISTRY: ghcr.io
68+
# github.repository as <account>/<repo>
69+
IMAGE_NAME: ${{ github.repository }}
4870
steps:
4971
- uses: actions/checkout@v4
5072
with:

0 commit comments

Comments
 (0)