mirror of
https://github.com/floci-io/floci.git
synced 2026-11-29 00:21:51 -05:00
feat(release): sign published image attestations with keyless cosign (#3914)
Move signing into its own sign-images job that consumes push-native's digest outputs, so a Fulcio or Rekor outage can no longer strand a partially published release, and document the cosign verify invocation for consumers. Closes #2397 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
This commit is contained in:
1 parent
288cc01268
commit
c357d37fa9
2 files changed
+118
-1
No files matched your search
@@ -19,9 +19,10 @@ on:
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+'
|
||||
|
||||
# Only the jobs that need an OIDC token request one: push-native (assume the
|
||||
# AWS role for ECR Public) and sign-images (that, plus a Fulcio certificate).
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
# Per-tag concurrency. Back-to-back tag pushes (e.g. 1.5.3 and 1.6.0 landing
|
||||
# minutes apart) resolve to different ${{ github.ref }} values, so they run
|
||||
@@ -139,6 +140,17 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
# Consumed by sign-images. Each is the digest of the pushed manifest index,
|
||||
# which is what cosign signs; the tags above are mutable, the digests are not.
|
||||
outputs:
|
||||
native-digest: ${{ steps.native.outputs.digest }}
|
||||
baseline-digest: ${{ steps.baseline.outputs.digest }}
|
||||
compat-digest: ${{ steps.compat.outputs.digest }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
@@ -194,6 +206,7 @@ jobs:
|
||||
registry-type: public
|
||||
|
||||
- name: Build and push native multi-arch image
|
||||
id: native
|
||||
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
|
||||
env:
|
||||
SOURCE_DATE_EPOCH: ${{ steps.source_date.outputs.epoch }}
|
||||
@@ -235,6 +248,7 @@ jobs:
|
||||
mv native/arm64/*-runner native/arm64/application
|
||||
|
||||
- name: Build and push ARMv8.0 baseline image
|
||||
id: baseline
|
||||
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
|
||||
env:
|
||||
SOURCE_DATE_EPOCH: ${{ steps.source_date.outputs.epoch }}
|
||||
@@ -263,6 +277,7 @@ jobs:
|
||||
cache-to: type=gha,scope=floci-arm64-baseline,mode=max
|
||||
|
||||
- name: Build and push compat multi-arch image
|
||||
id: compat
|
||||
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
|
||||
env:
|
||||
SOURCE_DATE_EPOCH: ${{ steps.source_date.outputs.epoch }}
|
||||
@@ -289,3 +304,64 @@ jobs:
|
||||
vcs-ref=${{ github.sha }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
# ── Sign the published images ────────────────────────────────────────────
|
||||
# Kept out of push-native on purpose: a Fulcio or Rekor outage mid-push would
|
||||
# otherwise leave `latest` updated while -baseline and -compat never publish,
|
||||
# and recovery would mean rebuilding everything. Signing only reads digests
|
||||
# that are already in the registries, so this job can be rerun on its own.
|
||||
sign-images:
|
||||
name: Sign published images
|
||||
needs: push-native
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Install Cosign
|
||||
# Keyless signing: the job's GitHub Actions OIDC token exchanges for a
|
||||
# short-lived Fulcio certificate and the signature is recorded in Rekor's
|
||||
# transparency log. No signing key to generate, store, or rotate.
|
||||
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
|
||||
with:
|
||||
cosign-release: 'v3.1.3'
|
||||
|
||||
# cosign writes each signature back to the registry beside the image it
|
||||
# signs, so both destinations need a logged-in session here as well.
|
||||
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Configure AWS credentials
|
||||
uses: aws-actions/configure-aws-credentials@e6de054238d6b7531b4efff3b6587d9aade6a06c # v6.2.3
|
||||
with:
|
||||
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
|
||||
aws-region: us-east-1
|
||||
|
||||
- name: Login to Amazon ECR Public
|
||||
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
|
||||
with:
|
||||
registry-type: public
|
||||
|
||||
- name: Sign images and their provenance/SBOM attestations
|
||||
# --recursive signs the pushed index and every manifest it references,
|
||||
# which includes the provenance/sbom attestation manifests BuildKit
|
||||
# attaches, not just the per-platform images. Those attestations are
|
||||
# unsigned in-toto JSON rather than cosign's own DSSE envelope, so a
|
||||
# consumer verifies them with `cosign verify` against the attestation
|
||||
# manifest's own digest (found via `docker buildx imagetools inspect`),
|
||||
# not `cosign verify-attestation`.
|
||||
env:
|
||||
DIGESTS: >-
|
||||
${{ needs.push-native.outputs.native-digest }}
|
||||
${{ needs.push-native.outputs.baseline-digest }}
|
||||
${{ needs.push-native.outputs.compat-digest }}
|
||||
run: |
|
||||
for digest in $DIGESTS; do
|
||||
cosign sign --yes --recursive "floci/floci@${digest}"
|
||||
cosign sign --yes --recursive "public.ecr.aws/floci/floci@${digest}"
|
||||
done
|
||||
Reference in new issue
Block a user