Skip to content

Commit 300cd24

Browse files
committed
ci: Sign release and containers with Cosign and GitHub OIDC
- Replace the Cosign static key with GitHub Actions OIDC when signing the flagger container image - Sign the GitHub release assets checksums with Cosign keyless - Sign the load-tester container image with Cosign keyless Signed-off-by: Stefan Prodan <[email protected]>
1 parent fb66d24 commit 300cd24

File tree

6 files changed

+29
-84
lines changed

6 files changed

+29
-84
lines changed

.cosign/README.md

-50
This file was deleted.

.cosign/cosign.key

-11
This file was deleted.

.cosign/cosign.pub

-4
This file was deleted.

.github/workflows/push-ld.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@ jobs:
1212
release-load-tester:
1313
runs-on: ubuntu-latest
1414
permissions:
15+
id-token: write
1516
packages: write
1617
steps:
17-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v3
19+
- uses: sigstore/cosign-installer@main
1820
- name: Prepare
1921
id: prep
2022
run: |
2123
VERSION=$(grep 'VERSION' cmd/loadtester/main.go | head -1 | awk '{ print $4 }' | tr -d '"')
2224
echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
2325
echo ::set-output name=VERSION::${VERSION}
2426
- name: Setup QEMU
25-
uses: docker/setup-qemu-action@v1
27+
uses: docker/setup-qemu-action@v2
2628
- name: Setup Docker Buildx
2729
id: buildx
28-
uses: docker/setup-buildx-action@v1
30+
uses: docker/setup-buildx-action@v2
2931
- name: Login to GitHub Container Registry
3032
uses: docker/login-action@v1
3133
with:
@@ -52,6 +54,8 @@ jobs:
5254
REVISION=${{ github.sha }}
5355
tags: ${{ steps.meta.outputs.tags }}
5456
labels: ${{ steps.meta.outputs.labels }}
55-
- name: Check images
57+
- name: Sign image
58+
env:
59+
COSIGN_EXPERIMENTAL: 1
5660
run: |
57-
docker buildx imagetools inspect ${{ env.IMAGE }}:${{ steps.prep.outputs.VERSION }}
61+
cosign sign ${{ env.IMAGE }}:${{ steps.prep.outputs.VERSION }}

.github/workflows/release.yml

+7-14
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
id-token: write # needed for keyless signing
1919
packages: write # needed for ghcr access
2020
steps:
21-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v3
2222
- uses: sigstore/cosign-installer@main
2323
- name: Prepare
2424
id: prep
@@ -29,12 +29,12 @@ jobs:
2929
echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
3030
echo ::set-output name=VERSION::${VERSION}
3131
- name: Setup QEMU
32-
uses: docker/setup-qemu-action@v1
32+
uses: docker/setup-qemu-action@v2
3333
- name: Setup Docker Buildx
3434
id: buildx
35-
uses: docker/setup-buildx-action@v1
35+
uses: docker/setup-buildx-action@v2
3636
- name: Login to GitHub Container Registry
37-
uses: docker/login-action@v1
37+
uses: docker/login-action@v2
3838
with:
3939
registry: ghcr.io
4040
username: fluxcdbot
@@ -60,17 +60,10 @@ jobs:
6060
tags: ${{ steps.meta.outputs.tags }}
6161
labels: ${{ steps.meta.outputs.labels }}
6262
- name: Sign image
63+
env:
64+
COSIGN_EXPERIMENTAL: 1
6365
run: |
64-
echo -n "${{secrets.COSIGN_PASSWORD}}" | \
65-
cosign sign -key ./.cosign/cosign.key -a git_sha=$GITHUB_SHA \
66-
${{ env.IMAGE }}:${{ steps.prep.outputs.VERSION }}
67-
- name: Check images
68-
run: |
69-
docker buildx imagetools inspect ${{ env.IMAGE }}:${{ steps.prep.outputs.VERSION }}
70-
- name: Verifiy image signature
71-
run: |
72-
cosign verify -key ./.cosign/cosign.pub \
73-
${{ env.IMAGE }}:${{ steps.prep.outputs.VERSION }}
66+
cosign sign ${{ env.IMAGE }}:${{ steps.prep.outputs.VERSION }}
7467
- name: Publish Helm charts
7568
uses: stefanprodan/[email protected]
7669
with:

.goreleaser.yml

+13
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,16 @@ sboms:
1515
artifacts: source
1616
documents:
1717
- "{{ .ProjectName }}_{{ .Version }}_sbom.spdx.json"
18+
19+
signs:
20+
- cmd: cosign
21+
env:
22+
- COSIGN_EXPERIMENTAL=1
23+
certificate: '${artifact}.pem'
24+
args:
25+
- sign-blob
26+
- '--output-certificate=${certificate}'
27+
- '--output-signature=${signature}'
28+
- '${artifact}'
29+
artifacts: checksum
30+
output: true

0 commit comments

Comments
 (0)