Skip to content

Commit 9b8be29

Browse files
authored
Merge pull request #108 from garethjevans/cosign
Sign with cosign
2 parents 9859009 + cfd57b3 commit 9b8be29

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

.github/workflows/release.yaml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ on:
66
tags:
77
- '*'
88

9+
910
jobs:
1011
goreleaser:
1112
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
# This is used to complete the identity challenge
17+
# with sigstore/fulcio when running outside of PRs.
18+
id-token: write
1219
steps:
1320
- name: Checkout
1421
uses: actions/checkout@v2
@@ -45,9 +52,18 @@ jobs:
4552
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
4653
fi
4754
echo ::set-output name=version::${VERSION}
55+
echo ::set-output name=image::${DOCKER_IMAGE}
4856
echo ::set-output name=tags::${TAGS}
4957
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
5058
59+
# Install the cosign tool except on PR
60+
# https://github.com/sigstore/cosign-installer
61+
- name: Install cosign
62+
if: github.event_name != 'pull_request'
63+
uses: sigstore/cosign-installer@1e95c1de343b5b0c23352d6417ee3e48d5bcd422
64+
with:
65+
cosign-release: 'v1.4.0'
66+
5167
- name: Set up QEMU
5268
uses: docker/setup-qemu-action@v1
5369

@@ -61,7 +77,7 @@ jobs:
6177
password: ${{ secrets.DOCKERHUB_TOKEN }}
6278

6379
- name: Build and push
64-
id: docker_build
80+
id: build-and-push
6581
uses: docker/build-push-action@v2
6682
with:
6783
context: .
@@ -77,3 +93,16 @@ jobs:
7793
org.label-schema.url=${{ github.event.repository.html_url }}
7894
org.label-schema.vcs-ref=${{ github.sha }}
7995
org.label-schema.build-date=${{ steps.prep.outputs.created }}
96+
97+
# Sign the resulting Docker image digest except on PRs.
98+
# This will only write to the public Rekor transparency log when the Docker
99+
# repository is public to avoid leaking data. If you would like to publish
100+
# transparency data even for private images, pass --force to cosign below.
101+
# https://github.com/sigstore/cosign
102+
- name: Sign the published Docker image
103+
if: ${{ github.event_name != 'pull_request' }}
104+
env:
105+
COSIGN_EXPERIMENTAL: "true"
106+
# This step uses the identity token to provision an ephemeral certificate
107+
# against the sigstore community Fulcio instance.
108+
run: cosign sign ${{ steps.prep.outputs.image }}@${{ steps.build-and-push.outputs.digest }}

0 commit comments

Comments
 (0)