Skip to content

Commit

Permalink
Sign checksum with cosign (#4181)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
lucacome committed Aug 17, 2023
1 parent 4e0795b commit 153f568
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ jobs:
needs: [checks, unit-tests]
outputs:
release-url: ${{ steps.release-notes.outputs.release-url }}
permissions:
contents: write # for lucacome/draft-release and goreleaser/goreleaser-action to manage releases
id-token: write # for goreleaser/goreleaser-action to sign artifacts
steps:
- name: Checkout Repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
Expand All @@ -99,7 +102,11 @@ jobs:

- name: Download Syft
uses: anchore/sbom-action/download-syft@78fc58e266e87a38d4194b2137a3d4e9bcaf7ca1 # v0.14.3
if: startsWith(github.ref, 'refs/tags/')
if: github.ref_type == 'tag'

- name: Install Cosign
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 # v3.1.1
if: github.ref_type == 'tag'

- name: Create/Update Draft
uses: lucacome/draft-release@d13ccde6350706e32f451566ee5cd4bf5a27de3d # v0.2.1
Expand Down
12 changes: 12 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ blobs:
extra_files:
- glob: ./dist/**.spdx.json

signs:
- cmd: cosign
artifacts: checksum
output: true
certificate: '${artifact}.pem'
args:
- sign-blob
- "--output-signature=${signature}"
- "--output-certificate=${certificate}"
- "${artifact}"
- "--yes"

announce:
slack:
enabled: true
Expand Down

0 comments on commit 153f568

Please sign in to comment.