diff --git a/.github/workflows/app-dev-auth-release.yml b/.github/workflows/app-dev-auth-release.yml index d52a3349..e9b39024 100644 --- a/.github/workflows/app-dev-auth-release.yml +++ b/.github/workflows/app-dev-auth-release.yml @@ -11,155 +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 - run: | - TAG="${{ inputs.tag }}" - VERSION="${TAG##*/}" - VERSION="${VERSION#v}" - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "Extracted version: $VERSION from tag: $TAG" - - build: - name: Build & Push Production Image - runs-on: ubuntu-latest + release: permissions: contents: read packages: write - needs: prepare - outputs: - digest: ${{ steps.build.outputs.digest }} - 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 }} - 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 - - uses: docker/setup-buildx-action@v3 - - - 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 }} - 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) - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - exit-code: "1" - - - 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.outputs.digest }}" - format: "sarif" - output: "trivy-dev-auth.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-dev-auth.sarif" - category: "container-dev-auth" - - sign-and-attest: - name: Sign & Attest Images - runs-on: ubuntu-latest - 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: - 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.build.outputs.digest }} - - - name: Generate production SBOM - run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.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 }} - - - name: GitHub attestation (production) - uses: actions/attest-build-provenance@v3 - with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ needs.build.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 f6540599..51bd2880 100644 --- a/.github/workflows/app-local-events-release.yml +++ b/.github/workflows/app-local-events-release.yml @@ -4,165 +4,37 @@ 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 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 - run: | - TAG="${{ inputs.tag }}" - VERSION="${TAG##*/}" - VERSION="${VERSION#v}" - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "Extracted version: $VERSION from tag: $TAG" - - build: - name: Build & Push Production Image - runs-on: ubuntu-latest + release: permissions: contents: read packages: write - needs: prepare - outputs: - digest: ${{ steps.build.outputs.digest }} - 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 }} - 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 - - uses: docker/setup-buildx-action@v3 - - - 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 }} - 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) - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - exit-code: "1" - - - 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.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" - - sign-and-attest: - name: Sign & Attest Images - runs-on: ubuntu-latest - 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 - 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.build.outputs.digest }} - - - name: Generate production SBOM - run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.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.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 }} - 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 6f857b03..638c989f 100644 --- a/.github/workflows/app-runtime-core-release.yml +++ b/.github/workflows/app-runtime-core-release.yml @@ -11,324 +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 }} - tags: | - type=raw,value=dev-${{ needs.prepare.outputs.version }} - 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 3397ec0f..0fcbac45 100644 --- a/.github/workflows/app-runtime-nodejs-release.yml +++ b/.github/workflows/app-runtime-nodejs-release.yml @@ -4,264 +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 - run: | - TAG="${{ inputs.tag }}" - VERSION="${TAG##*/}" - VERSION="${VERSION#v}" - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "Extracted version: $VERSION from tag: $TAG" - - build-runtime: - name: Build & Push Production Image - runs-on: ubuntu-latest + release: permissions: contents: read packages: write - needs: prepare - outputs: - digest: ${{ steps.build.outputs.digest }} - 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 }} - 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 - - - uses: docker/setup-qemu-action@v3 - - uses: docker/setup-buildx-action@v3 - - - 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 }} - 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 - - build-dev: - name: Build & Push Dev Image - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - needs: prepare - outputs: - digest: ${{ steps.build.outputs.digest }} - 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 }} - 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 - - - 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 - - scan-images: - name: Scan Container Images - runs-on: ubuntu-latest - permissions: - contents: read security-events: write - needs: [build-runtime, build-dev] - steps: - - uses: actions/checkout@v4 - - - name: Trivy scan production image (table) - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-runtime.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - exit-code: "1" - - - 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" - - - name: Trivy scan dev image (table) - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-dev.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - exit-code: "0" - - - name: Trivy scan dev image (SARIF) - if: always() - uses: aquasecurity/trivy-action@0.35.0 - 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" - - - name: Upload dev scan results - uses: github/codeql-action/upload-sarif@v4 - if: always() - with: - sarif_file: "trivy-dev.sarif" - category: "container-dev" - - sign-and-attest: - name: Sign & Attest Images - runs-on: ubuntu-latest - 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. - 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.build-runtime.outputs.digest }} - - - name: Generate production SBOM - run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-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 }} - - - 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 }} - 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 }} - - - name: Generate dev SBOM - run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-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 }} - - - 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 }} - 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 fd547f62..916c10dd 100644 --- a/.github/workflows/app-runtime-python-release.yml +++ b/.github/workflows/app-runtime-python-release.yml @@ -4,264 +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 - run: | - TAG="${{ inputs.tag }}" - VERSION="${TAG##*/}" - VERSION="${VERSION#v}" - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "Extracted version: $VERSION from tag: $TAG" - - build-runtime: - name: Build & Push Production Image - runs-on: ubuntu-latest + release: permissions: contents: read packages: write - needs: prepare - outputs: - digest: ${{ steps.build.outputs.digest }} - 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 }} - 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 - - - uses: docker/setup-qemu-action@v3 - - uses: docker/setup-buildx-action@v3 - - - 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 }} - 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 - - build-dev: - name: Build & Push Dev Image - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - needs: prepare - outputs: - digest: ${{ steps.build.outputs.digest }} - 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 }} - 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 - - - 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 - - scan-images: - name: Scan Container Images - runs-on: ubuntu-latest - permissions: - contents: read security-events: write - needs: [build-runtime, build-dev] - steps: - - uses: actions/checkout@v4 - - - name: Trivy scan production image (table) - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-runtime.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - exit-code: "1" - - - 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" - - - name: Trivy scan dev image (table) - uses: aquasecurity/trivy-action@0.35.0 - with: - image-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-dev.outputs.digest }}" - format: "table" - severity: "CRITICAL,HIGH" - exit-code: "0" - - - name: Trivy scan dev image (SARIF) - if: always() - uses: aquasecurity/trivy-action@0.35.0 - 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" - - - name: Upload dev scan results - uses: github/codeql-action/upload-sarif@v4 - if: always() - with: - sarif_file: "trivy-dev.sarif" - category: "container-python-dev" - - sign-and-attest: - name: Sign & Attest Images - runs-on: ubuntu-latest - 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. - 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.build-runtime.outputs.digest }} - - - name: Generate production SBOM - run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-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 }} - - - 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 }} - 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 }} - - - name: Generate dev SBOM - run: | - syft ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-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 }} - - - 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 }} - 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..ffb5be64 --- /dev/null +++ b/.github/workflows/container-release.yml @@ -0,0 +1,310 @@ +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: + # 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: + 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 diff --git a/apps/cli/internal/blueprint/helpers.go b/apps/cli/internal/blueprint/helpers.go index 756da6f1..5be01abb 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,33 @@ 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. +// +// 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 { + imageVersion, _, _ = strings.Cut(imageVersion, "+") + + if strings.Contains(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..ea434149 100644 --- a/apps/cli/internal/blueprint/helpers_test.go +++ b/apps/cli/internal/blueprint/helpers_test.go @@ -148,13 +148,43 @@ 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_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() { 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/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 diff --git a/apps/runtime/python/RELEASING.md b/apps/runtime/python/RELEASING.md index 3f995622..c5cd924b 100644 --- a/apps/runtime/python/RELEASING.md +++ b/apps/runtime/python/RELEASING.md @@ -2,8 +2,28 @@ ## 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` 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`, +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 +33,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 +108,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.