Skip to content

Commit 0187400

Browse files
authored
signs digest not tag to abide by cosign v4 (#87)
Signed-off-by: Chris Burns <[email protected]>
1 parent e2c6c95 commit 0187400

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,32 +56,27 @@ jobs:
5656
run: echo "OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
5757

5858
- name: Build and push container
59+
id: build
5960
env:
6061
KO_DOCKER_REPO: ghcr.io/${{ steps.repo_owner.outputs.OWNER }}/gofetch
6162
VERSION: ${{ steps.tag.outputs.VERSION }}
6263
CREATION_TIME: $(date -u +'%Y-%m-%dT%H:%M:%SZ')
6364
run: |
6465
# Build and push the container with reproducible build flags
65-
ko build \
66+
# Ko outputs the full image reference with digest
67+
DIGEST=$(ko build \
6668
--bare \
6769
--sbom=spdx \
6870
--platform=linux/amd64,linux/arm64 \
6971
--base-import-paths \
7072
--tags $VERSION,latest \
71-
./cmd/server
73+
./cmd/server)
74+
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
7275
7376
- name: Install Cosign
7477
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
7578

7679
- name: Sign Image with Cosign
77-
env:
78-
KO_DOCKER_REPO: ghcr.io/${{ steps.repo_owner.outputs.OWNER }}/gofetch
7980
run: |
80-
TAG=$(echo "${{ steps.tag.outputs.VERSION }}" | sed 's/+/_/g')
81-
# Sign the ko image
82-
cosign sign -y $KO_DOCKER_REPO/server:$TAG
83-
84-
# Sign the latest tag if building from a tag
85-
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
86-
cosign sign -y $KO_DOCKER_REPO/server:latest
87-
fi
81+
# Sign the image by digest (immutable reference)
82+
cosign sign -y ${{ steps.build.outputs.digest }}

0 commit comments

Comments
 (0)