From 7bcbc121522b0dab11d06dd01ad6d3dd461c7a5c Mon Sep 17 00:00:00 2001 From: Andre Sutherland Date: Fri, 28 Aug 2026 16:34:53 +0100 Subject: [PATCH 1/8] ci: scan container images before they are tagged The Node.js, Python, dev auth and local events releases pushed fully tagged images and only scanned afterwards, so a failing scan left the tags live and merely skipped the signing. Every one of those images was published without a signature or provenance attestation. Each architecture is now built and pushed by digest, scanned, and only then assembled into the manifest that carries the tags, so an image that fails its scan is never tagged at all. Signing runs off the published manifests, which only exist once every scan has passed. This is the shape the core runtime release already used. Scans block on findings that have a fix available and report the rest, so the gate only ever asks for an upgrade that exists. The production images have to be clean while the dev images, which carry a shell and the tools to debug with, are reported on rather than blocked. Building each architecture on a runner of its own architecture drops the emulation the two runtime releases were doing. The local events release shared a build cache scope and a code scanning category with the Node.js runtime, so the two were clobbering each other. Both now derive from the component. The dev manifests gain a minor tag, which is what the CLI resolves a project's declared SDK range to. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/app-dev-auth-release.yml | 180 ++++++++--- .../workflows/app-local-events-release.yml | 185 +++++++---- .../workflows/app-runtime-core-release.yml | 4 + .../workflows/app-runtime-nodejs-release.yml | 289 +++++++++++------- .../workflows/app-runtime-python-release.yml | 289 +++++++++++------- 5 files changed, 625 insertions(+), 322 deletions(-) diff --git a/.github/workflows/app-dev-auth-release.yml b/.github/workflows/app-dev-auth-release.yml index d52a3349..e012f0dc 100644 --- a/.github/workflows/app-dev-auth-release.yml +++ b/.github/workflows/app-dev-auth-release.yml @@ -24,22 +24,38 @@ jobs: steps: - name: Extract version from tag id: version + env: + TAG: ${{ inputs.tag }} run: | - TAG="${{ inputs.tag }}" + if [[ ! "$TAG" =~ ^dev-auth/v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then + echo "::error::Expected a tag of the form dev-auth/v1.2.3, got '$TAG'" + exit 1 + fi VERSION="${TAG##*/}" VERSION="${VERSION#v}" - echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "Extracted version: $VERSION from tag: $TAG" build: - name: Build & Push Production Image - runs-on: ubuntu-latest + name: Build on ${{ matrix.platform.arch }} + runs-on: ${{ matrix.platform.runner }} + needs: prepare permissions: contents: read packages: write - needs: prepare - outputs: - digest: ${{ steps.build.outputs.digest }} + security-events: write + strategy: + fail-fast: false + matrix: + # Each architecture is built on a runner of its own architecture rather + # than one runner emulating the other. + platform: + - arch: amd64 + os: linux/amd64 + runner: ubuntu-latest + - arch: arm64 + os: linux/arm64 + runner: ubuntu-24.04-arm steps: - uses: actions/checkout@v4 @@ -59,78 +75,148 @@ jobs: id: meta with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=semver,pattern={{version}},value=${{ needs.prepare.outputs.version }} - type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }} - type=raw,value=latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} labels: | org.opencontainers.image.title=Celerity Dev Auth org.opencontainers.image.description=Lightweight OIDC provider for local development and testing of Celerity applications - - uses: docker/setup-qemu-action@v3 + # Needed for the container driver. The docker driver that a runner has by + # default cannot export an image by digest, which is how each + # architecture is pushed before there is a manifest to tag. - uses: docker/setup-buildx-action@v3 + # Pushed without a tag, since a tag naming two architectures can only be + # applied once both exist. The manifest that carries the tags is assembled + # from these digests once every architecture has been built. - id: build uses: docker/build-push-action@v6 with: context: apps/dev-auth target: production - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} + platforms: ${{ matrix.platform.os }} labels: ${{ steps.meta.outputs.labels }} - annotations: ${{ steps.meta.outputs.annotations }} - cache-from: type=gha,scope=dev-auth-prod - cache-to: type=gha,mode=max,scope=dev-auth-prod - - scan-images: - name: Scan Container Images - runs-on: ubuntu-latest - permissions: - contents: read - security-events: write - needs: [build] - steps: - - uses: actions/checkout@v4 - - - name: Trivy scan production image (table) + # Without this buildx attaches a provenance attestation, which makes + # what is pushed an index holding the image and the attestation rather + # than the image itself. Scanning that index means resolving a + # platform inside it, and the manifest list assembled below is where + # multiple platforms belong anyway. The release still gets provenance, + # from the attestation step that runs against the published manifest. + provenance: false + outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true + cache-from: type=gha,scope=dev-auth-${{ matrix.platform.arch }} + cache-to: type=gha,mode=max,scope=dev-auth-${{ matrix.platform.arch }} + + # Scanned here, before the manifest that carries the tags is assembled, + # so an image with a critical vulnerability is never tagged. Scanning + # after publication would leave the tags live and only skip the signing, + # which is a worse outcome than a failed release. + - name: Scan the image uses: aquasecurity/trivy-action@0.35.0 with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.digest }}" + image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" format: "table" severity: "CRITICAL,HIGH" + # Blocks on anything with a fix available, so the gate only ever + # asks for an upgrade that exists. Findings with no released fix are + # still reported below, so they are recorded rather than dismissed. + ignore-unfixed: true exit-code: "1" - - name: Trivy scan production image (SARIF) - if: always() + - name: Scan the image (SARIF) + if: "!cancelled() && steps.build.outputs.digest != ''" uses: aquasecurity/trivy-action@0.35.0 with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.digest }}" + image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" format: "sarif" - output: "trivy-dev-auth.sarif" + output: "trivy.sarif" severity: "CRITICAL,HIGH" exit-code: "0" - - name: Upload production scan results + - name: Upload the scan results uses: github/codeql-action/upload-sarif@v4 - if: always() + if: "!cancelled() && hashFiles('trivy.sarif') != ''" + with: + sarif_file: "trivy.sarif" + category: "container-dev-auth-${{ matrix.platform.arch }}" + + - name: Export the digest + env: + DIGEST: ${{ steps.build.outputs.digest }} + run: | + mkdir -p /tmp/digests + touch "/tmp/digests/${DIGEST#sha256:}" + + - uses: actions/upload-artifact@v4 with: - sarif_file: "trivy-dev-auth.sarif" - category: "container-dev-auth" + name: digests-${{ matrix.platform.arch }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + + merge: + name: Publish Manifest + runs-on: ubuntu-latest + needs: [prepare, build] + permissions: + contents: read + packages: write + outputs: + digest: ${{ steps.manifest.outputs.digest }} + steps: + - uses: actions/download-artifact@v4 + with: + path: /tmp/digests + pattern: digests-* + merge-multiple: true + + - uses: docker/setup-buildx-action@v3 + + - uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/metadata-action@v5 + id: meta + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}},value=${{ needs.prepare.outputs.version }} + type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }} + type=raw,value=latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} + + - name: Create the manifest list + working-directory: /tmp/digests + run: | + docker buildx imagetools create \ + $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) + + - name: Read the manifest digest + id: manifest + env: + VERSION: ${{ needs.prepare.outputs.version }} + run: | + digest=$(docker buildx imagetools inspect \ + "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}" \ + --format '{{json .Manifest}}' | jq -r .digest) + echo "digest=$digest" >> "$GITHUB_OUTPUT" sign-and-attest: name: Sign & Attest Images runs-on: ubuntu-latest + needs: [merge] + # Nothing reaches a manifest unless its scan passed, so getting this far + # already means every image being signed is one that cleared the scan. + if: needs.merge.result == 'success' permissions: contents: read packages: write id-token: write attestations: write - needs: [build, scan-images] - # A signature and a provenance attestation say this image is fit to - # pull, so a failed scan has to stop them being made. - if: needs.build.result == 'success' && needs.scan-images.result == 'success' env: + # Store signatures and attestations as OCI 1.1 referrers instead of + # tag-based artifacts (.sig/.att/.sbom tags) that pollute the GHCR UI. COSIGN_REGISTRY_REFERRERS_MODE: oci-1-1 steps: - uses: docker/login-action@v3 @@ -145,21 +231,21 @@ jobs: - name: Sign production image (cosign keyless) run: | cosign sign --yes \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.digest }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge.outputs.digest }} - name: Generate production SBOM run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.digest }} \ + syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge.outputs.digest }} \ -o spdx-json=dev-auth-sbom.spdx.json - name: Attest production SBOM run: | cosign attest --yes --predicate dev-auth-sbom.spdx.json --type spdxjson \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.digest }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge.outputs.digest }} - name: GitHub attestation (production) uses: actions/attest-build-provenance@v3 with: subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.build.outputs.digest }} + subject-digest: ${{ needs.merge.outputs.digest }} push-to-registry: true diff --git a/.github/workflows/app-local-events-release.yml b/.github/workflows/app-local-events-release.yml index f6540599..f8f7e0bd 100644 --- a/.github/workflows/app-local-events-release.yml +++ b/.github/workflows/app-local-events-release.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: tag: - description: 'Release tag (e.g. apps/local-events/v0.3.0)' + description: 'Release tag (e.g. local-events/v0.3.0)' required: true type: string @@ -24,22 +24,38 @@ jobs: steps: - name: Extract version from tag id: version + env: + TAG: ${{ inputs.tag }} run: | - TAG="${{ inputs.tag }}" + if [[ ! "$TAG" =~ ^local-events/v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then + echo "::error::Expected a tag of the form local-events/v1.2.3, got '$TAG'" + exit 1 + fi VERSION="${TAG##*/}" VERSION="${VERSION#v}" - echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "Extracted version: $VERSION from tag: $TAG" build: - name: Build & Push Production Image - runs-on: ubuntu-latest + name: Build on ${{ matrix.platform.arch }} + runs-on: ${{ matrix.platform.runner }} + needs: prepare permissions: contents: read packages: write - needs: prepare - outputs: - digest: ${{ steps.build.outputs.digest }} + security-events: write + strategy: + fail-fast: false + matrix: + # Each architecture is built on a runner of its own architecture rather + # than one runner emulating the other. + platform: + - arch: amd64 + os: linux/amd64 + runner: ubuntu-latest + - arch: arm64 + os: linux/arm64 + runner: ubuntu-24.04-arm steps: - uses: actions/checkout@v4 @@ -59,77 +75,145 @@ jobs: id: meta with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=semver,pattern={{version}},value=${{ needs.prepare.outputs.version }} - type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }} - type=raw,value=latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} labels: | org.opencontainers.image.title=Celerity Local Events Sidecar org.opencontainers.image.description=Celerity Local Events Sidecar for local development and testing of Celerity applications - - uses: docker/setup-qemu-action@v3 + # Needed for the container driver. The docker driver that a runner has by + # default cannot export an image by digest, which is how each + # architecture is pushed before there is a manifest to tag. - uses: docker/setup-buildx-action@v3 + # Pushed without a tag, since a tag naming two architectures can only be + # applied once both exist. The manifest that carries the tags is assembled + # from these digests once every architecture has been built. - id: build uses: docker/build-push-action@v6 with: context: apps/local-events target: production - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} + platforms: ${{ matrix.platform.os }} labels: ${{ steps.meta.outputs.labels }} - annotations: ${{ steps.meta.outputs.annotations }} - cache-from: type=gha,scope=runtime-prod - cache-to: type=gha,mode=max,scope=runtime-prod - - scan-images: - name: Scan Container Images - runs-on: ubuntu-latest - permissions: - contents: read - security-events: write - needs: [build] - steps: - - uses: actions/checkout@v4 - - - name: Trivy scan production image (table) + # Without this buildx attaches a provenance attestation, which makes + # what is pushed an index holding the image and the attestation rather + # than the image itself. Scanning that index means resolving a + # platform inside it, and the manifest list assembled below is where + # multiple platforms belong anyway. The release still gets provenance, + # from the attestation step that runs against the published manifest. + provenance: false + outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true + cache-from: type=gha,scope=local-events-${{ matrix.platform.arch }} + cache-to: type=gha,mode=max,scope=local-events-${{ matrix.platform.arch }} + + # Scanned here, before the manifest that carries the tags is assembled, + # so an image with a critical vulnerability is never tagged. Scanning + # after publication would leave the tags live and only skip the signing, + # which is a worse outcome than a failed release. + - name: Scan the image uses: aquasecurity/trivy-action@0.35.0 with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.digest }}" + image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" format: "table" severity: "CRITICAL,HIGH" + # Blocks on anything with a fix available, so the gate only ever + # asks for an upgrade that exists. Findings with no released fix are + # still reported below, so they are recorded rather than dismissed. + ignore-unfixed: true exit-code: "1" - - name: Trivy scan production image (SARIF) - if: always() + - name: Scan the image (SARIF) + if: "!cancelled() && steps.build.outputs.digest != ''" uses: aquasecurity/trivy-action@0.35.0 with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.digest }}" + image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" format: "sarif" - output: "trivy-runtime.sarif" + output: "trivy.sarif" severity: "CRITICAL,HIGH" exit-code: "0" - - name: Upload production scan results + - name: Upload the scan results uses: github/codeql-action/upload-sarif@v4 - if: always() + if: "!cancelled() && hashFiles('trivy.sarif') != ''" + with: + sarif_file: "trivy.sarif" + category: "container-local-events-${{ matrix.platform.arch }}" + + - name: Export the digest + env: + DIGEST: ${{ steps.build.outputs.digest }} + run: | + mkdir -p /tmp/digests + touch "/tmp/digests/${DIGEST#sha256:}" + + - uses: actions/upload-artifact@v4 with: - sarif_file: "trivy-runtime.sarif" - category: "container-runtime" + name: digests-${{ matrix.platform.arch }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + + merge: + name: Publish Manifest + runs-on: ubuntu-latest + needs: [prepare, build] + permissions: + contents: read + packages: write + outputs: + digest: ${{ steps.manifest.outputs.digest }} + steps: + - uses: actions/download-artifact@v4 + with: + path: /tmp/digests + pattern: digests-* + merge-multiple: true + + - uses: docker/setup-buildx-action@v3 + + - uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/metadata-action@v5 + id: meta + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}},value=${{ needs.prepare.outputs.version }} + type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }} + type=raw,value=latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} + + - name: Create the manifest list + working-directory: /tmp/digests + run: | + docker buildx imagetools create \ + $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) + + - name: Read the manifest digest + id: manifest + env: + VERSION: ${{ needs.prepare.outputs.version }} + run: | + digest=$(docker buildx imagetools inspect \ + "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}" \ + --format '{{json .Manifest}}' | jq -r .digest) + echo "digest=$digest" >> "$GITHUB_OUTPUT" sign-and-attest: name: Sign & Attest Images runs-on: ubuntu-latest + needs: [merge] + # Nothing reaches a manifest unless its scan passed, so getting this far + # already means every image being signed is one that cleared the scan. + if: needs.merge.result == 'success' permissions: contents: read packages: write id-token: write attestations: write - needs: [build, scan-images] - # A signature and a provenance attestation say this image is fit to - # pull, so a failed scan has to stop them being made. - if: needs.build.result == 'success' && needs.scan-images.result == 'success' env: # Store signatures and attestations as OCI 1.1 referrers instead of # tag-based artifacts (.sig/.att/.sbom tags) that pollute the GHCR UI. @@ -144,25 +228,24 @@ jobs: - uses: sigstore/cosign-installer@v3 - uses: anchore/sbom-action/download-syft@v0 - # --- Production image --- - name: Sign production image (cosign keyless) run: | cosign sign --yes \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.digest }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge.outputs.digest }} - name: Generate production SBOM run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.digest }} \ - -o spdx-json=runtime-sbom.spdx.json + syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge.outputs.digest }} \ + -o spdx-json=local-events-sbom.spdx.json - name: Attest production SBOM run: | - cosign attest --yes --predicate runtime-sbom.spdx.json --type spdxjson \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.digest }} + cosign attest --yes --predicate local-events-sbom.spdx.json --type spdxjson \ + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge.outputs.digest }} - name: GitHub attestation (production) uses: actions/attest-build-provenance@v3 with: subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.build.outputs.digest }} + subject-digest: ${{ needs.merge.outputs.digest }} push-to-registry: true diff --git a/.github/workflows/app-runtime-core-release.yml b/.github/workflows/app-runtime-core-release.yml index 6f857b03..a87fa6c2 100644 --- a/.github/workflows/app-runtime-core-release.yml +++ b/.github/workflows/app-runtime-core-release.yml @@ -240,8 +240,12 @@ jobs: id: meta with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # The minor tag is what the CLI resolves a project's declared SDK + # range to, so a runtime-only patch reaches projects without every + # one of them editing a pin. tags: | type=raw,value=dev-${{ needs.prepare.outputs.version }} + type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }},prefix=dev- type=raw,value=dev-latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - name: Create the manifest list diff --git a/.github/workflows/app-runtime-nodejs-release.yml b/.github/workflows/app-runtime-nodejs-release.yml index 3397ec0f..4dd1e30c 100644 --- a/.github/workflows/app-runtime-nodejs-release.yml +++ b/.github/workflows/app-runtime-nodejs-release.yml @@ -24,22 +24,40 @@ jobs: steps: - name: Extract version from tag id: version + env: + TAG: ${{ inputs.tag }} run: | - TAG="${{ inputs.tag }}" + if [[ ! "$TAG" =~ ^runtime-nodejs/v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then + echo "::error::Expected a tag of the form runtime-nodejs/v1.2.3, got '$TAG'" + exit 1 + fi VERSION="${TAG##*/}" VERSION="${VERSION#v}" - echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "Extracted version: $VERSION from tag: $TAG" - build-runtime: - name: Build & Push Production Image - runs-on: ubuntu-latest + build: + name: Build ${{ matrix.target }} on ${{ matrix.platform.arch }} + runs-on: ${{ matrix.platform.runner }} + needs: prepare permissions: contents: read packages: write - needs: prepare - outputs: - digest: ${{ steps.build.outputs.digest }} + security-events: write + strategy: + fail-fast: false + matrix: + target: [runtime, dev] + # Each architecture is built on a runner of its own architecture rather + # than one runner emulating the other, which keeps the arm64 yarn + # install off QEMU. + platform: + - arch: amd64 + os: linux/amd64 + runner: ubuntu-latest + - arch: arm64 + os: linux/arm64 + runner: ubuntu-24.04-arm steps: - uses: actions/checkout@v4 @@ -59,47 +77,102 @@ jobs: id: meta with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=semver,pattern={{version}},value=${{ needs.prepare.outputs.version }} - type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }} - type=raw,value=latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} labels: | - org.opencontainers.image.title=Celerity Node.js Runtime - org.opencontainers.image.description=Production runtime for Celerity Node.js applications + org.opencontainers.image.title=Celerity Node.js Runtime${{ matrix.target == 'dev' && ' (Dev)' || '' }} + org.opencontainers.image.description=${{ matrix.target == 'dev' && 'Development runtime for Celerity Node.js applications (includes SWC, pino-pretty)' || 'Production runtime for Celerity Node.js applications' }} - - uses: docker/setup-qemu-action@v3 + # Needed for the container driver. The docker driver that a runner has by + # default cannot export an image by digest, which is how each + # architecture is pushed before there is a manifest to tag. - uses: docker/setup-buildx-action@v3 + # Pushed without a tag, since a tag naming two architectures can only be + # applied once both exist. The manifest that carries the tags is assembled + # from these digests once every architecture has been built. - id: build uses: docker/build-push-action@v6 with: context: apps/runtime/nodejs - target: runtime - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} + target: ${{ matrix.target }} + platforms: ${{ matrix.platform.os }} labels: ${{ steps.meta.outputs.labels }} - annotations: ${{ steps.meta.outputs.annotations }} - cache-from: type=gha,scope=runtime-prod - cache-to: type=gha,mode=max,scope=runtime-prod + # Without this buildx attaches a provenance attestation, which makes + # what is pushed an index holding the image and the attestation rather + # than the image itself. Scanning that index means resolving a + # platform inside it, and the manifest list assembled below is where + # multiple platforms belong anyway. The release still gets provenance, + # from the attestation step that runs against the published manifest. + provenance: false + outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true + cache-from: type=gha,scope=runtime-nodejs-${{ matrix.target }}-${{ matrix.platform.arch }} + cache-to: type=gha,mode=max,scope=runtime-nodejs-${{ matrix.target }}-${{ matrix.platform.arch }} + + # Scanned here, before the manifest that carries the tags is assembled, + # so an image with a critical vulnerability is never tagged. Scanning + # after publication would leave the tags live and only skip the signing, + # which is a worse outcome than a failed release. + - name: Scan the image + uses: aquasecurity/trivy-action@0.35.0 + with: + image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" + format: "table" + severity: "CRITICAL,HIGH" + # Blocks on anything with a fix available, so the gate only ever + # asks for an upgrade that exists. Findings with no released fix are + # still reported below, so they are recorded rather than dismissed. + ignore-unfixed: true + # The production image has to be clean. The dev image carries a shell + # and the tools to debug with, and is reported on rather than blocked. + exit-code: ${{ matrix.target == 'runtime' && '1' || '0' }} + + - name: Scan the image (SARIF) + if: "!cancelled() && steps.build.outputs.digest != ''" + uses: aquasecurity/trivy-action@0.35.0 + with: + image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" + format: "sarif" + output: "trivy.sarif" + severity: "CRITICAL,HIGH" + exit-code: "0" + + - name: Upload the scan results + uses: github/codeql-action/upload-sarif@v4 + if: "!cancelled() && hashFiles('trivy.sarif') != ''" + with: + sarif_file: "trivy.sarif" + category: "container-nodejs-${{ matrix.target }}-${{ matrix.platform.arch }}" + + - name: Export the digest + env: + DIGEST: ${{ steps.build.outputs.digest }} + run: | + mkdir -p /tmp/digests + touch "/tmp/digests/${DIGEST#sha256:}" + + - uses: actions/upload-artifact@v4 + with: + name: digests-${{ matrix.target }}-${{ matrix.platform.arch }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 - build-dev: - name: Build & Push Dev Image + merge-runtime: + name: Publish Production Manifest runs-on: ubuntu-latest + needs: [prepare, build] permissions: contents: read packages: write - needs: prepare outputs: - digest: ${{ steps.build.outputs.digest }} + digest: ${{ steps.manifest.outputs.digest }} steps: - - uses: actions/checkout@v4 - - - uses: docker/login-action@v3 + - uses: actions/download-artifact@v4 with: - registry: dhi.io - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + path: /tmp/digests + pattern: digests-runtime-* + merge-multiple: true + + - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: @@ -112,100 +185,92 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=raw,value=dev-${{ needs.prepare.outputs.version }} - type=raw,value=dev-latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - labels: | - org.opencontainers.image.title=Celerity Node.js Runtime (Dev) - org.opencontainers.image.description=Development runtime for Celerity Node.js applications (includes SWC, pino-pretty) - - - uses: docker/setup-qemu-action@v3 - - uses: docker/setup-buildx-action@v3 + type=semver,pattern={{version}},value=${{ needs.prepare.outputs.version }} + type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }} + type=raw,value=latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - - id: build - uses: docker/build-push-action@v6 - with: - context: apps/runtime/nodejs - target: dev - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - annotations: ${{ steps.meta.outputs.annotations }} - cache-from: type=gha,scope=runtime-dev - cache-to: type=gha,mode=max,scope=runtime-dev + - name: Create the manifest list + working-directory: /tmp/digests + run: | + docker buildx imagetools create \ + $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) + + - name: Read the manifest digest + id: manifest + env: + VERSION: ${{ needs.prepare.outputs.version }} + run: | + digest=$(docker buildx imagetools inspect \ + "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}" \ + --format '{{json .Manifest}}' | jq -r .digest) + echo "digest=$digest" >> "$GITHUB_OUTPUT" - scan-images: - name: Scan Container Images + merge-dev: + name: Publish Dev Manifest runs-on: ubuntu-latest + needs: [prepare, build] permissions: contents: read - security-events: write - needs: [build-runtime, build-dev] + packages: write + outputs: + digest: ${{ steps.manifest.outputs.digest }} steps: - - uses: actions/checkout@v4 - - - name: Trivy scan production image (table) - uses: aquasecurity/trivy-action@0.35.0 + - uses: actions/download-artifact@v4 with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-runtime.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - exit-code: "1" + path: /tmp/digests + pattern: digests-dev-* + merge-multiple: true - - name: Trivy scan production image (SARIF) - if: always() - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-runtime.outputs.digest }}" - format: "sarif" - output: "trivy-runtime.sarif" - severity: "CRITICAL,HIGH" - exit-code: "0" - - - name: Upload production scan results - uses: github/codeql-action/upload-sarif@v4 - if: always() - with: - sarif_file: "trivy-runtime.sarif" - category: "container-runtime" + - uses: docker/setup-buildx-action@v3 - - name: Trivy scan dev image (table) - uses: aquasecurity/trivy-action@0.35.0 + - uses: docker/login-action@v3 with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-dev.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - exit-code: "0" + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Trivy scan dev image (SARIF) - if: always() - uses: aquasecurity/trivy-action@0.35.0 + - uses: docker/metadata-action@v5 + id: meta with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-dev.outputs.digest }}" - format: "sarif" - output: "trivy-dev.sarif" - severity: "CRITICAL,HIGH" - exit-code: "0" + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # The minor tag is what the CLI resolves a project's declared SDK + # range to, so a runtime-only patch reaches projects without every + # one of them editing a pin. + tags: | + type=raw,value=dev-${{ needs.prepare.outputs.version }} + type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }},prefix=dev- + type=raw,value=dev-latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - - name: Upload dev scan results - uses: github/codeql-action/upload-sarif@v4 - if: always() - with: - sarif_file: "trivy-dev.sarif" - category: "container-dev" + - name: Create the manifest list + working-directory: /tmp/digests + run: | + docker buildx imagetools create \ + $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) + + - name: Read the manifest digest + id: manifest + env: + VERSION: ${{ needs.prepare.outputs.version }} + run: | + digest=$(docker buildx imagetools inspect \ + "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev-${VERSION}" \ + --format '{{json .Manifest}}' | jq -r .digest) + echo "digest=$digest" >> "$GITHUB_OUTPUT" sign-and-attest: name: Sign & Attest Images runs-on: ubuntu-latest + needs: [merge-runtime, merge-dev] + # Nothing reaches a manifest unless its scan passed, so getting this far + # already means every image being signed is one that cleared the scan. + if: needs.merge-runtime.result == 'success' && needs.merge-dev.result == 'success' permissions: contents: read packages: write id-token: write attestations: write - needs: [build-runtime, build-dev, scan-images] - # A signature and a provenance attestation say this image is fit to - # pull, so a failed scan has to stop them being made. - if: needs.build-runtime.result == 'success' && needs.build-dev.result == 'success' && needs.scan-images.result == 'success' env: # Store signatures and attestations as OCI 1.1 referrers instead of # tag-based artifacts (.sig/.att/.sbom tags) that pollute the GHCR UI. @@ -224,44 +289,44 @@ jobs: - name: Sign production image (cosign keyless) run: | cosign sign --yes \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-runtime.outputs.digest }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} - name: Generate production SBOM run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-runtime.outputs.digest }} \ + syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} \ -o spdx-json=runtime-sbom.spdx.json - name: Attest production SBOM run: | cosign attest --yes --predicate runtime-sbom.spdx.json --type spdxjson \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-runtime.outputs.digest }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} - name: GitHub attestation (production) uses: actions/attest-build-provenance@v3 with: subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.build-runtime.outputs.digest }} + subject-digest: ${{ needs.merge-runtime.outputs.digest }} push-to-registry: true # --- Dev image --- - name: Sign dev image (cosign keyless) run: | cosign sign --yes \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-dev.outputs.digest }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} - name: Generate dev SBOM run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-dev.outputs.digest }} \ + syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} \ -o spdx-json=dev-sbom.spdx.json - name: Attest dev SBOM run: | cosign attest --yes --predicate dev-sbom.spdx.json --type spdxjson \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-dev.outputs.digest }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} - name: GitHub attestation (dev) uses: actions/attest-build-provenance@v3 with: subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.build-dev.outputs.digest }} + subject-digest: ${{ needs.merge-dev.outputs.digest }} push-to-registry: true diff --git a/.github/workflows/app-runtime-python-release.yml b/.github/workflows/app-runtime-python-release.yml index fd547f62..9bec9a21 100644 --- a/.github/workflows/app-runtime-python-release.yml +++ b/.github/workflows/app-runtime-python-release.yml @@ -24,22 +24,40 @@ jobs: steps: - name: Extract version from tag id: version + env: + TAG: ${{ inputs.tag }} run: | - TAG="${{ inputs.tag }}" + if [[ ! "$TAG" =~ ^runtime-python/v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then + echo "::error::Expected a tag of the form runtime-python/v1.2.3, got '$TAG'" + exit 1 + fi VERSION="${TAG##*/}" VERSION="${VERSION#v}" - echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "Extracted version: $VERSION from tag: $TAG" - build-runtime: - name: Build & Push Production Image - runs-on: ubuntu-latest + build: + name: Build ${{ matrix.target }} on ${{ matrix.platform.arch }} + runs-on: ${{ matrix.platform.runner }} + needs: prepare permissions: contents: read packages: write - needs: prepare - outputs: - digest: ${{ steps.build.outputs.digest }} + security-events: write + strategy: + fail-fast: false + matrix: + target: [runtime, dev] + # Each architecture is built on a runner of its own architecture rather + # than one runner emulating the other, which keeps the arm64 dependency + # install off QEMU. + platform: + - arch: amd64 + os: linux/amd64 + runner: ubuntu-latest + - arch: arm64 + os: linux/arm64 + runner: ubuntu-24.04-arm steps: - uses: actions/checkout@v4 @@ -59,47 +77,102 @@ jobs: id: meta with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=semver,pattern={{version}},value=${{ needs.prepare.outputs.version }} - type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }} - type=raw,value=latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} labels: | - org.opencontainers.image.title=Celerity Python Runtime - org.opencontainers.image.description=Production runtime for Celerity Python applications + org.opencontainers.image.title=Celerity Python Runtime${{ matrix.target == 'dev' && ' (Dev)' || '' }} + org.opencontainers.image.description=${{ matrix.target == 'dev' && 'Development runtime for Celerity Python applications (includes watchfiles auto-reload)' || 'Production runtime for Celerity Python applications' }} - - uses: docker/setup-qemu-action@v3 + # Needed for the container driver. The docker driver that a runner has by + # default cannot export an image by digest, which is how each + # architecture is pushed before there is a manifest to tag. - uses: docker/setup-buildx-action@v3 + # Pushed without a tag, since a tag naming two architectures can only be + # applied once both exist. The manifest that carries the tags is assembled + # from these digests once every architecture has been built. - id: build uses: docker/build-push-action@v6 with: context: apps/runtime/python - target: runtime - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} + target: ${{ matrix.target }} + platforms: ${{ matrix.platform.os }} labels: ${{ steps.meta.outputs.labels }} - annotations: ${{ steps.meta.outputs.annotations }} - cache-from: type=gha,scope=runtime-python-prod - cache-to: type=gha,mode=max,scope=runtime-python-prod + # Without this buildx attaches a provenance attestation, which makes + # what is pushed an index holding the image and the attestation rather + # than the image itself. Scanning that index means resolving a + # platform inside it, and the manifest list assembled below is where + # multiple platforms belong anyway. The release still gets provenance, + # from the attestation step that runs against the published manifest. + provenance: false + outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true + cache-from: type=gha,scope=runtime-python-${{ matrix.target }}-${{ matrix.platform.arch }} + cache-to: type=gha,mode=max,scope=runtime-python-${{ matrix.target }}-${{ matrix.platform.arch }} + + # Scanned here, before the manifest that carries the tags is assembled, + # so an image with a critical vulnerability is never tagged. Scanning + # after publication would leave the tags live and only skip the signing, + # which is a worse outcome than a failed release. + - name: Scan the image + uses: aquasecurity/trivy-action@0.35.0 + with: + image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" + format: "table" + severity: "CRITICAL,HIGH" + # Blocks on anything with a fix available, so the gate only ever + # asks for an upgrade that exists. Findings with no released fix are + # still reported below, so they are recorded rather than dismissed. + ignore-unfixed: true + # The production image has to be clean. The dev image carries a shell + # and the tools to debug with, and is reported on rather than blocked. + exit-code: ${{ matrix.target == 'runtime' && '1' || '0' }} + + - name: Scan the image (SARIF) + if: "!cancelled() && steps.build.outputs.digest != ''" + uses: aquasecurity/trivy-action@0.35.0 + with: + image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" + format: "sarif" + output: "trivy.sarif" + severity: "CRITICAL,HIGH" + exit-code: "0" + + - name: Upload the scan results + uses: github/codeql-action/upload-sarif@v4 + if: "!cancelled() && hashFiles('trivy.sarif') != ''" + with: + sarif_file: "trivy.sarif" + category: "container-python-${{ matrix.target }}-${{ matrix.platform.arch }}" + + - name: Export the digest + env: + DIGEST: ${{ steps.build.outputs.digest }} + run: | + mkdir -p /tmp/digests + touch "/tmp/digests/${DIGEST#sha256:}" + + - uses: actions/upload-artifact@v4 + with: + name: digests-${{ matrix.target }}-${{ matrix.platform.arch }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 - build-dev: - name: Build & Push Dev Image + merge-runtime: + name: Publish Production Manifest runs-on: ubuntu-latest + needs: [prepare, build] permissions: contents: read packages: write - needs: prepare outputs: - digest: ${{ steps.build.outputs.digest }} + digest: ${{ steps.manifest.outputs.digest }} steps: - - uses: actions/checkout@v4 - - - uses: docker/login-action@v3 + - uses: actions/download-artifact@v4 with: - registry: dhi.io - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + path: /tmp/digests + pattern: digests-runtime-* + merge-multiple: true + + - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: @@ -112,100 +185,92 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=raw,value=dev-${{ needs.prepare.outputs.version }} - type=raw,value=dev-latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - labels: | - org.opencontainers.image.title=Celerity Python Runtime (Dev) - org.opencontainers.image.description=Development runtime for Celerity Python applications (includes watchfiles auto-reload) - - - uses: docker/setup-qemu-action@v3 - - uses: docker/setup-buildx-action@v3 + type=semver,pattern={{version}},value=${{ needs.prepare.outputs.version }} + type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }} + type=raw,value=latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - - id: build - uses: docker/build-push-action@v6 - with: - context: apps/runtime/python - target: dev - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - annotations: ${{ steps.meta.outputs.annotations }} - cache-from: type=gha,scope=runtime-python-dev - cache-to: type=gha,mode=max,scope=runtime-python-dev + - name: Create the manifest list + working-directory: /tmp/digests + run: | + docker buildx imagetools create \ + $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) + + - name: Read the manifest digest + id: manifest + env: + VERSION: ${{ needs.prepare.outputs.version }} + run: | + digest=$(docker buildx imagetools inspect \ + "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}" \ + --format '{{json .Manifest}}' | jq -r .digest) + echo "digest=$digest" >> "$GITHUB_OUTPUT" - scan-images: - name: Scan Container Images + merge-dev: + name: Publish Dev Manifest runs-on: ubuntu-latest + needs: [prepare, build] permissions: contents: read - security-events: write - needs: [build-runtime, build-dev] + packages: write + outputs: + digest: ${{ steps.manifest.outputs.digest }} steps: - - uses: actions/checkout@v4 - - - name: Trivy scan production image (table) - uses: aquasecurity/trivy-action@0.35.0 + - uses: actions/download-artifact@v4 with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-runtime.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - exit-code: "1" + path: /tmp/digests + pattern: digests-dev-* + merge-multiple: true - - name: Trivy scan production image (SARIF) - if: always() - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-runtime.outputs.digest }}" - format: "sarif" - output: "trivy-runtime.sarif" - severity: "CRITICAL,HIGH" - exit-code: "0" - - - name: Upload production scan results - uses: github/codeql-action/upload-sarif@v4 - if: always() - with: - sarif_file: "trivy-runtime.sarif" - category: "container-python-runtime" + - uses: docker/setup-buildx-action@v3 - - name: Trivy scan dev image (table) - uses: aquasecurity/trivy-action@0.35.0 + - uses: docker/login-action@v3 with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-dev.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - exit-code: "0" + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Trivy scan dev image (SARIF) - if: always() - uses: aquasecurity/trivy-action@0.35.0 + - uses: docker/metadata-action@v5 + id: meta with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-dev.outputs.digest }}" - format: "sarif" - output: "trivy-dev.sarif" - severity: "CRITICAL,HIGH" - exit-code: "0" + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # The minor tag is what the CLI resolves a project's declared SDK + # range to, so a runtime-only patch reaches projects without every + # one of them editing a pin. + tags: | + type=raw,value=dev-${{ needs.prepare.outputs.version }} + type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }},prefix=dev- + type=raw,value=dev-latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - - name: Upload dev scan results - uses: github/codeql-action/upload-sarif@v4 - if: always() - with: - sarif_file: "trivy-dev.sarif" - category: "container-python-dev" + - name: Create the manifest list + working-directory: /tmp/digests + run: | + docker buildx imagetools create \ + $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) + + - name: Read the manifest digest + id: manifest + env: + VERSION: ${{ needs.prepare.outputs.version }} + run: | + digest=$(docker buildx imagetools inspect \ + "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev-${VERSION}" \ + --format '{{json .Manifest}}' | jq -r .digest) + echo "digest=$digest" >> "$GITHUB_OUTPUT" sign-and-attest: name: Sign & Attest Images runs-on: ubuntu-latest + needs: [merge-runtime, merge-dev] + # Nothing reaches a manifest unless its scan passed, so getting this far + # already means every image being signed is one that cleared the scan. + if: needs.merge-runtime.result == 'success' && needs.merge-dev.result == 'success' permissions: contents: read packages: write id-token: write attestations: write - needs: [build-runtime, build-dev, scan-images] - # A signature and a provenance attestation say this image is fit to - # pull, so a failed scan has to stop them being made. - if: needs.build-runtime.result == 'success' && needs.build-dev.result == 'success' && needs.scan-images.result == 'success' env: # Store signatures and attestations as OCI 1.1 referrers instead of # tag-based artifacts (.sig/.att/.sbom tags) that pollute the GHCR UI. @@ -224,44 +289,44 @@ jobs: - name: Sign production image (cosign keyless) run: | cosign sign --yes \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-runtime.outputs.digest }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} - name: Generate production SBOM run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-runtime.outputs.digest }} \ + syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} \ -o spdx-json=runtime-sbom.spdx.json - name: Attest production SBOM run: | cosign attest --yes --predicate runtime-sbom.spdx.json --type spdxjson \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-runtime.outputs.digest }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} - name: GitHub attestation (production) uses: actions/attest-build-provenance@v3 with: subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.build-runtime.outputs.digest }} + subject-digest: ${{ needs.merge-runtime.outputs.digest }} push-to-registry: true # --- Dev image --- - name: Sign dev image (cosign keyless) run: | cosign sign --yes \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-dev.outputs.digest }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} - name: Generate dev SBOM run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-dev.outputs.digest }} \ + syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} \ -o spdx-json=dev-sbom.spdx.json - name: Attest dev SBOM run: | cosign attest --yes --predicate dev-sbom.spdx.json --type spdxjson \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-dev.outputs.digest }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} - name: GitHub attestation (dev) uses: actions/attest-build-provenance@v3 with: subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.build-dev.outputs.digest }} + subject-digest: ${{ needs.merge-dev.outputs.digest }} push-to-registry: true From e5b8c97f5e2bdac3a8d1eb1860fcb4898170656e Mon Sep 17 00:00:00 2001 From: Andre Sutherland Date: Fri, 28 Aug 2026 16:35:13 +0100 Subject: [PATCH 2/8] deps(runtime-nodejs): pin protobufjs to a release with the RCE fixed The image carried protobufjs 7.5.4, which has an arbitrary code execution flaw rated critical along with five high severity findings, reaching the tree through the gRPC proto loader that the OpenTelemetry exporters depend on. Every finding in the image had a fix available, so the release scan blocked on all of them. The proto loader asks for a caret range on 7.5.3, so the resolution below satisfies it without overriding what the dependency declared. Scanning the lock file after the change reports nothing. Co-Authored-By: Claude Opus 5 (1M context) --- apps/runtime/nodejs/package.json | 3 ++ apps/runtime/nodejs/yarn.lock | 61 ++++++++++++++------------------ 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/apps/runtime/nodejs/package.json b/apps/runtime/nodejs/package.json index 8e63d099..0b590c70 100644 --- a/apps/runtime/nodejs/package.json +++ b/apps/runtime/nodejs/package.json @@ -26,5 +26,8 @@ "@swc/core": "^1.11.0", "pino-pretty": "^13.0.0", "typescript": "^5.7.0" + }, + "resolutions": { + "protobufjs": "^7.6.6" } } diff --git a/apps/runtime/nodejs/yarn.lock b/apps/runtime/nodejs/yarn.lock index bb21b9d2..62dd85f6 100644 --- a/apps/runtime/nodejs/yarn.lock +++ b/apps/runtime/nodejs/yarn.lock @@ -962,27 +962,26 @@ __metadata: languageName: node linkType: hard -"@protobufjs/codegen@npm:^2.0.4": - version: 2.0.4 - resolution: "@protobufjs/codegen@npm:2.0.4" - checksum: 10c0/26ae337c5659e41f091606d16465bbcc1df1f37cc1ed462438b1f67be0c1e28dfb2ca9f294f39100c52161aef82edf758c95d6d75650a1ddf31f7ddee1440b43 +"@protobufjs/codegen@npm:^2.0.5": + version: 2.0.5 + resolution: "@protobufjs/codegen@npm:2.0.5" + checksum: 10c0/1b8a2ae56ee60a56e9d205cd4b6072a1503c5069b8ebb905710f974ff0098a0d0700641c137e0a8d98dedf14423156a106a9433695cbf52574810f55000fdcab languageName: node linkType: hard -"@protobufjs/eventemitter@npm:^1.1.0": - version: 1.1.0 - resolution: "@protobufjs/eventemitter@npm:1.1.0" - checksum: 10c0/1eb0a75180e5206d1033e4138212a8c7089a3d418c6dfa5a6ce42e593a4ae2e5892c4ef7421f38092badba4040ea6a45f0928869989411001d8c1018ea9a6e70 +"@protobufjs/eventemitter@npm:^1.1.1": + version: 1.1.1 + resolution: "@protobufjs/eventemitter@npm:1.1.1" + checksum: 10c0/8e06193d4629c5e7c09d4f8c2ddba8fc4dfa739f0149f33a1d901568d35bb7b8b5277a4e8452baf3bdd0b302fd599cf255d193267aa93a0a4747e23cd073c4ac languageName: node linkType: hard -"@protobufjs/fetch@npm:^1.1.0": - version: 1.1.0 - resolution: "@protobufjs/fetch@npm:1.1.0" +"@protobufjs/fetch@npm:^1.1.1": + version: 1.1.1 + resolution: "@protobufjs/fetch@npm:1.1.1" dependencies: "@protobufjs/aspromise": "npm:^1.1.1" - "@protobufjs/inquire": "npm:^1.1.0" - checksum: 10c0/cda6a3dc2d50a182c5865b160f72077aac197046600091dbb005dd0a66db9cce3c5eaed6d470ac8ed49d7bcbeef6ee5f0bc288db5ff9a70cbd003e5909065233 + checksum: 10c0/a497ff5433854e8577f0427983ea39b9113b49a8120f94515291d763327061d2c3013e60e24ea436d091dafae01a0f6eb1867e3b1616045d96a31d8b3c646ed4 languageName: node linkType: hard @@ -993,13 +992,6 @@ __metadata: languageName: node linkType: hard -"@protobufjs/inquire@npm:^1.1.0": - version: 1.1.0 - resolution: "@protobufjs/inquire@npm:1.1.0" - checksum: 10c0/64372482efcba1fb4d166a2664a6395fa978b557803857c9c03500e0ac1013eb4b1aacc9ed851dd5fc22f81583670b4f4431bae186f3373fedcfde863ef5921a - languageName: node - linkType: hard - "@protobufjs/path@npm:^1.1.2": version: 1.1.2 resolution: "@protobufjs/path@npm:1.1.2" @@ -1014,10 +1006,10 @@ __metadata: languageName: node linkType: hard -"@protobufjs/utf8@npm:^1.1.0": - version: 1.1.0 - resolution: "@protobufjs/utf8@npm:1.1.0" - checksum: 10c0/a3fe31fe3fa29aa3349e2e04ee13dc170cc6af7c23d92ad49e3eeaf79b9766264544d3da824dba93b7855bd6a2982fb40032ef40693da98a136d835752beb487 +"@protobufjs/utf8@npm:^1.1.1": + version: 1.1.2 + resolution: "@protobufjs/utf8@npm:1.1.2" + checksum: 10c0/975c6e2c0319bd50c17531d186b537a88cb4d3205e3ca9297cd842b631d341da0ee3ff16be8656cd2660756dc753b29c8a6a14c0ad8ed602c1f91ddf22e7b3f3 languageName: node linkType: hard @@ -1525,7 +1517,7 @@ __metadata: languageName: node linkType: hard -"long@npm:^5.0.0": +"long@npm:^5.0.0, long@npm:^5.3.2": version: 5.3.2 resolution: "long@npm:5.3.2" checksum: 10c0/7130fe1cbce2dca06734b35b70d380ca3f70271c7f8852c922a7c62c86c4e35f0c39290565eca7133c625908d40e126ac57c02b1b1a4636b9457d77e1e60b981 @@ -1719,23 +1711,22 @@ __metadata: languageName: node linkType: hard -"protobufjs@npm:^7.5.3": - version: 7.5.4 - resolution: "protobufjs@npm:7.5.4" +"protobufjs@npm:^7.6.6": + version: 7.6.6 + resolution: "protobufjs@npm:7.6.6" dependencies: "@protobufjs/aspromise": "npm:^1.1.2" "@protobufjs/base64": "npm:^1.1.2" - "@protobufjs/codegen": "npm:^2.0.4" - "@protobufjs/eventemitter": "npm:^1.1.0" - "@protobufjs/fetch": "npm:^1.1.0" + "@protobufjs/codegen": "npm:^2.0.5" + "@protobufjs/eventemitter": "npm:^1.1.1" + "@protobufjs/fetch": "npm:^1.1.1" "@protobufjs/float": "npm:^1.0.2" - "@protobufjs/inquire": "npm:^1.1.0" "@protobufjs/path": "npm:^1.1.2" "@protobufjs/pool": "npm:^1.1.0" - "@protobufjs/utf8": "npm:^1.1.0" + "@protobufjs/utf8": "npm:^1.1.1" "@types/node": "npm:>=13.7.0" - long: "npm:^5.0.0" - checksum: 10c0/913b676109ffb3c05d3d31e03a684e569be91f3bba8613da4a683d69d9dba948daa2afd7d2e7944d1aa6c417890c35d9d9a8883c1160affafb0f9670d59ef722 + long: "npm:^5.3.2" + checksum: 10c0/6c0dc6d4a2801825e39417bc116297d5261c0cf28892a5e28adafc13432331c0cb75603bbe50ad6f2715f3b0a9ce2896591ad6b51fdc8eae2d05b9ac2e4a8ec1 languageName: node linkType: hard From 7b490a7b444aae76a67bf583ebdc2ecf85a32fe9 Mon Sep 17 00:00:00 2001 From: Andre Sutherland Date: Fri, 28 Aug 2026 16:35:29 +0100 Subject: [PATCH 3/8] feat(cli): resolve the runtime image to its minor series A project's declared SDK version was turned into an exact image tag, so dev-0.9.0 rather than dev-0.9. That pinned every project to one runtime patch and left no way to ship a rebuilt image for a base image CVE without each project editing a pin. The runtime now tracks the SDK on major and minor and owns its patch component, so resolving to the minor series is what a declared range of the form used here already means. A rebuild reaches projects on the next pull. Prereleases keep their full version, since the release workflow deliberately publishes no minor tag for one. Co-Authored-By: Claude Opus 5 (1M context) --- apps/cli/internal/blueprint/helpers.go | 25 +++++++++++++++++++-- apps/cli/internal/blueprint/helpers_test.go | 22 ++++++++++++++++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/apps/cli/internal/blueprint/helpers.go b/apps/cli/internal/blueprint/helpers.go index 756da6f1..22f3e0a0 100644 --- a/apps/cli/internal/blueprint/helpers.go +++ b/apps/cli/internal/blueprint/helpers.go @@ -122,7 +122,8 @@ func DetectRuntimeFromProject(appDir string) (string, error) { } // ResolveRuntimeImage maps a blueprint runtime identifier to a full Docker image reference. -// The image repo encodes the language and major version; the tag encodes the dev image version. +// The image repo encodes the language and major version; the tag encodes the dev image +// minor series, so a project picks up runtime patch releases without editing a pin. func ResolveRuntimeImage(runtime string, imageVersion string) (string, error) { repo, ok := runtimeImageRepos[runtime] if !ok { @@ -135,7 +136,27 @@ func ResolveRuntimeImage(runtime string, imageVersion string) (string, error) { runtime, strings.Join(supported, ", "), ) } - return repo + ":dev-" + imageVersion, nil + return repo + ":dev-" + runtimeImageTagVersion(imageVersion), nil +} + +// The runtime image tracks the SDK on major.minor and owns the patch component +// itself, so that a rebuild for a base image fix reaches projects that declared a +// range like ^0.9.0. Resolving to the minor series is what a range of that form +// already means, so the patch is dropped from the tag. +// +// Prereleases keep the full version as the release workflow deliberately publishes +// no minor tag for one, since a prerelease is not what a range resolves to. +func runtimeImageTagVersion(imageVersion string) string { + if strings.ContainsAny(imageVersion, "-+") { + return imageVersion + } + + parts := strings.Split(imageVersion, ".") + if len(parts) < 3 { + return imageVersion + } + + return parts[0] + "." + parts[1] } // CollectHandlerInfo extracts handler metadata from the blueprint diff --git a/apps/cli/internal/blueprint/helpers_test.go b/apps/cli/internal/blueprint/helpers_test.go index 5c1421ac..382e6eba 100644 --- a/apps/cli/internal/blueprint/helpers_test.go +++ b/apps/cli/internal/blueprint/helpers_test.go @@ -148,13 +148,31 @@ resources: func (s *HelpersTestSuite) Test_ResolveRuntimeImage_nodejs22() { image, err := ResolveRuntimeImage("nodejs24.x", "0.3.0") s.Require().NoError(err) - s.Assert().Equal("ghcr.io/newstack-cloud/celerity-runtime-nodejs-24:dev-0.3.0", image) + s.Assert().Equal("ghcr.io/newstack-cloud/celerity-runtime-nodejs-24:dev-0.3", image) } func (s *HelpersTestSuite) Test_ResolveRuntimeImage_python313() { image, err := ResolveRuntimeImage("python3.13", "0.1.0") s.Require().NoError(err) - s.Assert().Equal("ghcr.io/newstack-cloud/celerity-runtime-python-3-13:dev-0.1.0", image) + s.Assert().Equal("ghcr.io/newstack-cloud/celerity-runtime-python-3-13:dev-0.1", image) +} + +func (s *HelpersTestSuite) Test_ResolveRuntimeImage_drops_the_sdk_patch_component() { + image, err := ResolveRuntimeImage("nodejs24.x", "0.9.5") + s.Require().NoError(err) + s.Assert().Equal("ghcr.io/newstack-cloud/celerity-runtime-nodejs-24:dev-0.9", image) +} + +func (s *HelpersTestSuite) Test_ResolveRuntimeImage_keeps_the_full_version_for_a_prerelease() { + image, err := ResolveRuntimeImage("nodejs24.x", "0.10.0-rc.1") + s.Require().NoError(err) + s.Assert().Equal("ghcr.io/newstack-cloud/celerity-runtime-nodejs-24:dev-0.10.0-rc.1", image) +} + +func (s *HelpersTestSuite) Test_ResolveRuntimeImage_keeps_a_version_without_a_patch_component() { + image, err := ResolveRuntimeImage("nodejs24.x", "0.9") + s.Require().NoError(err) + s.Assert().Equal("ghcr.io/newstack-cloud/celerity-runtime-nodejs-24:dev-0.9", image) } func (s *HelpersTestSuite) Test_ResolveRuntimeImage_unsupported_runtime() { From 132890df820ae7e33d65ce6b09b4592f308d79b0 Mon Sep 17 00:00:00 2001 From: Andre Sutherland Date: Fri, 28 Aug 2026 16:35:47 +0100 Subject: [PATCH 4/8] docs: record the runtime versioning strategy for image releases Both runtime releasing guides told you to force the runtime onto the SDK's exact version with a Release-As footer. That makes a sequence unreleasable, because a runtime already patched for a base image CVE cannot then be released as the SDK version it has passed. The invariant is now major and minor alignment, with the patch component belonging to the runtime, which is also what lets the CLI resolve a declared range to the image's minor tag. Updating dependencies splits into the two cases, where a new SDK minor still forces the version and a patch or a runtime only fix takes an ordinary commit. Both guides now note that the version numbers no longer read as an exact statement of what SDK the image carries, and point at the build time manifest and the startup log that do say so. Co-Authored-By: Claude Opus 5 (1M context) --- apps/runtime/nodejs/RELEASING.md | 81 +++++++++++++++++++++++++------- apps/runtime/python/RELEASING.md | 80 ++++++++++++++++++++++++------- 2 files changed, 128 insertions(+), 33 deletions(-) diff --git a/apps/runtime/nodejs/RELEASING.md b/apps/runtime/nodejs/RELEASING.md index 8eb47748..5a26a314 100644 --- a/apps/runtime/nodejs/RELEASING.md +++ b/apps/runtime/nodejs/RELEASING.md @@ -2,47 +2,93 @@ ## Version Strategy -The runtime version tracks `@celerity-sdk/*` package versions so the Celerity CLI can map -between SDK and runtime image versions without a lookup table. +The runtime version tracks `@celerity-sdk/*` on **major.minor**, and owns its patch +component. The Celerity CLI resolves a project's declared SDK range to the runtime image's +minor tag, so it maps between the two without a lookup table. -- `@celerity-sdk/runtime` (the NAPI package) is versioned independently — it lives in this +``` +runtime major.minor == SDK major.minor patch belongs to the runtime +``` + +The patch component is held out of the mapping so the runtime can ship a rebuild of its +own, for a base image CVE or a fix in the wrapper, without waiting on an SDK release. A +project declaring `^0.9.0` is asking for any `0.9.x`, which is exactly what the `dev-0.9` +tag resolves to, so it picks the rebuild up without editing a pin. + +The two version numbers are no longer readable as "this image contains exactly that SDK". +Runtime `0.9.2` may carry SDK `0.9.1`. The exact set is recorded in `runtime-manifest.json`, +written at image build time by `generate-manifest.mjs`, and logged at startup by `index.mjs`. + +This rests on the SDK keeping breaking changes out of patch releases. Under `0.x` that is a +convention rather than something semver guarantees, so a breaking `0.9.x` patch would need +a runtime minor bump to keep the two in step. + +- `@celerity-sdk/runtime` (the NAPI package) is versioned independently, it lives in this repo and has its own release-please component (`runtime-sdk-node`). - All other `@celerity-sdk/*` packages (`core`, `config`, `common`, `telemetry`, `types`) are versioned in unison in the [celerity-node-sdk](https://github.com/newstack-cloud/celerity-node-sdk) repo. ## Updating SDK Dependencies -When a new `@celerity-sdk/*` version is released (e.g., `0.4.0`): +### A new SDK minor or major (e.g. `0.9.x` → `0.10.0`) + +The runtime has to land on that exact minor, so the `Release-As` footer forces it: ```bash cd apps/runtime/nodejs # 1. Update SDK dependencies in package.json -# @celerity-sdk/core, /config, /common, /telemetry, /types → ^0.4.0 +# @celerity-sdk/core, /config, /common, /telemetry, /types → ^0.10.0 # @celerity-sdk/runtime stays at its own version # 2. Update lockfile yarn install -# 3. Commit with Release-As footer to force version alignment -git commit -m "deps(runtime-nodejs): update @celerity-sdk/* to 0.4.0 +# 3. Commit with Release-As footer to move the runtime onto the new minor +git commit -m "deps(runtime-nodejs): update @celerity-sdk/* to 0.10.0 -Release-As: 0.4.0" +Release-As: 0.10.0" # 4. Push to main (or open a PR) ``` +### An SDK patch, or a runtime-only fix + +This covers a patch-level SDK release, a base image rebuild for a CVE, and any fix to the +wrapper itself. The runtime's patch number is its own, so there is no version to force: + +```bash +cd apps/runtime/nodejs + +# 1. Update the lockfile (a caret range already admits the new SDK patch) +yarn install + +# 2. Commit with no Release-As footer, letting release-please bump the patch +git commit -m "deps(runtime-nodejs): bump up @celerity-sdk/* 0.9.4" +``` + +Do not add a `Release-As` footer here. Pinning the runtime to the SDK's patch number is what +makes the sequence unreleasable as a runtime already at `0.9.1` from a CVE rebuild cannot then +be released as the SDK's `0.9.1`. + ## Release Flow -1. **release-please** detects the `deps` commit on `main` and creates a release PR that - bumps `package.json` version to `0.4.0` (the `Release-As` footer forces exact version). -2. **Merge** the release PR — release-please creates tag `runtime-nodejs/v0.4.0`. +1. **release-please** detects the commit on `main` and creates a release PR that bumps + `package.json`, to the version named by a `Release-As` footer if there is one and by the + conventional commit bump rules otherwise. +2. **Merge** the release PR — release-please creates tag `runtime-nodejs/v0.10.0`. 3. The `release-please.yml` `post-process-tags` job dispatches `runtime-nodejs-release.yml` with the tag. -4. The release workflow builds and pushes Docker images to GHCR: - - Production: `ghcr.io/newstack-cloud/celerity-runtime-nodejs-24:0.4.0`, `:0.4`, `:latest` - - Dev: `ghcr.io/newstack-cloud/celerity-runtime-nodejs-24:dev-0.4.0`, `:dev-latest` -5. Images are scanned (Trivy), signed (cosign keyless), and attested (SBOM + build provenance). +4. The release workflow builds each architecture, scans it, and only then assembles the + manifest that carries the tags, so an image that fails its scan is never tagged: + - Production: `ghcr.io/newstack-cloud/celerity-runtime-nodejs-24:0.10.0`, `:0.10`, `:latest` + - Dev: `ghcr.io/newstack-cloud/celerity-runtime-nodejs-24:dev-0.10.0`, `:dev-0.10`, `:dev-latest` +5. Images are signed (cosign keyless) and attested (SBOM + build provenance). Signing runs + off the published manifests, which only exist if every scan passed. + +`:dev-0.10` is the tag the CLI resolves to. `:dev-0.10.0` stays available for pinning an +exact runtime patch. A prerelease publishes no minor tag, and the CLI resolves such a +version to its full `dev-` tag instead. ## Image Verification @@ -63,5 +109,6 @@ cosign verify-attestation --type spdxjson \ ## Changelog The `deps` commit type appears under "Dependencies" in the auto-generated changelog -(configured in `release-please-config.json`). The `Release-As` footer ensures the version -number matches the SDK, regardless of conventional commit bump rules. +(configured in `release-please-config.json`). On the commit that moves the runtime onto a +new SDK minor, the `Release-As` footer overrides the conventional commit bump rules so the +runtime lands on that minor exactly. diff --git a/apps/runtime/python/RELEASING.md b/apps/runtime/python/RELEASING.md index 3f995622..1a125750 100644 --- a/apps/runtime/python/RELEASING.md +++ b/apps/runtime/python/RELEASING.md @@ -2,8 +2,27 @@ ## Version Strategy -The runtime version tracks `celerity-sdk` package versions so the Celerity CLI can map -between SDK and runtime image versions without a lookup table. +The runtime version tracks `celerity-sdk` on **major.minor**, and owns its patch component. +The Celerity CLI resolves the SDK version a project declares to the runtime image's minor +tag, so it maps between the two without a lookup table. + +``` +runtime major.minor == SDK major.minor patch belongs to the runtime +``` + +The patch component is held out of the mapping so the runtime can ship a rebuild of its +own, for a base image CVE or a fix in the wrapper, without waiting on an SDK release. A +project declaring `celerity-sdk[runtime]>=0.3.0` resolves to the `dev-0.3` tag, which +carries the newest runtime patch on that minor, so it picks the rebuild up without editing +a pin. + +The two version numbers are no longer readable as "this image contains exactly that SDK". +Runtime `0.3.2` may carry SDK `0.3.1`. The exact set is recorded in `runtime-manifest.json`, +written at image build time by `generate_manifest.py`, and logged at startup by `main.py`. + +This rests on the SDK keeping breaking changes out of patch releases. Under `0.x` that is a +convention rather than something semver guarantees, so a breaking `0.3.x` patch would need +a runtime minor bump to keep the two in step. - `celerity-runtime-sdk` (the PyO3 package) is versioned independently — it lives in the `libs/runtime/sdk/python` directory of this repo and has its own release-please component @@ -13,33 +32,61 @@ between SDK and runtime image versions without a lookup table. ## Updating SDK Dependencies -When a new `celerity-sdk` version is released (e.g., `0.3.0`): +### A new SDK minor or major (e.g. `0.3.x` → `0.4.0`) + +The runtime has to land on that exact minor, so the `Release-As` footer forces it: ```bash cd apps/runtime/python # 1. Update celerity-sdk dependency in pyproject.toml -# celerity-sdk[runtime] → >=0.3.0 +# celerity-sdk[runtime] → >=0.4.0 -# 2. Commit with Release-As footer to force version alignment. -git commit -m "deps(runtime-python): update celerity-sdk to 0.3.0 +# 2. Commit with Release-As footer to move the runtime onto the new minor +git commit -m "deps(runtime-python): update celerity-sdk to 0.4.0 -Release-As: 0.3.0" +Release-As: 0.4.0" # 3. Push to main (or open a PR) ``` +### An SDK patch, or a runtime-only fix + +This covers a patch-level SDK release, a base image rebuild for a CVE, and any fix to the +wrapper itself. The runtime's patch number is its own, so there is no version to force: + +```bash +cd apps/runtime/python + +# 1. Refresh the lock file (the declared floor already admits the new SDK patch) +uv lock --upgrade-package celerity-sdk + +# 2. Commit with no Release-As footer, letting release-please bump the patch +git commit -m "deps(runtime-python): bump up celerity-sdk 0.3.4" +``` + +Do not add a `Release-As` footer here. Pinning the runtime to the SDK's patch number is what +makes the sequence unreleasable: a runtime already at `0.3.1` from a CVE rebuild cannot then +be released as the SDK's `0.3.1`. + ## Release Flow -1. **release-please** detects the `deps` commit on `main` and creates a release PR that - bumps the version to `0.3.0` (the `Release-As` footer forces exact version). -2. **Merge** the release PR — release-please creates tag `runtime-python/v0.3.0`. +1. **release-please** detects the commit on `main` and creates a release PR that bumps the + version, to the version named by a `Release-As` footer if there is one and by the + conventional commit bump rules otherwise. +2. **Merge** the release PR — release-please creates tag `runtime-python/v0.4.0`. 3. The `release-please.yml` `post-process-tags` job dispatches `app-runtime-python-release.yml` with the tag. -4. The release workflow builds and pushes Docker images to GHCR: - - Production: `ghcr.io/newstack-cloud/celerity-runtime-python-3-13:0.3.0`, `:0.3`, `:latest` - - Dev: `ghcr.io/newstack-cloud/celerity-runtime-python-3-13:dev-0.3.0`, `:dev-latest` -5. Images are scanned (Trivy), signed (cosign keyless), and attested (SBOM + build provenance). +4. The release workflow builds each architecture, scans it, and only then assembles the + manifest that carries the tags, so an image that fails its scan is never tagged: + - Production: `ghcr.io/newstack-cloud/celerity-runtime-python-3-13:0.4.0`, `:0.4`, `:latest` + - Dev: `ghcr.io/newstack-cloud/celerity-runtime-python-3-13:dev-0.4.0`, `:dev-0.4`, `:dev-latest` +5. Images are signed (cosign keyless) and attested (SBOM + build provenance). Signing runs + off the published manifests, which only exist if every scan passed. + +`:dev-0.4` is the tag the CLI resolves to. `:dev-0.4.0` stays available for pinning an +exact runtime patch. A prerelease publishes no minor tag, and the CLI resolves such a +version to its full `dev-` tag instead. ## Image Verification @@ -60,5 +107,6 @@ cosign verify-attestation --type spdxjson \ ## Changelog The `deps` commit type appears under "Dependencies" in the auto-generated changelog -(configured in `release-please-config.json`). The `Release-As` footer ensures the version -number matches the SDK, regardless of conventional commit bump rules. +(configured in `release-please-config.json`). On the commit that moves the runtime onto a +new SDK minor, the `Release-As` footer overrides the conventional commit bump rules so the +runtime lands on that minor exactly. From 85b1916a0959133fd614818186a38b44814d390a Mon Sep 17 00:00:00 2001 From: Andre Sutherland Date: Fri, 28 Aug 2026 16:42:45 +0100 Subject: [PATCH 5/8] ci: build every container release from one reusable workflow The five container releases had drifted into five copies of the same pipeline, and the copies were the problem. The local events release had picked up the Node.js runtime's build cache scope and code scanning category, so the two were quietly clobbering each other, which is the failure that copying invites. They now call a single reusable workflow. What differs between them is data, so each caller passes its image, context, cache scope, scanning category and the set of images to publish, and holds nothing else. The set is JSON, which is what lets one template serve both the runtimes that publish a production and a dev image and the sidecars that publish one. Assembling the manifest and signing it are now a single job. A matrix job's outputs are overwritten by whichever leg finishes last, so a separate signing job could not read a per target digest, and keeping them together states the guarantee more directly, in that signing cannot run for a target whose manifest was never assembled. The tags are written out rather than derived from the semver tag type, so the rule that a prerelease moves neither the minor tag nor latest is stated where it can be read. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/app-dev-auth-release.yml | 251 +------------ .../workflows/app-local-events-release.yml | 251 +------------ .../workflows/app-runtime-core-release.yml | 348 ++---------------- .../workflows/app-runtime-nodejs-release.yml | 341 ++--------------- .../workflows/app-runtime-python-release.yml | 341 ++--------------- .github/workflows/container-release.yml | 305 +++++++++++++++ 6 files changed, 431 insertions(+), 1406 deletions(-) create mode 100644 .github/workflows/container-release.yml diff --git a/.github/workflows/app-dev-auth-release.yml b/.github/workflows/app-dev-auth-release.yml index e012f0dc..e9b39024 100644 --- a/.github/workflows/app-dev-auth-release.yml +++ b/.github/workflows/app-dev-auth-release.yml @@ -11,241 +11,30 @@ on: permissions: contents: read -env: - REGISTRY: ghcr.io - IMAGE_NAME: newstack-cloud/celerity-dev-auth - jobs: - prepare: - name: Prepare Release - runs-on: ubuntu-latest - outputs: - version: ${{ steps.version.outputs.version }} - steps: - - name: Extract version from tag - id: version - env: - TAG: ${{ inputs.tag }} - run: | - if [[ ! "$TAG" =~ ^dev-auth/v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then - echo "::error::Expected a tag of the form dev-auth/v1.2.3, got '$TAG'" - exit 1 - fi - VERSION="${TAG##*/}" - VERSION="${VERSION#v}" - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - echo "Extracted version: $VERSION from tag: $TAG" - - build: - name: Build on ${{ matrix.platform.arch }} - runs-on: ${{ matrix.platform.runner }} - needs: prepare + release: permissions: contents: read packages: write security-events: write - strategy: - fail-fast: false - matrix: - # Each architecture is built on a runner of its own architecture rather - # than one runner emulating the other. - platform: - - arch: amd64 - os: linux/amd64 - runner: ubuntu-latest - - arch: arm64 - os: linux/arm64 - runner: ubuntu-24.04-arm - steps: - - uses: actions/checkout@v4 - - - uses: docker/login-action@v3 - with: - registry: dhi.io - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - labels: | - org.opencontainers.image.title=Celerity Dev Auth - org.opencontainers.image.description=Lightweight OIDC provider for local development and testing of Celerity applications - - # Needed for the container driver. The docker driver that a runner has by - # default cannot export an image by digest, which is how each - # architecture is pushed before there is a manifest to tag. - - uses: docker/setup-buildx-action@v3 - - # Pushed without a tag, since a tag naming two architectures can only be - # applied once both exist. The manifest that carries the tags is assembled - # from these digests once every architecture has been built. - - id: build - uses: docker/build-push-action@v6 - with: - context: apps/dev-auth - target: production - platforms: ${{ matrix.platform.os }} - labels: ${{ steps.meta.outputs.labels }} - # Without this buildx attaches a provenance attestation, which makes - # what is pushed an index holding the image and the attestation rather - # than the image itself. Scanning that index means resolving a - # platform inside it, and the manifest list assembled below is where - # multiple platforms belong anyway. The release still gets provenance, - # from the attestation step that runs against the published manifest. - provenance: false - outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true - cache-from: type=gha,scope=dev-auth-${{ matrix.platform.arch }} - cache-to: type=gha,mode=max,scope=dev-auth-${{ matrix.platform.arch }} - - # Scanned here, before the manifest that carries the tags is assembled, - # so an image with a critical vulnerability is never tagged. Scanning - # after publication would leave the tags live and only skip the signing, - # which is a worse outcome than a failed release. - - name: Scan the image - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - # Blocks on anything with a fix available, so the gate only ever - # asks for an upgrade that exists. Findings with no released fix are - # still reported below, so they are recorded rather than dismissed. - ignore-unfixed: true - exit-code: "1" - - - name: Scan the image (SARIF) - if: "!cancelled() && steps.build.outputs.digest != ''" - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" - format: "sarif" - output: "trivy.sarif" - severity: "CRITICAL,HIGH" - exit-code: "0" - - - name: Upload the scan results - uses: github/codeql-action/upload-sarif@v4 - if: "!cancelled() && hashFiles('trivy.sarif') != ''" - with: - sarif_file: "trivy.sarif" - category: "container-dev-auth-${{ matrix.platform.arch }}" - - - name: Export the digest - env: - DIGEST: ${{ steps.build.outputs.digest }} - run: | - mkdir -p /tmp/digests - touch "/tmp/digests/${DIGEST#sha256:}" - - - uses: actions/upload-artifact@v4 - with: - name: digests-${{ matrix.platform.arch }} - path: /tmp/digests/* - if-no-files-found: error - retention-days: 1 - - merge: - name: Publish Manifest - runs-on: ubuntu-latest - needs: [prepare, build] - permissions: - contents: read - packages: write - outputs: - digest: ${{ steps.manifest.outputs.digest }} - steps: - - uses: actions/download-artifact@v4 - with: - path: /tmp/digests - pattern: digests-* - merge-multiple: true - - - uses: docker/setup-buildx-action@v3 - - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=semver,pattern={{version}},value=${{ needs.prepare.outputs.version }} - type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }} - type=raw,value=latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - - - name: Create the manifest list - working-directory: /tmp/digests - run: | - docker buildx imagetools create \ - $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) - - - name: Read the manifest digest - id: manifest - env: - VERSION: ${{ needs.prepare.outputs.version }} - run: | - digest=$(docker buildx imagetools inspect \ - "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}" \ - --format '{{json .Manifest}}' | jq -r .digest) - echo "digest=$digest" >> "$GITHUB_OUTPUT" - - sign-and-attest: - name: Sign & Attest Images - runs-on: ubuntu-latest - needs: [merge] - # Nothing reaches a manifest unless its scan passed, so getting this far - # already means every image being signed is one that cleared the scan. - if: needs.merge.result == 'success' - permissions: - contents: read - packages: write id-token: write attestations: write - env: - # Store signatures and attestations as OCI 1.1 referrers instead of - # tag-based artifacts (.sig/.att/.sbom tags) that pollute the GHCR UI. - COSIGN_REGISTRY_REFERRERS_MODE: oci-1-1 - steps: - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: sigstore/cosign-installer@v3 - - uses: anchore/sbom-action/download-syft@v0 - - - name: Sign production image (cosign keyless) - run: | - cosign sign --yes \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge.outputs.digest }} - - - name: Generate production SBOM - run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge.outputs.digest }} \ - -o spdx-json=dev-auth-sbom.spdx.json - - - name: Attest production SBOM - run: | - cosign attest --yes --predicate dev-auth-sbom.spdx.json --type spdxjson \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge.outputs.digest }} - - - name: GitHub attestation (production) - uses: actions/attest-build-provenance@v3 - with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.merge.outputs.digest }} - push-to-registry: true + uses: ./.github/workflows/container-release.yml + secrets: inherit + with: + tag: ${{ inputs.tag }} + tag-component: dev-auth + image-name: newstack-cloud/celerity-dev-auth + context: apps/dev-auth + cache-scope: dev-auth + sarif-category: container-dev-auth + targets: >- + [ + { + "name": "production", + "tagPrefix": "", + "block": true, + "title": "Celerity Dev Auth", + "description": "Lightweight OIDC provider for local development and testing of Celerity applications" + } + ] diff --git a/.github/workflows/app-local-events-release.yml b/.github/workflows/app-local-events-release.yml index f8f7e0bd..51bd2880 100644 --- a/.github/workflows/app-local-events-release.yml +++ b/.github/workflows/app-local-events-release.yml @@ -11,241 +11,30 @@ on: permissions: contents: read -env: - REGISTRY: ghcr.io - IMAGE_NAME: newstack-cloud/celerity-local-events - jobs: - prepare: - name: Prepare Release - runs-on: ubuntu-latest - outputs: - version: ${{ steps.version.outputs.version }} - steps: - - name: Extract version from tag - id: version - env: - TAG: ${{ inputs.tag }} - run: | - if [[ ! "$TAG" =~ ^local-events/v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then - echo "::error::Expected a tag of the form local-events/v1.2.3, got '$TAG'" - exit 1 - fi - VERSION="${TAG##*/}" - VERSION="${VERSION#v}" - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - echo "Extracted version: $VERSION from tag: $TAG" - - build: - name: Build on ${{ matrix.platform.arch }} - runs-on: ${{ matrix.platform.runner }} - needs: prepare + release: permissions: contents: read packages: write security-events: write - strategy: - fail-fast: false - matrix: - # Each architecture is built on a runner of its own architecture rather - # than one runner emulating the other. - platform: - - arch: amd64 - os: linux/amd64 - runner: ubuntu-latest - - arch: arm64 - os: linux/arm64 - runner: ubuntu-24.04-arm - steps: - - uses: actions/checkout@v4 - - - uses: docker/login-action@v3 - with: - registry: dhi.io - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - labels: | - org.opencontainers.image.title=Celerity Local Events Sidecar - org.opencontainers.image.description=Celerity Local Events Sidecar for local development and testing of Celerity applications - - # Needed for the container driver. The docker driver that a runner has by - # default cannot export an image by digest, which is how each - # architecture is pushed before there is a manifest to tag. - - uses: docker/setup-buildx-action@v3 - - # Pushed without a tag, since a tag naming two architectures can only be - # applied once both exist. The manifest that carries the tags is assembled - # from these digests once every architecture has been built. - - id: build - uses: docker/build-push-action@v6 - with: - context: apps/local-events - target: production - platforms: ${{ matrix.platform.os }} - labels: ${{ steps.meta.outputs.labels }} - # Without this buildx attaches a provenance attestation, which makes - # what is pushed an index holding the image and the attestation rather - # than the image itself. Scanning that index means resolving a - # platform inside it, and the manifest list assembled below is where - # multiple platforms belong anyway. The release still gets provenance, - # from the attestation step that runs against the published manifest. - provenance: false - outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true - cache-from: type=gha,scope=local-events-${{ matrix.platform.arch }} - cache-to: type=gha,mode=max,scope=local-events-${{ matrix.platform.arch }} - - # Scanned here, before the manifest that carries the tags is assembled, - # so an image with a critical vulnerability is never tagged. Scanning - # after publication would leave the tags live and only skip the signing, - # which is a worse outcome than a failed release. - - name: Scan the image - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - # Blocks on anything with a fix available, so the gate only ever - # asks for an upgrade that exists. Findings with no released fix are - # still reported below, so they are recorded rather than dismissed. - ignore-unfixed: true - exit-code: "1" - - - name: Scan the image (SARIF) - if: "!cancelled() && steps.build.outputs.digest != ''" - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" - format: "sarif" - output: "trivy.sarif" - severity: "CRITICAL,HIGH" - exit-code: "0" - - - name: Upload the scan results - uses: github/codeql-action/upload-sarif@v4 - if: "!cancelled() && hashFiles('trivy.sarif') != ''" - with: - sarif_file: "trivy.sarif" - category: "container-local-events-${{ matrix.platform.arch }}" - - - name: Export the digest - env: - DIGEST: ${{ steps.build.outputs.digest }} - run: | - mkdir -p /tmp/digests - touch "/tmp/digests/${DIGEST#sha256:}" - - - uses: actions/upload-artifact@v4 - with: - name: digests-${{ matrix.platform.arch }} - path: /tmp/digests/* - if-no-files-found: error - retention-days: 1 - - merge: - name: Publish Manifest - runs-on: ubuntu-latest - needs: [prepare, build] - permissions: - contents: read - packages: write - outputs: - digest: ${{ steps.manifest.outputs.digest }} - steps: - - uses: actions/download-artifact@v4 - with: - path: /tmp/digests - pattern: digests-* - merge-multiple: true - - - uses: docker/setup-buildx-action@v3 - - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=semver,pattern={{version}},value=${{ needs.prepare.outputs.version }} - type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }} - type=raw,value=latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - - - name: Create the manifest list - working-directory: /tmp/digests - run: | - docker buildx imagetools create \ - $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) - - - name: Read the manifest digest - id: manifest - env: - VERSION: ${{ needs.prepare.outputs.version }} - run: | - digest=$(docker buildx imagetools inspect \ - "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}" \ - --format '{{json .Manifest}}' | jq -r .digest) - echo "digest=$digest" >> "$GITHUB_OUTPUT" - - sign-and-attest: - name: Sign & Attest Images - runs-on: ubuntu-latest - needs: [merge] - # Nothing reaches a manifest unless its scan passed, so getting this far - # already means every image being signed is one that cleared the scan. - if: needs.merge.result == 'success' - permissions: - contents: read - packages: write id-token: write attestations: write - env: - # Store signatures and attestations as OCI 1.1 referrers instead of - # tag-based artifacts (.sig/.att/.sbom tags) that pollute the GHCR UI. - COSIGN_REGISTRY_REFERRERS_MODE: oci-1-1 - steps: - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: sigstore/cosign-installer@v3 - - uses: anchore/sbom-action/download-syft@v0 - - - name: Sign production image (cosign keyless) - run: | - cosign sign --yes \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge.outputs.digest }} - - - name: Generate production SBOM - run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge.outputs.digest }} \ - -o spdx-json=local-events-sbom.spdx.json - - - name: Attest production SBOM - run: | - cosign attest --yes --predicate local-events-sbom.spdx.json --type spdxjson \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge.outputs.digest }} - - - name: GitHub attestation (production) - uses: actions/attest-build-provenance@v3 - with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.merge.outputs.digest }} - push-to-registry: true + uses: ./.github/workflows/container-release.yml + secrets: inherit + with: + tag: ${{ inputs.tag }} + tag-component: local-events + image-name: newstack-cloud/celerity-local-events + context: apps/local-events + cache-scope: local-events + sarif-category: container-local-events + targets: >- + [ + { + "name": "production", + "tagPrefix": "", + "block": true, + "title": "Celerity Local Events Sidecar", + "description": "Celerity Local Events Sidecar for local development and testing of Celerity applications" + } + ] diff --git a/.github/workflows/app-runtime-core-release.yml b/.github/workflows/app-runtime-core-release.yml index a87fa6c2..638c989f 100644 --- a/.github/workflows/app-runtime-core-release.yml +++ b/.github/workflows/app-runtime-core-release.yml @@ -11,328 +11,40 @@ on: permissions: contents: read -env: - REGISTRY: ghcr.io - IMAGE_NAME: newstack-cloud/celerity-runtime-core - jobs: - prepare: - name: Prepare Release - runs-on: ubuntu-latest - outputs: - version: ${{ steps.version.outputs.version }} - steps: - - name: Extract version from tag - id: version - env: - TAG: ${{ inputs.tag }} - run: | - if [[ ! "$TAG" =~ ^runtime-core-app/v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then - echo "::error::Expected a tag of the form runtime-core-app/v1.2.3, got '$TAG'" - exit 1 - fi - VERSION="${TAG##*/}" - VERSION="${VERSION#v}" - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - echo "Extracted version: $VERSION from tag: $TAG" - - build: - name: Build ${{ matrix.target }} on ${{ matrix.platform.arch }} - runs-on: ${{ matrix.platform.runner }} - needs: prepare + release: permissions: contents: read packages: write security-events: write - strategy: - fail-fast: false - matrix: - target: [runtime, dev] - # Each architecture is built on a runner of its own architecture. The - # other runtime images copy interpreted code and build the same either - # way, but this one compiles the runtime from source, and doing that for - # arm64 under emulation takes hours where a native runner takes minutes. - platform: - - arch: amd64 - os: linux/amd64 - runner: ubuntu-latest - - arch: arm64 - os: linux/arm64 - runner: ubuntu-24.04-arm - steps: - - uses: actions/checkout@v4 - - - uses: docker/login-action@v3 - with: - registry: dhi.io - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - labels: | - org.opencontainers.image.title=Celerity Core Runtime - org.opencontainers.image.description=Runtime for Celerity applications with ahead-of-time compiled handlers - - # Needed for the container driver. The docker driver that a runner has by - # default cannot export an image by digest, which is how each - # architecture is pushed before there is a manifest to tag. - - uses: docker/setup-buildx-action@v3 - - # Pushed without a tag, since a tag naming two architectures can only be - # applied once both exist. The manifest that carries the tags is assembled - # from these digests once every architecture has been built. - - id: build - uses: docker/build-push-action@v6 - with: - context: . - file: apps/runtime/core/Dockerfile - target: ${{ matrix.target }} - platforms: ${{ matrix.platform.os }} - labels: ${{ steps.meta.outputs.labels }} - # Without this buildx attaches a provenance attestation, which makes - # what is pushed an index holding the image and the attestation rather - # than the image itself. Scanning that index means resolving a - # platform inside it, which is what failed here, and the manifest list - # assembled below is where multiple platforms belong anyway. The - # release still gets provenance, from the attestation step that runs - # against the published manifest. - provenance: false - outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true - cache-from: type=gha,scope=runtime-core-${{ matrix.target }}-${{ matrix.platform.arch }} - cache-to: type=gha,mode=max,scope=runtime-core-${{ matrix.target }}-${{ matrix.platform.arch }} - - # Scanned here, before the manifest that carries the tags is assembled, - # so an image with a critical vulnerability is never tagged. Scanning - # after publication would leave the tags live and only skip the signing, - # which is a worse outcome than a failed release. - - name: Scan the image - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - # Blocks on anything with a fix available. The base image currently - # carries findings in gzip, ncurses and openssl that Debian has not - # released a fix for, and failing on those would only mean never - # releasing, since there is nothing to update to. They are still - # reported below, so they are recorded rather than dismissed, and the - # way to be rid of them is a base image without those packages. - ignore-unfixed: true - # The production image has to be clean. The dev image carries a shell - # and the tools to debug with, and is reported on rather than blocked. - exit-code: ${{ matrix.target == 'runtime' && '1' || '0' }} - - - name: Scan the image (SARIF) - if: "!cancelled() && steps.build.outputs.digest != ''" - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" - format: "sarif" - output: "trivy.sarif" - severity: "CRITICAL,HIGH" - exit-code: "0" - - - name: Upload the scan results - uses: github/codeql-action/upload-sarif@v4 - if: "!cancelled() && hashFiles('trivy.sarif') != ''" - with: - sarif_file: "trivy.sarif" - category: "container-core-${{ matrix.target }}-${{ matrix.platform.arch }}" - - - name: Export the digest - env: - DIGEST: ${{ steps.build.outputs.digest }} - run: | - mkdir -p /tmp/digests - touch "/tmp/digests/${DIGEST#sha256:}" - - - uses: actions/upload-artifact@v4 - with: - name: digests-${{ matrix.target }}-${{ matrix.platform.arch }} - path: /tmp/digests/* - if-no-files-found: error - retention-days: 1 - - merge-runtime: - name: Publish Production Manifest - runs-on: ubuntu-latest - needs: [prepare, build] - permissions: - contents: read - packages: write - outputs: - digest: ${{ steps.manifest.outputs.digest }} - steps: - - uses: actions/download-artifact@v4 - with: - path: /tmp/digests - pattern: digests-runtime-* - merge-multiple: true - - - uses: docker/setup-buildx-action@v3 - - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=semver,pattern={{version}},value=${{ needs.prepare.outputs.version }} - type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }} - type=raw,value=latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - - - name: Create the manifest list - working-directory: /tmp/digests - run: | - docker buildx imagetools create \ - $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) - - - name: Read the manifest digest - id: manifest - env: - VERSION: ${{ needs.prepare.outputs.version }} - run: | - digest=$(docker buildx imagetools inspect \ - "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}" \ - --format '{{json .Manifest}}' | jq -r .digest) - echo "digest=$digest" >> "$GITHUB_OUTPUT" - - merge-dev: - name: Publish Dev Manifest - runs-on: ubuntu-latest - needs: [prepare, build] - permissions: - contents: read - packages: write - outputs: - digest: ${{ steps.manifest.outputs.digest }} - steps: - - uses: actions/download-artifact@v4 - with: - path: /tmp/digests - pattern: digests-dev-* - merge-multiple: true - - - uses: docker/setup-buildx-action@v3 - - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # The minor tag is what the CLI resolves a project's declared SDK - # range to, so a runtime-only patch reaches projects without every - # one of them editing a pin. - tags: | - type=raw,value=dev-${{ needs.prepare.outputs.version }} - type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }},prefix=dev- - type=raw,value=dev-latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - - - name: Create the manifest list - working-directory: /tmp/digests - run: | - docker buildx imagetools create \ - $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) - - - name: Read the manifest digest - id: manifest - env: - VERSION: ${{ needs.prepare.outputs.version }} - run: | - digest=$(docker buildx imagetools inspect \ - "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev-${VERSION}" \ - --format '{{json .Manifest}}' | jq -r .digest) - echo "digest=$digest" >> "$GITHUB_OUTPUT" - - sign-and-attest: - name: Sign & Attest Images - runs-on: ubuntu-latest - needs: [merge-runtime, merge-dev] - # Nothing reaches a manifest unless its scan passed, so getting this far - # already means every image being signed is one that cleared the scan. - if: needs.merge-runtime.result == 'success' && needs.merge-dev.result == 'success' - permissions: - contents: read - packages: write id-token: write attestations: write - env: - # Store signatures and attestations as OCI 1.1 referrers instead of - # tag-based artifacts (.sig/.att/.sbom tags) that pollute the GHCR UI. - COSIGN_REGISTRY_REFERRERS_MODE: oci-1-1 - steps: - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: sigstore/cosign-installer@v3 - - uses: anchore/sbom-action/download-syft@v0 - - # --- Production image --- - - name: Sign production image (cosign keyless) - run: | - cosign sign --yes \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} - - - name: Generate production SBOM - run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} \ - -o spdx-json=runtime-sbom.spdx.json - - - name: Attest production SBOM - run: | - cosign attest --yes --predicate runtime-sbom.spdx.json --type spdxjson \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} - - - name: GitHub attestation (production) - uses: actions/attest-build-provenance@v3 - with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.merge-runtime.outputs.digest }} - push-to-registry: true - - # --- Dev image --- - - name: Sign dev image (cosign keyless) - run: | - cosign sign --yes \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} - - - name: Generate dev SBOM - run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} \ - -o spdx-json=dev-sbom.spdx.json - - - name: Attest dev SBOM - run: | - cosign attest --yes --predicate dev-sbom.spdx.json --type spdxjson \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} - - - name: GitHub attestation (dev) - uses: actions/attest-build-provenance@v3 - with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.merge-dev.outputs.digest }} - push-to-registry: true + uses: ./.github/workflows/container-release.yml + secrets: inherit + with: + tag: ${{ inputs.tag }} + tag-component: runtime-core-app + image-name: newstack-cloud/celerity-runtime-core + # Built from the repository root, since the runtime is compiled from + # sources that sit outside the app directory. + context: . + dockerfile: apps/runtime/core/Dockerfile + cache-scope: runtime-core + sarif-category: container-core + targets: >- + [ + { + "name": "runtime", + "tagPrefix": "", + "block": true, + "title": "Celerity Core Runtime", + "description": "Runtime for Celerity applications with ahead-of-time compiled handlers" + }, + { + "name": "dev", + "tagPrefix": "dev-", + "block": false, + "title": "Celerity Core Runtime (Dev)", + "description": "Development runtime for Celerity applications with ahead-of-time compiled handlers" + } + ] diff --git a/.github/workflows/app-runtime-nodejs-release.yml b/.github/workflows/app-runtime-nodejs-release.yml index 4dd1e30c..0fcbac45 100644 --- a/.github/workflows/app-runtime-nodejs-release.yml +++ b/.github/workflows/app-runtime-nodejs-release.yml @@ -4,329 +4,44 @@ on: workflow_dispatch: inputs: tag: - description: 'Release tag (e.g. runtime-nodejs/v0.3.0)' + description: 'Release tag (e.g. runtime-nodejs/v0.9.0)' required: true type: string permissions: contents: read -env: - REGISTRY: ghcr.io - IMAGE_NAME: newstack-cloud/celerity-runtime-nodejs-24 - jobs: - prepare: - name: Prepare Release - runs-on: ubuntu-latest - outputs: - version: ${{ steps.version.outputs.version }} - steps: - - name: Extract version from tag - id: version - env: - TAG: ${{ inputs.tag }} - run: | - if [[ ! "$TAG" =~ ^runtime-nodejs/v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then - echo "::error::Expected a tag of the form runtime-nodejs/v1.2.3, got '$TAG'" - exit 1 - fi - VERSION="${TAG##*/}" - VERSION="${VERSION#v}" - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - echo "Extracted version: $VERSION from tag: $TAG" - - build: - name: Build ${{ matrix.target }} on ${{ matrix.platform.arch }} - runs-on: ${{ matrix.platform.runner }} - needs: prepare + release: permissions: contents: read packages: write security-events: write - strategy: - fail-fast: false - matrix: - target: [runtime, dev] - # Each architecture is built on a runner of its own architecture rather - # than one runner emulating the other, which keeps the arm64 yarn - # install off QEMU. - platform: - - arch: amd64 - os: linux/amd64 - runner: ubuntu-latest - - arch: arm64 - os: linux/arm64 - runner: ubuntu-24.04-arm - steps: - - uses: actions/checkout@v4 - - - uses: docker/login-action@v3 - with: - registry: dhi.io - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - labels: | - org.opencontainers.image.title=Celerity Node.js Runtime${{ matrix.target == 'dev' && ' (Dev)' || '' }} - org.opencontainers.image.description=${{ matrix.target == 'dev' && 'Development runtime for Celerity Node.js applications (includes SWC, pino-pretty)' || 'Production runtime for Celerity Node.js applications' }} - - # Needed for the container driver. The docker driver that a runner has by - # default cannot export an image by digest, which is how each - # architecture is pushed before there is a manifest to tag. - - uses: docker/setup-buildx-action@v3 - - # Pushed without a tag, since a tag naming two architectures can only be - # applied once both exist. The manifest that carries the tags is assembled - # from these digests once every architecture has been built. - - id: build - uses: docker/build-push-action@v6 - with: - context: apps/runtime/nodejs - target: ${{ matrix.target }} - platforms: ${{ matrix.platform.os }} - labels: ${{ steps.meta.outputs.labels }} - # Without this buildx attaches a provenance attestation, which makes - # what is pushed an index holding the image and the attestation rather - # than the image itself. Scanning that index means resolving a - # platform inside it, and the manifest list assembled below is where - # multiple platforms belong anyway. The release still gets provenance, - # from the attestation step that runs against the published manifest. - provenance: false - outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true - cache-from: type=gha,scope=runtime-nodejs-${{ matrix.target }}-${{ matrix.platform.arch }} - cache-to: type=gha,mode=max,scope=runtime-nodejs-${{ matrix.target }}-${{ matrix.platform.arch }} - - # Scanned here, before the manifest that carries the tags is assembled, - # so an image with a critical vulnerability is never tagged. Scanning - # after publication would leave the tags live and only skip the signing, - # which is a worse outcome than a failed release. - - name: Scan the image - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - # Blocks on anything with a fix available, so the gate only ever - # asks for an upgrade that exists. Findings with no released fix are - # still reported below, so they are recorded rather than dismissed. - ignore-unfixed: true - # The production image has to be clean. The dev image carries a shell - # and the tools to debug with, and is reported on rather than blocked. - exit-code: ${{ matrix.target == 'runtime' && '1' || '0' }} - - - name: Scan the image (SARIF) - if: "!cancelled() && steps.build.outputs.digest != ''" - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" - format: "sarif" - output: "trivy.sarif" - severity: "CRITICAL,HIGH" - exit-code: "0" - - - name: Upload the scan results - uses: github/codeql-action/upload-sarif@v4 - if: "!cancelled() && hashFiles('trivy.sarif') != ''" - with: - sarif_file: "trivy.sarif" - category: "container-nodejs-${{ matrix.target }}-${{ matrix.platform.arch }}" - - - name: Export the digest - env: - DIGEST: ${{ steps.build.outputs.digest }} - run: | - mkdir -p /tmp/digests - touch "/tmp/digests/${DIGEST#sha256:}" - - - uses: actions/upload-artifact@v4 - with: - name: digests-${{ matrix.target }}-${{ matrix.platform.arch }} - path: /tmp/digests/* - if-no-files-found: error - retention-days: 1 - - merge-runtime: - name: Publish Production Manifest - runs-on: ubuntu-latest - needs: [prepare, build] - permissions: - contents: read - packages: write - outputs: - digest: ${{ steps.manifest.outputs.digest }} - steps: - - uses: actions/download-artifact@v4 - with: - path: /tmp/digests - pattern: digests-runtime-* - merge-multiple: true - - - uses: docker/setup-buildx-action@v3 - - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=semver,pattern={{version}},value=${{ needs.prepare.outputs.version }} - type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }} - type=raw,value=latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - - - name: Create the manifest list - working-directory: /tmp/digests - run: | - docker buildx imagetools create \ - $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) - - - name: Read the manifest digest - id: manifest - env: - VERSION: ${{ needs.prepare.outputs.version }} - run: | - digest=$(docker buildx imagetools inspect \ - "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}" \ - --format '{{json .Manifest}}' | jq -r .digest) - echo "digest=$digest" >> "$GITHUB_OUTPUT" - - merge-dev: - name: Publish Dev Manifest - runs-on: ubuntu-latest - needs: [prepare, build] - permissions: - contents: read - packages: write - outputs: - digest: ${{ steps.manifest.outputs.digest }} - steps: - - uses: actions/download-artifact@v4 - with: - path: /tmp/digests - pattern: digests-dev-* - merge-multiple: true - - - uses: docker/setup-buildx-action@v3 - - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # The minor tag is what the CLI resolves a project's declared SDK - # range to, so a runtime-only patch reaches projects without every - # one of them editing a pin. - tags: | - type=raw,value=dev-${{ needs.prepare.outputs.version }} - type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }},prefix=dev- - type=raw,value=dev-latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - - - name: Create the manifest list - working-directory: /tmp/digests - run: | - docker buildx imagetools create \ - $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) - - - name: Read the manifest digest - id: manifest - env: - VERSION: ${{ needs.prepare.outputs.version }} - run: | - digest=$(docker buildx imagetools inspect \ - "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev-${VERSION}" \ - --format '{{json .Manifest}}' | jq -r .digest) - echo "digest=$digest" >> "$GITHUB_OUTPUT" - - sign-and-attest: - name: Sign & Attest Images - runs-on: ubuntu-latest - needs: [merge-runtime, merge-dev] - # Nothing reaches a manifest unless its scan passed, so getting this far - # already means every image being signed is one that cleared the scan. - if: needs.merge-runtime.result == 'success' && needs.merge-dev.result == 'success' - permissions: - contents: read - packages: write id-token: write attestations: write - env: - # Store signatures and attestations as OCI 1.1 referrers instead of - # tag-based artifacts (.sig/.att/.sbom tags) that pollute the GHCR UI. - COSIGN_REGISTRY_REFERRERS_MODE: oci-1-1 - steps: - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: sigstore/cosign-installer@v3 - - uses: anchore/sbom-action/download-syft@v0 - - # --- Production image --- - - name: Sign production image (cosign keyless) - run: | - cosign sign --yes \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} - - - name: Generate production SBOM - run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} \ - -o spdx-json=runtime-sbom.spdx.json - - - name: Attest production SBOM - run: | - cosign attest --yes --predicate runtime-sbom.spdx.json --type spdxjson \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} - - - name: GitHub attestation (production) - uses: actions/attest-build-provenance@v3 - with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.merge-runtime.outputs.digest }} - push-to-registry: true - - # --- Dev image --- - - name: Sign dev image (cosign keyless) - run: | - cosign sign --yes \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} - - - name: Generate dev SBOM - run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} \ - -o spdx-json=dev-sbom.spdx.json - - - name: Attest dev SBOM - run: | - cosign attest --yes --predicate dev-sbom.spdx.json --type spdxjson \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} - - - name: GitHub attestation (dev) - uses: actions/attest-build-provenance@v3 - with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.merge-dev.outputs.digest }} - push-to-registry: true + uses: ./.github/workflows/container-release.yml + secrets: inherit + with: + tag: ${{ inputs.tag }} + tag-component: runtime-nodejs + image-name: newstack-cloud/celerity-runtime-nodejs-24 + context: apps/runtime/nodejs + cache-scope: runtime-nodejs + sarif-category: container-nodejs + targets: >- + [ + { + "name": "runtime", + "tagPrefix": "", + "block": true, + "title": "Celerity Node.js Runtime", + "description": "Production runtime for Celerity Node.js applications" + }, + { + "name": "dev", + "tagPrefix": "dev-", + "block": false, + "title": "Celerity Node.js Runtime (Dev)", + "description": "Development runtime for Celerity Node.js applications (includes SWC, pino-pretty)" + } + ] diff --git a/.github/workflows/app-runtime-python-release.yml b/.github/workflows/app-runtime-python-release.yml index 9bec9a21..916c10dd 100644 --- a/.github/workflows/app-runtime-python-release.yml +++ b/.github/workflows/app-runtime-python-release.yml @@ -4,329 +4,44 @@ on: workflow_dispatch: inputs: tag: - description: 'Release tag (e.g. runtime-python/v0.1.0)' + description: 'Release tag (e.g. runtime-python/v0.3.0)' required: true type: string permissions: contents: read -env: - REGISTRY: ghcr.io - IMAGE_NAME: newstack-cloud/celerity-runtime-python-3-13 - jobs: - prepare: - name: Prepare Release - runs-on: ubuntu-latest - outputs: - version: ${{ steps.version.outputs.version }} - steps: - - name: Extract version from tag - id: version - env: - TAG: ${{ inputs.tag }} - run: | - if [[ ! "$TAG" =~ ^runtime-python/v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then - echo "::error::Expected a tag of the form runtime-python/v1.2.3, got '$TAG'" - exit 1 - fi - VERSION="${TAG##*/}" - VERSION="${VERSION#v}" - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - echo "Extracted version: $VERSION from tag: $TAG" - - build: - name: Build ${{ matrix.target }} on ${{ matrix.platform.arch }} - runs-on: ${{ matrix.platform.runner }} - needs: prepare + release: permissions: contents: read packages: write security-events: write - strategy: - fail-fast: false - matrix: - target: [runtime, dev] - # Each architecture is built on a runner of its own architecture rather - # than one runner emulating the other, which keeps the arm64 dependency - # install off QEMU. - platform: - - arch: amd64 - os: linux/amd64 - runner: ubuntu-latest - - arch: arm64 - os: linux/arm64 - runner: ubuntu-24.04-arm - steps: - - uses: actions/checkout@v4 - - - uses: docker/login-action@v3 - with: - registry: dhi.io - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - labels: | - org.opencontainers.image.title=Celerity Python Runtime${{ matrix.target == 'dev' && ' (Dev)' || '' }} - org.opencontainers.image.description=${{ matrix.target == 'dev' && 'Development runtime for Celerity Python applications (includes watchfiles auto-reload)' || 'Production runtime for Celerity Python applications' }} - - # Needed for the container driver. The docker driver that a runner has by - # default cannot export an image by digest, which is how each - # architecture is pushed before there is a manifest to tag. - - uses: docker/setup-buildx-action@v3 - - # Pushed without a tag, since a tag naming two architectures can only be - # applied once both exist. The manifest that carries the tags is assembled - # from these digests once every architecture has been built. - - id: build - uses: docker/build-push-action@v6 - with: - context: apps/runtime/python - target: ${{ matrix.target }} - platforms: ${{ matrix.platform.os }} - labels: ${{ steps.meta.outputs.labels }} - # Without this buildx attaches a provenance attestation, which makes - # what is pushed an index holding the image and the attestation rather - # than the image itself. Scanning that index means resolving a - # platform inside it, and the manifest list assembled below is where - # multiple platforms belong anyway. The release still gets provenance, - # from the attestation step that runs against the published manifest. - provenance: false - outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true - cache-from: type=gha,scope=runtime-python-${{ matrix.target }}-${{ matrix.platform.arch }} - cache-to: type=gha,mode=max,scope=runtime-python-${{ matrix.target }}-${{ matrix.platform.arch }} - - # Scanned here, before the manifest that carries the tags is assembled, - # so an image with a critical vulnerability is never tagged. Scanning - # after publication would leave the tags live and only skip the signing, - # which is a worse outcome than a failed release. - - name: Scan the image - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - # Blocks on anything with a fix available, so the gate only ever - # asks for an upgrade that exists. Findings with no released fix are - # still reported below, so they are recorded rather than dismissed. - ignore-unfixed: true - # The production image has to be clean. The dev image carries a shell - # and the tools to debug with, and is reported on rather than blocked. - exit-code: ${{ matrix.target == 'runtime' && '1' || '0' }} - - - name: Scan the image (SARIF) - if: "!cancelled() && steps.build.outputs.digest != ''" - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" - format: "sarif" - output: "trivy.sarif" - severity: "CRITICAL,HIGH" - exit-code: "0" - - - name: Upload the scan results - uses: github/codeql-action/upload-sarif@v4 - if: "!cancelled() && hashFiles('trivy.sarif') != ''" - with: - sarif_file: "trivy.sarif" - category: "container-python-${{ matrix.target }}-${{ matrix.platform.arch }}" - - - name: Export the digest - env: - DIGEST: ${{ steps.build.outputs.digest }} - run: | - mkdir -p /tmp/digests - touch "/tmp/digests/${DIGEST#sha256:}" - - - uses: actions/upload-artifact@v4 - with: - name: digests-${{ matrix.target }}-${{ matrix.platform.arch }} - path: /tmp/digests/* - if-no-files-found: error - retention-days: 1 - - merge-runtime: - name: Publish Production Manifest - runs-on: ubuntu-latest - needs: [prepare, build] - permissions: - contents: read - packages: write - outputs: - digest: ${{ steps.manifest.outputs.digest }} - steps: - - uses: actions/download-artifact@v4 - with: - path: /tmp/digests - pattern: digests-runtime-* - merge-multiple: true - - - uses: docker/setup-buildx-action@v3 - - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=semver,pattern={{version}},value=${{ needs.prepare.outputs.version }} - type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }} - type=raw,value=latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - - - name: Create the manifest list - working-directory: /tmp/digests - run: | - docker buildx imagetools create \ - $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) - - - name: Read the manifest digest - id: manifest - env: - VERSION: ${{ needs.prepare.outputs.version }} - run: | - digest=$(docker buildx imagetools inspect \ - "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}" \ - --format '{{json .Manifest}}' | jq -r .digest) - echo "digest=$digest" >> "$GITHUB_OUTPUT" - - merge-dev: - name: Publish Dev Manifest - runs-on: ubuntu-latest - needs: [prepare, build] - permissions: - contents: read - packages: write - outputs: - digest: ${{ steps.manifest.outputs.digest }} - steps: - - uses: actions/download-artifact@v4 - with: - path: /tmp/digests - pattern: digests-dev-* - merge-multiple: true - - - uses: docker/setup-buildx-action@v3 - - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # The minor tag is what the CLI resolves a project's declared SDK - # range to, so a runtime-only patch reaches projects without every - # one of them editing a pin. - tags: | - type=raw,value=dev-${{ needs.prepare.outputs.version }} - type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.version }},prefix=dev- - type=raw,value=dev-latest,enable=${{ !contains(needs.prepare.outputs.version, '-') }} - - - name: Create the manifest list - working-directory: /tmp/digests - run: | - docker buildx imagetools create \ - $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) - - - name: Read the manifest digest - id: manifest - env: - VERSION: ${{ needs.prepare.outputs.version }} - run: | - digest=$(docker buildx imagetools inspect \ - "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev-${VERSION}" \ - --format '{{json .Manifest}}' | jq -r .digest) - echo "digest=$digest" >> "$GITHUB_OUTPUT" - - sign-and-attest: - name: Sign & Attest Images - runs-on: ubuntu-latest - needs: [merge-runtime, merge-dev] - # Nothing reaches a manifest unless its scan passed, so getting this far - # already means every image being signed is one that cleared the scan. - if: needs.merge-runtime.result == 'success' && needs.merge-dev.result == 'success' - permissions: - contents: read - packages: write id-token: write attestations: write - env: - # Store signatures and attestations as OCI 1.1 referrers instead of - # tag-based artifacts (.sig/.att/.sbom tags) that pollute the GHCR UI. - COSIGN_REGISTRY_REFERRERS_MODE: oci-1-1 - steps: - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: sigstore/cosign-installer@v3 - - uses: anchore/sbom-action/download-syft@v0 - - # --- Production image --- - - name: Sign production image (cosign keyless) - run: | - cosign sign --yes \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} - - - name: Generate production SBOM - run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} \ - -o spdx-json=runtime-sbom.spdx.json - - - name: Attest production SBOM - run: | - cosign attest --yes --predicate runtime-sbom.spdx.json --type spdxjson \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-runtime.outputs.digest }} - - - name: GitHub attestation (production) - uses: actions/attest-build-provenance@v3 - with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.merge-runtime.outputs.digest }} - push-to-registry: true - - # --- Dev image --- - - name: Sign dev image (cosign keyless) - run: | - cosign sign --yes \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} - - - name: Generate dev SBOM - run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} \ - -o spdx-json=dev-sbom.spdx.json - - - name: Attest dev SBOM - run: | - cosign attest --yes --predicate dev-sbom.spdx.json --type spdxjson \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.merge-dev.outputs.digest }} - - - name: GitHub attestation (dev) - uses: actions/attest-build-provenance@v3 - with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.merge-dev.outputs.digest }} - push-to-registry: true + uses: ./.github/workflows/container-release.yml + secrets: inherit + with: + tag: ${{ inputs.tag }} + tag-component: runtime-python + image-name: newstack-cloud/celerity-runtime-python-3-13 + context: apps/runtime/python + cache-scope: runtime-python + sarif-category: container-python + targets: >- + [ + { + "name": "runtime", + "tagPrefix": "", + "block": true, + "title": "Celerity Python Runtime", + "description": "Production runtime for Celerity Python applications" + }, + { + "name": "dev", + "tagPrefix": "dev-", + "block": false, + "title": "Celerity Python Runtime (Dev)", + "description": "Development runtime for Celerity Python applications (includes watchfiles auto-reload)" + } + ] diff --git a/.github/workflows/container-release.yml b/.github/workflows/container-release.yml new file mode 100644 index 00000000..22b0ee9a --- /dev/null +++ b/.github/workflows/container-release.yml @@ -0,0 +1,305 @@ +name: Container Release + +# Builds, scans, publishes, signs and attests the container images for one +# release. Called by the per-component release workflows, which hold the +# dispatch entry point and the values that differ between them. +# +# Each architecture is built and pushed by digest, scanned, and only then +# assembled into the manifest that carries the tags, so an image that fails +# its scan is never tagged. Signing runs off that manifest, so an image that +# was never tagged is never signed either. + +on: + workflow_call: + inputs: + tag: + description: 'Release tag being published (e.g. runtime-nodejs/v0.9.0)' + required: true + type: string + tag-component: + description: 'Component the release tag must name (e.g. runtime-nodejs)' + required: true + type: string + image-name: + description: 'Image repository within the registry (e.g. newstack-cloud/celerity-runtime-nodejs-24)' + required: true + type: string + context: + description: 'Build context directory' + required: true + type: string + dockerfile: + description: 'Dockerfile path. Defaults to a Dockerfile at the root of the context.' + required: false + type: string + default: '' + targets: + description: >- + JSON array of the images to publish from this context. Each entry names a + Dockerfile target, the prefix its tags carry, whether a scan failure blocks + the release, and the labels the image gets. See the callers for examples. + required: true + type: string + cache-scope: + description: 'Prefix for the build cache scope. Must be unique per image.' + required: true + type: string + sarif-category: + description: 'Prefix for the code scanning category. Must be unique per image.' + required: true + type: string + +env: + REGISTRY: ghcr.io + +jobs: + prepare: + name: Prepare Release + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + minor: ${{ steps.version.outputs.minor }} + prerelease: ${{ steps.version.outputs.prerelease }} + steps: + - name: Extract version from tag + id: version + env: + TAG: ${{ inputs.tag }} + COMPONENT: ${{ inputs.tag-component }} + run: | + if [[ ! "$TAG" =~ ^${COMPONENT}/v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then + echo "::error::Expected a tag of the form ${COMPONENT}/v1.2.3, got '$TAG'" + exit 1 + fi + VERSION="${TAG##*/}" + VERSION="${VERSION#v}" + + # The minor series is the tag the CLI resolves a project's declared SDK + # range to. A prerelease does not get one, since a range does not resolve + # to a prerelease, and it does not move latest either. + if [[ "$VERSION" == *-* ]]; then + PRERELEASE=true + else + PRERELEASE=false + fi + # Taken from the numeric core so the minor stays meaningful for a + # prerelease, rather than trimming at the last dot of the whole string + # and leaving something like 0.10.0-rc behind. + CORE="${VERSION%%-*}" + MINOR="${CORE%.*}" + + { + echo "version=$VERSION" + echo "minor=$MINOR" + echo "prerelease=$PRERELEASE" + } >> "$GITHUB_OUTPUT" + echo "Extracted version: $VERSION (minor $MINOR, prerelease $PRERELEASE) from tag: $TAG" + + build: + name: Build ${{ matrix.target.name }} on ${{ matrix.platform.arch }} + runs-on: ${{ matrix.platform.runner }} + needs: prepare + permissions: + contents: read + packages: write + security-events: write + strategy: + fail-fast: false + matrix: + target: ${{ fromJSON(inputs.targets) }} + # Each architecture is built on a runner of its own architecture rather + # than one runner emulating the other. + platform: + - arch: amd64 + os: linux/amd64 + runner: ubuntu-latest + - arch: arm64 + os: linux/arm64 + runner: ubuntu-24.04-arm + steps: + - uses: actions/checkout@v4 + + - uses: docker/login-action@v3 + with: + registry: dhi.io + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/metadata-action@v5 + id: meta + with: + images: ${{ env.REGISTRY }}/${{ inputs.image-name }} + labels: | + org.opencontainers.image.title=${{ matrix.target.title }} + org.opencontainers.image.description=${{ matrix.target.description }} + + # Needed for the container driver. The docker driver that a runner has by + # default cannot export an image by digest, which is how each + # architecture is pushed before there is a manifest to tag. + - uses: docker/setup-buildx-action@v3 + + # Pushed without a tag, since a tag naming two architectures can only be + # applied once both exist. The manifest that carries the tags is assembled + # from these digests once every architecture has been built. + - id: build + uses: docker/build-push-action@v6 + with: + context: ${{ inputs.context }} + file: ${{ inputs.dockerfile != '' && inputs.dockerfile || format('{0}/Dockerfile', inputs.context) }} + target: ${{ matrix.target.name }} + platforms: ${{ matrix.platform.os }} + labels: ${{ steps.meta.outputs.labels }} + # Without this buildx attaches a provenance attestation, which makes + # what is pushed an index holding the image and the attestation rather + # than the image itself. Scanning that index means resolving a + # platform inside it, and the manifest list assembled below is where + # multiple platforms belong anyway. The release still gets provenance, + # from the attestation step that runs against the published manifest. + provenance: false + outputs: type=image,name=${{ env.REGISTRY }}/${{ inputs.image-name }},push-by-digest=true,name-canonical=true,push=true + cache-from: type=gha,scope=${{ inputs.cache-scope }}-${{ matrix.target.name }}-${{ matrix.platform.arch }} + cache-to: type=gha,mode=max,scope=${{ inputs.cache-scope }}-${{ matrix.target.name }}-${{ matrix.platform.arch }} + + # Scanned here, before the manifest that carries the tags is assembled, + # so an image with a critical vulnerability is never tagged. Scanning + # after publication would leave the tags live and only skip the signing, + # which is a worse outcome than a failed release. + - name: Scan the image + uses: aquasecurity/trivy-action@0.35.0 + with: + image-ref: "${{ env.REGISTRY }}/${{ inputs.image-name }}@${{ steps.build.outputs.digest }}" + format: "table" + severity: "CRITICAL,HIGH" + # Blocks on anything with a fix available, so the gate only ever + # asks for an upgrade that exists. Findings with no released fix are + # still reported below, so they are recorded rather than dismissed. + ignore-unfixed: true + # Production images have to be clean. Images carrying a shell and the + # tools to debug with are reported on rather than blocked. + exit-code: ${{ matrix.target.block && '1' || '0' }} + + - name: Scan the image (SARIF) + if: "!cancelled() && steps.build.outputs.digest != ''" + uses: aquasecurity/trivy-action@0.35.0 + with: + image-ref: "${{ env.REGISTRY }}/${{ inputs.image-name }}@${{ steps.build.outputs.digest }}" + format: "sarif" + output: "trivy.sarif" + severity: "CRITICAL,HIGH" + exit-code: "0" + + - name: Upload the scan results + uses: github/codeql-action/upload-sarif@v4 + if: "!cancelled() && hashFiles('trivy.sarif') != ''" + with: + sarif_file: "trivy.sarif" + category: "${{ inputs.sarif-category }}-${{ matrix.target.name }}-${{ matrix.platform.arch }}" + + - name: Export the digest + env: + DIGEST: ${{ steps.build.outputs.digest }} + run: | + mkdir -p /tmp/digests + touch "/tmp/digests/${DIGEST#sha256:}" + + - uses: actions/upload-artifact@v4 + with: + name: digests-${{ matrix.target.name }}-${{ matrix.platform.arch }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + + # Assembling the manifest and signing it are one job because a matrix job's + # outputs are overwritten by whichever leg finishes last, so a separate + # signing job could not read a per-target digest. Keeping them together also + # keeps the guarantee direct, in that signing cannot run for a target whose + # manifest was never assembled. + publish: + name: Publish & Sign ${{ matrix.target.name }} + runs-on: ubuntu-latest + needs: [prepare, build] + permissions: + contents: read + packages: write + id-token: write + attestations: write + strategy: + fail-fast: false + matrix: + target: ${{ fromJSON(inputs.targets) }} + env: + # Store signatures and attestations as OCI 1.1 referrers instead of + # tag-based artifacts (.sig/.att/.sbom tags) that pollute the GHCR UI. + COSIGN_REGISTRY_REFERRERS_MODE: oci-1-1 + steps: + - uses: actions/download-artifact@v4 + with: + path: /tmp/digests + pattern: digests-${{ matrix.target.name }}-* + merge-multiple: true + + - uses: docker/setup-buildx-action@v3 + + - uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Written out rather than derived from the semver tag type so the + # prerelease rule is stated once, here, instead of resting on what the + # metadata action does with a prerelease by default. + - uses: docker/metadata-action@v5 + id: meta + with: + images: ${{ env.REGISTRY }}/${{ inputs.image-name }} + tags: | + type=raw,value=${{ matrix.target.tagPrefix }}${{ needs.prepare.outputs.version }} + type=raw,value=${{ matrix.target.tagPrefix }}${{ needs.prepare.outputs.minor }},enable=${{ needs.prepare.outputs.prerelease == 'false' }} + type=raw,value=${{ matrix.target.tagPrefix }}latest,enable=${{ needs.prepare.outputs.prerelease == 'false' }} + + - name: Create the manifest list + working-directory: /tmp/digests + run: | + docker buildx imagetools create \ + $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.REGISTRY }}/${{ inputs.image-name }}@sha256:%s ' *) + + - name: Read the manifest digest + id: manifest + env: + REF: ${{ env.REGISTRY }}/${{ inputs.image-name }}:${{ matrix.target.tagPrefix }}${{ needs.prepare.outputs.version }} + run: | + digest=$(docker buildx imagetools inspect "$REF" --format '{{json .Manifest}}' | jq -r .digest) + echo "digest=$digest" >> "$GITHUB_OUTPUT" + + - uses: sigstore/cosign-installer@v3 + - uses: anchore/sbom-action/download-syft@v0 + + - name: Sign the image (cosign keyless) + run: | + cosign sign --yes \ + ${{ env.REGISTRY }}/${{ inputs.image-name }}@${{ steps.manifest.outputs.digest }} + + - name: Generate the SBOM + run: | + syft ${{ env.REGISTRY }}/${{ inputs.image-name }}@${{ steps.manifest.outputs.digest }} \ + -o spdx-json=${{ matrix.target.name }}-sbom.spdx.json + + - name: Attest the SBOM + run: | + cosign attest --yes --predicate ${{ matrix.target.name }}-sbom.spdx.json --type spdxjson \ + ${{ env.REGISTRY }}/${{ inputs.image-name }}@${{ steps.manifest.outputs.digest }} + + - name: GitHub attestation + uses: actions/attest-build-provenance@v3 + with: + subject-name: ${{ env.REGISTRY }}/${{ inputs.image-name }} + subject-digest: ${{ steps.manifest.outputs.digest }} + push-to-registry: true From 3eb2b51971e5ed0037e2f5b209e6d4f81dfd57a1 Mon Sep 17 00:00:00 2001 From: Andre Sutherland Date: Fri, 28 Aug 2026 17:53:07 +0100 Subject: [PATCH 6/8] ci: check out the release tag rather than the dispatch branch The callers are dispatched with a tag input and the checkout step took no ref, so the source built came from whichever branch the dispatch was started from while the version stamped on the image came from the tag. A release retried after other work had landed would build something the tag never named. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/container-release.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/container-release.yml b/.github/workflows/container-release.yml index 22b0ee9a..ffb5be64 100644 --- a/.github/workflows/container-release.yml +++ b/.github/workflows/container-release.yml @@ -117,7 +117,12 @@ jobs: os: linux/arm64 runner: ubuntu-24.04-arm steps: + # Checked out at the release tag rather than the branch the dispatch was + # started from, so a release built today is the source that tag names and + # not whatever has landed on the branch since. - uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag }} - uses: docker/login-action@v3 with: From 018bc27f6b5b13a6262debb7550b65fa7c2b8a75 Mon Sep 17 00:00:00 2001 From: Andre Sutherland Date: Fri, 28 Aug 2026 17:53:24 +0100 Subject: [PATCH 7/8] fix(cli): drop build metadata from the resolved runtime image tag The SDK version comes from a project's own manifest, so a version carrying build metadata reaches the resolver. It was returned whole alongside a prerelease, giving a tag that no registry can hold, since a plus is not a legal character in a Docker tag and the release workflow rejects a version carrying one. Cutting the metadata off first resolves to the minor series that is actually published, and leaves the prerelease rule as it was. Co-Authored-By: Claude Opus 5 (1M context) --- apps/cli/internal/blueprint/helpers.go | 8 +++++++- apps/cli/internal/blueprint/helpers_test.go | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/cli/internal/blueprint/helpers.go b/apps/cli/internal/blueprint/helpers.go index 22f3e0a0..5be01abb 100644 --- a/apps/cli/internal/blueprint/helpers.go +++ b/apps/cli/internal/blueprint/helpers.go @@ -146,8 +146,14 @@ func ResolveRuntimeImage(runtime string, imageVersion string) (string, error) { // // Prereleases keep the full version as the release workflow deliberately publishes // no minor tag for one, since a prerelease is not what a range resolves to. +// +// Build metadata is dropped first. No published tag carries it, since the release +// workflow only accepts a tag without it, and a "+" is not a legal character in a +// Docker tag anyway, so leaving it on would build a reference that cannot be pulled. func runtimeImageTagVersion(imageVersion string) string { - if strings.ContainsAny(imageVersion, "-+") { + imageVersion, _, _ = strings.Cut(imageVersion, "+") + + if strings.Contains(imageVersion, "-") { return imageVersion } diff --git a/apps/cli/internal/blueprint/helpers_test.go b/apps/cli/internal/blueprint/helpers_test.go index 382e6eba..ea434149 100644 --- a/apps/cli/internal/blueprint/helpers_test.go +++ b/apps/cli/internal/blueprint/helpers_test.go @@ -175,6 +175,18 @@ func (s *HelpersTestSuite) Test_ResolveRuntimeImage_keeps_a_version_without_a_pa s.Assert().Equal("ghcr.io/newstack-cloud/celerity-runtime-nodejs-24:dev-0.9", image) } +func (s *HelpersTestSuite) Test_ResolveRuntimeImage_drops_build_metadata() { + image, err := ResolveRuntimeImage("nodejs24.x", "0.9.5+build.1") + s.Require().NoError(err) + s.Assert().Equal("ghcr.io/newstack-cloud/celerity-runtime-nodejs-24:dev-0.9", image) +} + +func (s *HelpersTestSuite) Test_ResolveRuntimeImage_drops_build_metadata_from_a_prerelease() { + image, err := ResolveRuntimeImage("nodejs24.x", "0.10.0-rc.1+build.1") + s.Require().NoError(err) + s.Assert().Equal("ghcr.io/newstack-cloud/celerity-runtime-nodejs-24:dev-0.10.0-rc.1", image) +} + func (s *HelpersTestSuite) Test_ResolveRuntimeImage_unsupported_runtime() { _, err := ResolveRuntimeImage("ruby3.3", "0.3.0") s.Require().Error(err) From 2ff9665793400ade9768ad7a2db3878da4705370 Mon Sep 17 00:00:00 2001 From: Andre Sutherland Date: Fri, 28 Aug 2026 17:53:38 +0100 Subject: [PATCH 8/8] docs(runtime-python): use a compatible release constraint in the example A bare floor resolves to the same image tag but does not hold the project to that minor, so the installed SDK is free to move on to one the image does not carry, which is the alignment the section is arguing for. The compatible release form is the PEP 440 equivalent of the caret range the Node.js runtime documents for the same mapping. Co-Authored-By: Claude Opus 5 (1M context) --- apps/runtime/python/RELEASING.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/runtime/python/RELEASING.md b/apps/runtime/python/RELEASING.md index 1a125750..c5cd924b 100644 --- a/apps/runtime/python/RELEASING.md +++ b/apps/runtime/python/RELEASING.md @@ -12,9 +12,10 @@ runtime major.minor == SDK major.minor patch belongs to the runtime The patch component is held out of the mapping so the runtime can ship a rebuild of its own, for a base image CVE or a fix in the wrapper, without waiting on an SDK release. A -project declaring `celerity-sdk[runtime]>=0.3.0` resolves to the `dev-0.3` tag, which -carries the newest runtime patch on that minor, so it picks the rebuild up without editing -a pin. +project declaring `celerity-sdk[runtime]~=0.3.0` is asking for any `0.3.x`, which is what +the `dev-0.3` tag carries, so it picks the rebuild up without editing a pin. A bare +`>=0.3.0` resolves to the same tag but does not hold the project to that minor, leaving the +installed SDK free to move on to one the image does not carry. The two version numbers are no longer readable as "this image contains exactly that SDK". Runtime `0.3.2` may carry SDK `0.3.1`. The exact set is recorded in `runtime-manifest.json`,