Skip to content

Commit c90e4fc

Browse files
authored
Sign checksum with cosign (#4181) (#4258)
Adds config to sign artifacts. Since the checksum contains the SHAs of the artifacts, signing the checksums is enough to ensure that the artifacts were not modified. GoReleaser uses cosign to sign the artifact and uploads .sig and .pem to the release. (cherry picked from commit d64b566)
1 parent c152119 commit c90e4fc

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ jobs:
8686
needs: [checks, unit-tests]
8787
outputs:
8888
release-url: ${{ steps.release-notes.outputs.release-url }}
89+
permissions:
90+
contents: write # for lucacome/draft-release and goreleaser/goreleaser-action to manage releases
91+
id-token: write # for goreleaser/goreleaser-action to sign artifacts
8992
steps:
9093
- name: Checkout Repository
9194
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
@@ -99,7 +102,11 @@ jobs:
99102

100103
- name: Download Syft
101104
uses: anchore/sbom-action/download-syft@78fc58e266e87a38d4194b2137a3d4e9bcaf7ca1 # v0.14.3
102-
if: startsWith(github.ref, 'refs/tags/')
105+
if: github.ref_type == 'tag'
106+
107+
- name: Install Cosign
108+
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 # v3.1.1
109+
if: github.ref_type == 'tag'
103110

104111
- name: Create/Update Draft
105112
uses: lucacome/draft-release@d13ccde6350706e32f451566ee5cd4bf5a27de3d # v0.2.1

.goreleaser.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,18 @@ blobs:
117117
extra_files:
118118
- glob: ./dist/**.spdx.json
119119

120+
signs:
121+
- cmd: cosign
122+
artifacts: checksum
123+
output: true
124+
certificate: '${artifact}.pem'
125+
args:
126+
- sign-blob
127+
- "--output-signature=${signature}"
128+
- "--output-certificate=${certificate}"
129+
- "${artifact}"
130+
- "--yes"
131+
120132
announce:
121133
slack:
122134
enabled: true

0 commit comments

Comments
 (0)