OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
fix(release): publish containers with coordinated npm releases (#1796)
Michael D'Angelo15f349c296e7
diff --git a/.github/workflows/container-release.yml b/.github/workflows/container-release.ymlindex 934697cb2..c2a7883ae 100644--- a/.github/workflows/container-release.yml+++ b/.github/workflows/container-release.yml@@ -5,6 +5,16 @@ on:tags:- "container-v*"workflow_dispatch:+ workflow_call:+ inputs:+ release-sha:+ description: Verified npm release source commit.+ required: true+ type: string+ release-version:+ description: Verified stable npm version.+ required: true+ type: stringconcurrency: container-release-publish@@ -12,51 +22,55 @@ permissions:contents: readjobs:- native:- if: github.repository == 'openai/codex-security'- uses: ./.github/workflows/native-artifacts.yml-- validate:- needs: native- if: github.repository == 'openai/codex-security'- uses: ./.github/workflows/container-validate.yml-- authorize:+ source:if: github.repository == 'openai/codex-security'- name: authorize-container-publication- needs: validateruns-on: ubuntu-24.04timeout-minutes: 10- environment: containerpermissions:contents: readpackages: read+ attestations: readoutputs:+ sha: ${{ steps.release.outputs.sha }}image: ${{ steps.release.outputs.image }}version: ${{ steps.release.outputs.version }}- labels: ${{ steps.metadata.outputs.labels }}- metadata: ${{ steps.metadata.outputs.json }}-+ existing-digest: ${{ steps.existing.outputs.digest }}steps:- - name: Checkout release source+ - name: Checkout release historyuses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:+ ref: ${{ github.sha }}fetch-depth: 0persist-credentials: false- name: Validate protected release source and versionid: release+ env:+ RELEASE_SHA: ${{ inputs.release-sha }}+ RELEASE_VERSION: ${{ inputs.release-version }}shell: bashrun: |set -euo pipefail- package_version="$(node -p 'require("./sdk/typescript/package.json").version')"+ source_sha="$GITHUB_SHA"- if [[ "$GITHUB_EVENT_NAME" == workflow_dispatch ]]; then+ if [[ -n "$RELEASE_SHA" ]]; then+ if [[ "$GITHUB_REF" != refs/heads/main || ! "$RELEASE_SHA" =~ ^[0-9a-f]{40}$ ]]; then+ echo 'Coordinated image releases must run on main with an exact release commit.' >&2+ exit 1+ fi+ source_sha="$RELEASE_SHA"+ version="$RELEASE_VERSION"+ if [[ ! "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]] ||+ [[ "$(git rev-parse "refs/tags/npm-v$version^{commit}")" != "$source_sha" ]]; then+ echo 'The container source must match the immutable npm release tag.' >&2+ exit 1+ fi+ elif [[ "$GITHUB_EVENT_NAME" == workflow_dispatch ]]; thenif [[ "$GITHUB_REF" != refs/heads/main ]]; thenecho 'Manual image releases must use the protected main branch.' >&2exit 1fi- version="$package_version"+ version="$(git show "$source_sha:sdk/typescript/package.json" | jq -r .version)"elif [[ "$GITHUB_REF_NAME" =~ ^container-v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; thenversion="${GITHUB_REF_NAME#container-v}"else@@ -64,24 +78,112 @@ jobs:exit 1fi+ package_version="$(git show "$source_sha:sdk/typescript/package.json" | jq -r .version)"if [[ "$version" != "$package_version" ]]; thenecho "Container version $version must match the CLI package version $package_version." >&2exit 1figit fetch --no-tags origin +refs/heads/main:refs/remotes/origin/main- if ! git merge-base --is-ancestor "$GITHUB_SHA" refs/remotes/origin/main; then+ if ! git merge-base --is-ancestor "$source_sha" refs/remotes/origin/main; thenecho 'Container releases must be built from a commit on the protected main branch.' >&2exit 1fi- printf 'image=ghcr.io/%s\n' "${GITHUB_REPOSITORY_OWNER,,}/codex-security" >> "$GITHUB_OUTPUT"+ owner="$(printf '%s' "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')"+ printf 'image=ghcr.io/%s/codex-security\n' "$owner" >> "$GITHUB_OUTPUT"printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT"+ printf 'sha=%s\n' "$source_sha" >> "$GITHUB_OUTPUT"- - name: Preflight public package and immutable release version+ - &set-up-docker-buildx+ name: Set up Docker Buildx+ uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1++ - name: Verify an existing immutable container release+ id: existingenv:GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ IMAGE: ${{ steps.release.outputs.image }}VERSION: ${{ steps.release.outputs.version }}+ RELEASE_SHA: ${{ steps.release.outputs.sha }}+ shell: bash+ run: |+ set -euo pipefail+ owner="$(printf '%s' "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')"+ endpoint="orgs/$owner/packages/container/codex-security"+ versions="$(gh api --paginate "$endpoint/versions?per_page=100")"+ digest="$(jq -r -s --arg version "$VERSION" '+ [.[][] | select(any(.metadata.container.tags[]?; . == $version)) | .name]+ | unique | .[]+ ' <<< "$versions")"+ if [[ -z "$digest" ]]; then+ exit 0+ fi+ if [[ ! "$digest" =~ ^sha256:[a-f0-9]{64}$ ]]; then+ echo 'The existing container version must resolve to one immutable digest.' >&2+ exit 1+ fi+ jq --exit-status --slurp --arg tag "sha-$RELEASE_SHA" --arg digest "$digest" '+ [.[][] | select(any(.metadata.container.tags[]?; . == $tag)) | .name]+ | unique == [$digest]+ ' <<< "$versions" > /dev/null+ reference="$IMAGE@$digest"+ docker buildx imagetools inspect "$reference" --raw |+ jq --exit-status --arg version "$VERSION" --arg sha "$RELEASE_SHA" '+ .annotations["org.opencontainers.image.version"] == $version+ and .annotations["org.opencontainers.image.revision"] == $sha+ and (+ [.manifests[] | select(.platform.os == "linux") | .platform.architecture]+ | (index("amd64") != null and index("arm64") != null)+ )+ ' > /dev/null+ gh attestation verify "oci://$reference" --repo "$GITHUB_REPOSITORY"+ docker pull "$reference"+ docker run --rm "$reference" --version+ sh docker/verify-container-release-version.sh "$endpoint" "$VERSION" "$digest"+ printf 'digest=%s\n' "$digest" >> "$GITHUB_OUTPUT"++ native:+ needs: source+ if: github.repository == 'openai/codex-security' && needs.source.outputs.existing-digest == ''+ uses: ./.github/workflows/native-artifacts.yml+ with:+ ref: ${{ needs.source.outputs.sha }}++ validate:+ needs: [source, native]+ if: github.repository == 'openai/codex-security'+ uses: ./.github/workflows/container-validate.yml+ with:+ ref: ${{ needs.source.outputs.sha }}++ authorize:+ if: github.repository == 'openai/codex-security'+ name: authorize-container-publication+ needs: [source, validate]+ runs-on: ubuntu-24.04+ timeout-minutes: 10+ environment: container+ permissions:+ contents: read+ packages: read+ outputs:+ sha: ${{ needs.source.outputs.sha }}+ image: ${{ needs.source.outputs.image }}+ version: ${{ needs.source.outputs.version }}+ labels: ${{ steps.metadata.outputs.labels }}+ metadata: ${{ steps.metadata.outputs.json }}+ steps:+ - name: Checkout release automation+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ ref: ${{ github.sha }}+ persist-credentials: false++ - name: Preflight public package and immutable release version+ env:+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ VERSION: ${{ needs.source.outputs.version }}shell: bashrun: |set -euo pipefail@@ -104,16 +206,17 @@ jobs:id: metadatauses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0with:- images: ${{ steps.release.outputs.image }}+ images: ${{ needs.source.outputs.image }}# Use the release version for metadata; only promote publishes stable tags.- tags: type=raw,value=${{ steps.release.outputs.version }}+ tags: type=raw,value=${{ needs.source.outputs.version }}labels: |org.opencontainers.image.title=Codex Securityorg.opencontainers.image.description=Codex Security scanner.org.opencontainers.image.licenses=Apache-2.0org.opencontainers.image.vendor=OpenAI- org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}/releases/tag/npm-v${{ steps.release.outputs.version }}- org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/docker/README.md+ org.opencontainers.image.revision=${{ needs.source.outputs.sha }}+ org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}/releases/tag/npm-v${{ needs.source.outputs.version }}+ org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/${{ needs.source.outputs.sha }}/docker/README.mdpublish-platform:name: publish-linux-${{ matrix.architecture }}@@ -136,13 +239,15 @@ jobs:- name: Checkout approved release sourceuses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:+ ref: ${{ needs.authorize.outputs.sha }}persist-credentials: false- name: Prepare native runtime- uses: ./.github/actions/download-native+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2+ with:+ name: native-universal-${{ needs.authorize.outputs.sha }}+ path: plugins/codex-security/native/prebuilt- - &set-up-docker-buildx- name: Set up Docker Buildx- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1+ - *set-up-docker-buildx- &sign-in-to-github-container-registryname: Sign in to GitHub Container Registry@@ -236,6 +341,7 @@ jobs:- name: Checkout approved customer configurationuses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:+ ref: ${{ needs.authorize.outputs.sha }}persist-credentials: false- *set-up-docker-buildx@@ -255,6 +361,7 @@ jobs:IMAGE: ${{ needs.authorize.outputs.image }}IMAGE_LABELS: ${{ needs.authorize.outputs.labels }}IMAGE_METADATA: ${{ needs.authorize.outputs.metadata }}+ RELEASE_SHA: ${{ needs.authorize.outputs.sha }}shell: bashrun: |set -euo pipefail@@ -282,7 +389,7 @@ jobs:annotations+=(--annotation "index:$label")done <<< "$IMAGE_LABELS"- candidate="$IMAGE:release-candidate-$GITHUB_SHA"+ candidate="$IMAGE:release-candidate-$RELEASE_SHA"docker buildx imagetools create \"${annotations[@]}" \--tag "$candidate" \@@ -366,6 +473,7 @@ jobs:- name: Checkout approved immutable-version verifieruses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:+ ref: ${{ github.sha }}persist-credentials: false- *set-up-docker-buildx@@ -396,10 +504,11 @@ jobs:VERSION: ${{ needs.authorize.outputs.version }}PUBLISH_LATEST: ${{ steps.version.outputs.publish_latest }}MANIFEST_DIGEST: ${{ needs.manifest.outputs.digest }}+ RELEASE_SHA: ${{ needs.authorize.outputs.sha }}shell: bashrun: |set -euo pipefail- tags=(--tag "$IMAGE:$VERSION" --tag "$IMAGE:sha-$GITHUB_SHA")+ tags=(--tag "$IMAGE:$VERSION" --tag "$IMAGE:sha-$RELEASE_SHA")if [[ "$PUBLISH_LATEST" == true ]]; thentags+=(--tag "$IMAGE:latest")fi@@ -433,13 +542,14 @@ jobs:MANIFEST_DIGEST: ${{ needs.manifest.outputs.digest }}RELEASE_URL: ${{ fromJSON(needs.authorize.outputs.metadata).labels['org.opencontainers.image.url'] }}DOCUMENTATION_URL: ${{ fromJSON(needs.authorize.outputs.metadata).labels['org.opencontainers.image.documentation'] }}+ RELEASE_SHA: ${{ needs.authorize.outputs.sha }}shell: bashrun: |{printf '## Codex Security container %s\n\n' "$VERSION"printf 'Platforms: linux/amd64, linux/arm64.\n\n'printf 'Source: [%s](%s/%s/commit/%s)\n\n' \- "$GITHUB_SHA" "$GITHUB_SERVER_URL" "$GITHUB_REPOSITORY" "$GITHUB_SHA"+ "$RELEASE_SHA" "$GITHUB_SERVER_URL" "$GITHUB_REPOSITORY" "$RELEASE_SHA"printf '[Container guide](%s) | [Release notes](%s)\n\n' \"$DOCUMENTATION_URL" "$RELEASE_URL"printf '```bash\n'diff --git a/.github/workflows/container-validate.yml b/.github/workflows/container-validate.ymlindex c23f42b5f..ae1253678 100644--- a/.github/workflows/container-validate.yml+++ b/.github/workflows/container-validate.yml@@ -2,6 +2,11 @@ name: container-validateon:workflow_call:+ inputs:+ ref:+ description: Source commit to validate; defaults to the calling workflow commit.+ type: string+ default: ""permissions:contents: read@@ -24,9 +29,13 @@ jobs:- name: Checkout repositoryuses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:+ ref: ${{ inputs.ref || github.sha }}persist-credentials: false- name: Prepare native runtime- uses: ./.github/actions/download-native+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2+ with:+ name: native-universal-${{ inputs.ref || github.sha }}+ path: plugins/codex-security/native/prebuilt- name: Verify customer build excludes secrets and scan datashell: bashdiff --git a/.github/workflows/native-artifacts.yml b/.github/workflows/native-artifacts.ymlindex 5197a5b09..89b83dfd7 100644--- a/.github/workflows/native-artifacts.yml+++ b/.github/workflows/native-artifacts.yml@@ -2,6 +2,11 @@ name: native-artifactson:workflow_call:+ inputs:+ ref:+ description: Source commit to build; defaults to the calling workflow commit.+ type: string+ default: ""workflow_dispatch:permissions:@@ -10,10 +15,16 @@ permissions:jobs:unix:uses: ./.github/workflows/native-unix.yml+ with:+ ref: ${{ inputs.ref || github.sha }}windows:uses: ./.github/workflows/native-windows.yml+ with:+ ref: ${{ inputs.ref || github.sha }}musl:uses: ./.github/workflows/native-musl.yml+ with:+ ref: ${{ inputs.ref || github.sha }}bundle:needs: [unix, windows, musl]runs-on: ubuntu-24.04@@ -21,13 +32,13 @@ jobs:- name: Download verified platform payloadsuses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2with:- pattern: native-platform-*-${{ github.sha }}+ pattern: native-platform-*-${{ inputs.ref || github.sha }}merge-multiple: truepath: native- name: Upload universal native payloaduses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2with:- name: native-universal-${{ github.sha }}+ name: native-universal-${{ inputs.ref || github.sha }}path: native/if-no-files-found: erroroverwrite: truediff --git a/.github/workflows/native-musl.yml b/.github/workflows/native-musl.ymlindex 38f575a1b..37518958c 100644--- a/.github/workflows/native-musl.yml+++ b/.github/workflows/native-musl.yml@@ -2,6 +2,11 @@ name: native-muslon:workflow_call:+ inputs:+ ref:+ description: Source commit to build; defaults to the calling workflow commit.+ type: string+ default: ""permissions:contents: read@@ -37,6 +42,7 @@ jobs:- name: Checkout repositoryuses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:+ ref: ${{ inputs.ref || github.sha }}persist-credentials: false- name: Set up TypeScript toolsuses: ./.github/actions/setup-tools@@ -98,7 +104,7 @@ jobs:- name: Upload verified native artifactuses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2with:- name: native-platform-linux-${{ matrix.arch }}-musl-${{ github.sha }}+ name: native-platform-linux-${{ matrix.arch }}-musl-${{ inputs.ref || github.sha }}path: plugins/codex-security/native/dist/*/*.nodeif-no-files-found: erroroverwrite: truediff --git a/.github/workflows/native-unix.yml b/.github/workflows/native-unix.ymlindex ffc031cf3..fd2a93a33 100644--- a/.github/workflows/native-unix.yml+++ b/.github/workflows/native-unix.yml@@ -2,6 +2,11 @@ name: native-unixon:workflow_call:+ inputs:+ ref:+ description: Source commit to build; defaults to the calling workflow commit.+ type: string+ default: ""permissions:contents: read@@ -43,6 +48,7 @@ jobs:- name: Checkout repositoryuses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:+ ref: ${{ inputs.ref || github.sha }}persist-credentials: false- name: Set up TypeScript toolsuses: ./.github/actions/setup-tools@@ -120,7 +126,7 @@ jobs:- name: Upload verified native artifactuses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2with:- name: native-platform-${{ matrix.artifact }}-${{ github.sha }}+ name: native-platform-${{ matrix.artifact }}-${{ inputs.ref || github.sha }}path: |plugins/codex-security/native/dist/*/*.nodeplugins/codex-security/native/dist/THIRD_PARTY_NOTICES.txtdiff --git a/.github/workflows/native-windows.yml b/.github/workflows/native-windows.ymlindex 836371e85..c7ad3b39f 100644--- a/.github/workflows/native-windows.yml+++ b/.github/workflows/native-windows.yml@@ -2,6 +2,11 @@ name: native-windowson:workflow_call:+ inputs:+ ref:+ description: Source commit to build; defaults to the calling workflow commit.+ type: string+ default: ""permissions:contents: read@@ -31,6 +36,7 @@ jobs:- name: Checkout repositoryuses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:+ ref: ${{ inputs.ref || github.sha }}persist-credentials: false- name: Set up TypeScript toolsuses: ./.github/actions/setup-tools@@ -99,7 +105,7 @@ jobs:- name: Upload verified native artifactuses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2with:- name: native-platform-win32-${{ matrix.arch }}-${{ github.sha }}+ name: native-platform-win32-${{ matrix.arch }}-${{ inputs.ref || github.sha }}path: plugins/codex-security/native/dist/*/*.nodeif-no-files-found: erroroverwrite: truediff --git a/.github/workflows/node-github-release.yml b/.github/workflows/node-github-release.ymlindex 75fc6faa4..b85813446 100644--- a/.github/workflows/node-github-release.yml+++ b/.github/workflows/node-github-release.yml@@ -34,6 +34,7 @@ jobs:sha: ${{ steps.release.outputs.sha }}integrity: ${{ steps.artifact.outputs.integrity }}has-action: ${{ steps.action.outputs.present }}+ has-container: ${{ steps.container.outputs.present }}steps:- name: Checkout release automation@@ -372,6 +373,21 @@ jobs:echo 'present=true' >> "$GITHUB_OUTPUT"fi+ - name: Detect container release source+ id: container+ env:+ RELEASE_SHA: ${{ steps.release.outputs.sha }}+ RELEASE_VERSION: ${{ steps.release.outputs.version }}+ run: |+ # Coordinated container publication starts at 0.5.0. Earlier releases+ # use older container/native build contracts and retain npm/Action recovery.+ if [[ "$RELEASE_VERSION" =~ ^0\.[0-4]\. ]]; then+ exit 0+ fi+ if git cat-file -e "$RELEASE_SHA:Dockerfile" 2>/dev/null; then+ echo 'present=true' >> "$GITHUB_OUTPUT"+ fi+- name: Resolve published release historyid: historyshell: bash@@ -712,10 +728,24 @@ jobs:printf 'Action: `uses: %s@%s` (`action-v%s`)\n' "$GITHUB_REPOSITORY" "$(git rev-parse HEAD)" "$RELEASE_VERSION"} >> "$GITHUB_STEP_SUMMARY"+ container:+ name: publish matching container+ needs: [release, installed]+ if: needs.release.outputs.has-container == 'true'+ permissions:+ contents: read+ packages: write+ attestations: write+ id-token: write+ uses: ./.github/workflows/container-release.yml+ with:+ release-sha: ${{ needs.release.outputs.sha }}+ release-version: ${{ needs.release.outputs.version }}+complete:name: release statusif: always()- needs: [release, installed, action]+ needs: [release, installed, action, container]runs-on: ubuntu-lateststeps:- name: Require completed release channels@@ -724,9 +754,14 @@ jobs:INSTALL_RESULT: ${{ needs.installed.result }}ACTION_RESULT: ${{ needs.action.result }}HAS_ACTION: ${{ needs.release.outputs.has-action }}+ CONTAINER_RESULT: ${{ needs.container.result }}+ HAS_CONTAINER: ${{ needs.release.outputs.has-container }}run: |test "$RELEASE_RESULT" = successtest "$INSTALL_RESULT" = successif [[ "$HAS_ACTION" == true ]]; thentest "$ACTION_RESULT" = successfi+ if [[ "$HAS_CONTAINER" == true ]]; then+ test "$CONTAINER_RESULT" = success+ fidiff --git a/RELEASING.md b/RELEASING.mdindex 4d87b3f8f..360e8b82e 100644--- a/RELEASING.md+++ b/RELEASING.md@@ -268,7 +268,7 @@ for that exact commit:manifest and SBOM attached before publication makes those assets immutable.The companion links to the `npm-vX.Y.Z` changelog and lists the full Actiondistribution commit SHA. It is never marked Latest. A final status job- reports publication, installation smoke, and Action results.+ reports publication, installation smoke, Action, and container results.The Action tag points to a generated distribution commit whose parent is theCLI release commit. That additional commit contains the runnable Action bundle@@ -293,14 +293,28 @@ do not prepare a release by editing or committing files there.Monitor all three workflows and the final status in `node-github-release`.A release is complete when npm and GitHub publication, exact-version install-checks, and applicable Action publication have succeeded. The protected npm-publication gates and immutable `npm-vX.Y.Z` tag remain in place.--Container publication currently has its own workflow and approval. It uses-`container-vX.Y.Z` or a manual `container-release` run on `main`, with the version-matching the SDK package. It is not part of the coordinated npm and Action-completion status. See [Container releases](docker/README.md) for its-publication and verification steps.+checks, and applicable Action and container publication have succeeded. The+protected npm publication gates and immutable `npm-vX.Y.Z` tag remain in place.++After the installed-package checks pass, `node-github-release` calls+`container-release` with the verified npm version and source commit. Native+binaries, Docker builds, OCI revision labels, and image tags all use that commit,+including when the release is older than `main`. Publication still requires+approval in the protected `container` environment. The final status waits for+both architectures, public pulls, attestation, and stable tag promotion.+Coordinated container publication starts at 0.5.0. Earlier releases use older+container and native build contracts, so their recovery runs continue to publish+npm and the Action without requiring this container pipeline. Sources without a+Dockerfile also skip container publication.++To publish a missing container for an existing npm release, dispatch+`node-github-release` on `main` with its `npm-vX.Y.Z` tag and approve the container+deployment after validation. Recovery verifies and reuses an existing container+only when its version, source commit, architectures, attestation, public pull, and+immutable tag checks pass. It does not rebuild or overwrite that version.+Standalone `container-vX.Y.Z` and manual `container-release` triggers remain+available.+See [Container releases](docker/README.md) for publication and verification.## Verify@@ -312,6 +326,8 @@ Check the published state before announcing the release:- The npm GitHub Release is stable, has the correct title, and contains oneverified npm package archive.- The exact-version published installation checks succeeded.+- For releases at or after 0.5.0 with a Dockerfile, container publication+ succeeded and the version tag is publicly pullable on Linux `amd64` and `arm64`.- For releases with the Action, `action-vX.Y.Z` points to the distributioncommit recorded in its manifest, whose parent is the CLI release commit.Its companion GitHub Release contains the manifest and SBOM, links to thediff --git a/docker/README.md b/docker/README.mdindex 644703067..bd1d01a01 100644--- a/docker/README.md+++ b/docker/README.md@@ -82,11 +82,31 @@ and [package access settings](https://docs.github.com/en/packages/learn-github-p## Publishing-After merging to `main`, push `container-v<version>` matching the SDK package-version or run `container-release` manually on `main`. Releases require a commit-on protected `main`; pull requests only build and test.--If a release fails, fix the cause and rerun only failed jobs. Promotion retries+Starting with 0.5.0, the coordinated `node-github-release` workflow calls+`container-release` after verifying the published npm package and its installation. It supplies the npm+release version and exact source commit; native binaries and Docker images are+built from that source even when `main` has advanced. Approve the `container`+environment deployment after validation. The coordinated release cannot finish+successfully until the container has been published and verified.++To backfill a missing image, dispatch `node-github-release` on `main` with the+existing `npm-v<version>` tag for version 0.5.0 or later. Earlier release recovery+skips the new container pipeline because those source trees use older build+contracts. Standalone publication also supports pushing+`container-v<version>` matching the SDK package version, or running+`container-release` manually on `main`. Releases require a commit on protected+`main`; pull requests only build and test.++BuildKit provenance and OCI revision labels identify the source checkout. The+GitHub attestation identifies the workflow run that built and promoted the image;+for a coordinated backfill, that automation can be newer than the release source.++If the version already exists, the workflow verifies its source revision,+architectures, GitHub attestation, anonymous pull, and immutable tags, then reuses+it without approval or publication. A mismatched image fails recovery.++If a release fails, fix the cause and rerun failed jobs, or dispatch recovery on+`main` to use updated automation. Promotion retriesrequire the existing stable version to reference the verified digest. If a newerstable version exists, promotion leaves `latest` untouched; otherwise a retryalso requires `latest` to reference that digest. `bootstrap` anddiff --git a/sdk/typescript/tests-ts/action-release-workflow.test.ts b/sdk/typescript/tests-ts/action-release-workflow.test.tsindex 509169705..1e844f89a 100644--- a/sdk/typescript/tests-ts/action-release-workflow.test.ts+++ b/sdk/typescript/tests-ts/action-release-workflow.test.ts@@ -55,6 +55,7 @@ const reuse = script("Reuse an existing immutable Action distribution",);const detect = script("release", "Detect Action release source");+const detectContainer = script("release", "Detect container release source");const complete = script("complete", "Require completed release channels");const publish = script("action", "Publish immutable Action tag and metadata");const directories: string[] = [];@@ -883,6 +884,65 @@ test.each([INSTALL_RESULT: installResult,ACTION_RESULT: actionResult,HAS_ACTION: hasAction,+ CONTAINER_RESULT: "success",+ HAS_CONTAINER: "true",+ });+ expect(result.status === 0).toBe(succeeds);+ },+);++test("detects container support from the release commit, not the automation checkout", () => {+ const release = fixture();+ release.write("Dockerfile", "FROM scratch\n");+ const containerSource = release.commit("Add container");+ expect(release.run(detectContainer).output).toBe("");+ expect(+ release.run(detectContainer, { RELEASE_SHA: containerSource }).output,+ ).toBe("present=true\n");+});++test.each([+ ["0.1.26", false],+ ["0.4.0", false],+ ["0.5.0", true],+ ["0.10.0", true],+ ["1.0.0", true],+] as const)(+ "preserves historical recovery before coordinated containers: %s",+ (version, included) => {+ const release = fixture();+ release.write("Dockerfile", "FROM scratch\n");+ release.updateJson("sdk/typescript/package.json", (value) => ({+ ...value,+ version,+ }));+ const source = release.commit("Add container source");+ expect(+ release.run(detectContainer, {+ RELEASE_SHA: source,+ RELEASE_VERSION: version,+ }).output,+ ).toBe(included ? "present=true\n" : "");+ },+);++test.each([+ ["success", "true", true],+ ["failure", "true", false],+ ["cancelled", "true", false],+ ["skipped", "true", false],+ ["skipped", "", true],+] as const)(+ "requires container publication when present: result=%s present=%s",+ (containerResult, hasContainer, succeeds) => {+ const release = fixture();+ const result = release.run(complete, {+ RELEASE_RESULT: "success",+ INSTALL_RESULT: "success",+ ACTION_RESULT: "success",+ HAS_ACTION: "true",+ CONTAINER_RESULT: containerResult,+ HAS_CONTAINER: hasContainer,});expect(result.status === 0).toBe(succeeds);},diff --git a/sdk/typescript/tests-ts/container-ci-workflow.test.ts b/sdk/typescript/tests-ts/container-ci-workflow.test.tsindex f4445d56b..24b4a3694 100644--- a/sdk/typescript/tests-ts/container-ci-workflow.test.ts+++ b/sdk/typescript/tests-ts/container-ci-workflow.test.ts@@ -71,11 +71,14 @@ test("keeps container validation available to forks and publication upstream-onlexpect(container.jobs["native"]).not.toHaveProperty("if");expect(container.jobs["container"]).not.toHaveProperty("if");expect(validation.jobs["validate"]).not.toHaveProperty("if");- for (const name of ["native", "validate", "authorize"]) {+ for (const name of ["source", "validate", "authorize"]) {expect(release.jobs[name]?.if).toBe("github.repository == 'openai/codex-security'",);}+ expect(release.jobs["native"]?.if).toBe(+ "github.repository == 'openai/codex-security' && needs.source.outputs.existing-digest == ''",+ );expect(release.jobs["publish-platform"]?.needs).toBe("authorize");});diff --git a/sdk/typescript/tests-ts/container-release-workflow.test.ts b/sdk/typescript/tests-ts/container-release-workflow.test.tsnew file mode 100644index 000000000..6601ebe98--- /dev/null+++ b/sdk/typescript/tests-ts/container-release-workflow.test.ts@@ -0,0 +1,395 @@+import { afterEach, expect, test } from "bun:test";+import { execFileSync } from "node:child_process";+import {+ copyFileSync,+ mkdirSync,+ mkdtempSync,+ readFileSync,+ rmSync,+ writeFileSync,+} from "node:fs";+import { tmpdir } from "node:os";+import { delimiter, join } from "node:path";+import { runWorkflowScript } from "./support/workflow-script.js";++type Step = {+ name: string;+ uses?: string;+ run?: string;+ with?: Record<string, string | boolean>;+};+type Job = {+ needs?: string | string[];+ uses?: string;+ if?: string;+ environment?: string;+ permissions?: Record<string, string>;+ with?: Record<string, string>;+ steps?: Step[];+};+function workflow(name: string) {+ return Bun.YAML.parse(+ readFileSync(+ new URL(`../../../.github/workflows/${name}.yml`, import.meta.url),+ "utf8",+ ),+ ) as { jobs: Record<string, Job> };+}+const release = workflow("container-release");+const directories: string[] = [];+afterEach(() => {+ for (const directory of directories.splice(0))+ rmSync(directory, { recursive: true, force: true });+});++function fixture() {+ const directory = mkdtempSync(join(tmpdir(), "container release "));+ directories.push(directory);+ const repository = join(directory, "source");+ mkdirSync(join(repository, "sdk/typescript"), { recursive: true });+ const output = join(directory, "output");+ function git(...args: string[]) {+ return execFileSync(+ "git",+ [+ "-c",+ "user.name=Release Test",+ "-c",+ "[email protected]",+ "-c",+ "commit.gpgsign=false",+ ...args,+ ],+ { cwd: repository, encoding: "utf8", stdio: "pipe" },+ ).trim();+ }+ function commit(version: string) {+ writeFileSync(+ join(repository, "sdk/typescript/package.json"),+ JSON.stringify({ version }),+ );+ git("add", ".");+ git("commit", "-m", `Release ${version}`);+ return git("rev-parse", "HEAD");+ }+ git("init", "-b", "main");+ const source = commit("99.1.2");+ git("tag", "npm-v99.1.2");+ const automation = commit("99.2.0");+ git("remote", "add", "origin", repository);+ function run(env: Record<string, string> = {}) {+ writeFileSync(output, "");+ const result = runWorkflowScript(+ repository,+ release.jobs["source"]!.steps![1]!.run,+ {+ GITHUB_OUTPUT: output.replaceAll("\\", "/"),+ GITHUB_REPOSITORY_OWNER: "Example",+ GITHUB_SHA: automation,+ GITHUB_EVENT_NAME: "workflow_dispatch",+ GITHUB_REF: "refs/heads/main",+ GITHUB_REF_NAME: "main",+ RELEASE_SHA: source,+ RELEASE_VERSION: "99.1.2",+ ...env,+ },+ );+ return { ...result, output: readFileSync(output, "utf8") };+ }+ return { directory, repository, source, automation, git, commit, run };+}++test("backfills the tagged release after main has advanced", () => {+ const { run, source } = fixture();+ const result = run();+ expect(result.status, result.stderr).toBe(0);+ expect(result.output).toContain(`sha=${source}\n`);+ expect(result.output).toContain("version=99.1.2\n");+});++test("rejects a different commit with the same package version", () => {+ const source = fixture();+ const different = source.commit("99.1.2");+ const result = source.run({ RELEASE_SHA: different });+ expect(result.status).not.toBe(0);+ expect(result.stderr).toContain("immutable npm release tag");+});++test("rejects source outside protected main", () => {+ const source = fixture();+ source.git("checkout", "-b", "unmerged", source.source);+ const unmerged = source.commit("99.3.0");+ source.git("tag", "npm-v99.3.0");+ source.git("checkout", "main");+ const result = source.run({+ RELEASE_SHA: unmerged,+ RELEASE_VERSION: "99.3.0",+ });+ expect(result.status).not.toBe(0);+ expect(result.stderr).toContain("protected main branch");+});++test("rejects a release tag whose version differs from the package", () => {+ const source = fixture();+ source.git("tag", "npm-v99.3.0", source.source);+ const result = source.run({ RELEASE_VERSION: "99.3.0" });+ expect(result.status).not.toBe(0);+ expect(result.stderr).toContain("must match the CLI package version");+});++test.each(["refs/heads/feature", "refs/tags/npm-v99.1.2"])(+ "rejects coordinated publication from %s",+ (ref) => {+ const result = fixture().run({ GITHUB_REF: ref });+ expect(result.status).not.toBe(0);+ expect(result.stderr).toContain("must run on main");+ },+);++test("preserves standalone manual and container tag source selection", () => {+ const source = fixture();+ const manual = source.run({ RELEASE_SHA: "", RELEASE_VERSION: "" });+ expect(manual.status, manual.stderr).toBe(0);+ expect(manual.output).toContain(`sha=${source.automation}\n`);+ expect(manual.output).toContain("version=99.2.0\n");+ const tagged = source.run({+ RELEASE_SHA: "",+ RELEASE_VERSION: "",+ GITHUB_SHA: source.source,+ GITHUB_EVENT_NAME: "push",+ GITHUB_REF: "refs/tags/container-v99.1.2",+ GITHUB_REF_NAME: "container-v99.1.2",+ });+ expect(tagged.status, tagged.stderr).toBe(0);+ expect(tagged.output).toContain(`sha=${source.source}\n`);+});++test("coordinates publication, approval, and completion with the verified npm source", () => {+ const parent = workflow("node-github-release");+ expect(parent.jobs["container"]).toMatchObject({+ needs: ["release", "installed"],+ if: "needs.release.outputs.has-container == 'true'",+ uses: "./.github/workflows/container-release.yml",+ with: {+ "release-sha": "${{ needs.release.outputs.sha }}",+ "release-version": "${{ needs.release.outputs.version }}",+ },+ permissions: {+ contents: "read",+ packages: "write",+ attestations: "write",+ "id-token": "write",+ },+ });+ expect(parent.jobs["complete"]?.needs).toContain("container");+ expect(release.jobs["authorize"]).toMatchObject({+ needs: ["source", "validate"],+ environment: "container",+ permissions: { contents: "read", packages: "read" },+ });+ expect(release.jobs["publish-platform"]?.needs).toBe("authorize");+ expect(release.jobs["promote"]?.needs).toContain("attest");+});++test("builds and downloads native payloads from the same source as the image", () => {+ expect(release.jobs["native"]?.with?.["ref"]).toBe(+ "${{ needs.source.outputs.sha }}",+ );+ expect(release.jobs["validate"]?.with?.["ref"]).toBe(+ "${{ needs.source.outputs.sha }}",+ );+ const native = workflow("native-artifacts");+ for (const platform of ["unix", "windows", "musl"]) {+ expect(native.jobs[platform]?.with?.["ref"]).toBe(+ "${{ inputs.ref || github.sha }}",+ );+ const steps = workflow(`native-${platform}`).jobs["primitives"]!.steps!;+ expect(steps[0]?.with?.["ref"]).toBe("${{ inputs.ref || github.sha }}");+ expect(steps.at(-1)?.with?.["name"]).toContain(+ "${{ inputs.ref || github.sha }}",+ );+ }+ expect(native.jobs["bundle"]!.steps![0]?.with?.["pattern"]).toBe(+ "native-platform-*-${{ inputs.ref || github.sha }}",+ );+ expect(native.jobs["bundle"]!.steps![1]?.with?.["name"]).toBe(+ "native-universal-${{ inputs.ref || github.sha }}",+ );+ for (const job of ["publish-platform", "manifest"]) {+ expect(release.jobs[job]!.steps![0]?.with?.["ref"]).toBe(+ "${{ needs.authorize.outputs.sha }}",+ );+ }+ for (const job of ["authorize", "promote"]) {+ expect(release.jobs[job]!.steps![0]?.with?.["ref"]).toBe(+ "${{ github.sha }}",+ );+ }+ const buildSteps = release.jobs["publish-platform"]!.steps!;+ expect(+ buildSteps.find((step) => step.name === "Prepare native runtime")?.with?.[+ "name"+ ],+ ).toBe("native-universal-${{ needs.authorize.outputs.sha }}");+ const validation = workflow("container-validate").jobs["validate"]!.steps!;+ expect(validation[0]?.with?.["ref"]).toBe("${{ inputs.ref || github.sha }}");+ expect(validation[1]?.with?.["name"]).toBe(+ "native-universal-${{ inputs.ref || github.sha }}",+ );+});++const digest = `sha256:${"a".repeat(64)}`;+function existingFixture() {+ const source = fixture();+ const bin = join(source.directory, "bin");+ const events = join(source.directory, "events");+ const output = join(source.directory, "reuse-output");+ mkdirSync(bin);+ mkdirSync(join(source.repository, "docker"));+ copyFileSync(+ new URL(+ "../../../docker/verify-container-release-version.sh",+ import.meta.url,+ ),+ join(source.repository, "docker/verify-container-release-version.sh"),+ );+ writeFileSync(+ join(bin, "gh"),+ `#!/bin/sh+case "$1" in+ api) printf '%s\\n' "$MOCK_VERSIONS"; exit "$MOCK_API_STATUS" ;;+ attestation) printf '%s\\n' "$*" >> "$EVENTS"; exit "$MOCK_ATTESTATION_STATUS" ;;+ *) exit 99 ;;+esac+`,+ { mode: 0o755 },+ );+ writeFileSync(+ join(bin, "docker"),+ `#!/bin/sh+printf '%s\\n' "$*" >> "$EVENTS"+case "$1" in+ buildx) printf '%s\\n' "$MOCK_MANIFEST" ;;+ pull|run) exit "$MOCK_DOCKER_STATUS" ;;+ *) exit 99 ;;+esac+`,+ { mode: 0o755 },+ );+ const manifest = {+ annotations: {+ "org.opencontainers.image.version": "99.1.2",+ "org.opencontainers.image.revision": source.source,+ },+ manifests: ["amd64", "arm64"].map((architecture) => ({+ platform: { os: "linux", architecture },+ })),+ };+ const script = release.jobs["source"]!.steps!.find(+ (step) => step.name === "Verify an existing immutable container release",+ )!.run;+ function run(env: Record<string, string> = {}) {+ writeFileSync(events, "");+ writeFileSync(output, "");+ const result = runWorkflowScript(source.repository, script, {+ PATH: `${bin}${delimiter}${process.env["PATH"]}`,+ EVENTS: events.replaceAll("\\", "/"),+ GITHUB_OUTPUT: output.replaceAll("\\", "/"),+ GITHUB_REPOSITORY: "example/project",+ GITHUB_REPOSITORY_OWNER: "Example",+ IMAGE: "ghcr.io/example/codex-security",+ VERSION: "99.1.2",+ RELEASE_SHA: source.source,+ MOCK_VERSIONS: JSON.stringify([+ {+ name: digest,+ metadata: {+ container: { tags: ["99.1.2", "latest", `sha-${source.source}`] },+ },+ },+ ]),+ MOCK_MANIFEST: JSON.stringify(manifest),+ MOCK_API_STATUS: "0",+ MOCK_ATTESTATION_STATUS: "0",+ MOCK_DOCKER_STATUS: "0",+ ...env,+ });+ return {+ ...result,+ output: readFileSync(output, "utf8"),+ events: readFileSync(events, "utf8"),+ };+ }+ return { run, manifest, source: source.source };+}++test("verifies and reuses the published source without a registry write", () => {+ const { run } = existingFixture();+ const result = run();+ expect(result.status, result.stderr).toBe(0);+ expect(result.output).toContain(`digest=${digest}\n`);+ expect(result.events.trim().split("\n")).toEqual([+ `buildx imagetools inspect ghcr.io/example/codex-security@${digest} --raw`,+ `attestation verify oci://ghcr.io/example/codex-security@${digest} --repo example/project`,+ `pull ghcr.io/example/codex-security@${digest}`,+ `run --rm ghcr.io/example/codex-security@${digest} --version`,+ ]);+});++test("leaves an unpublished version on the build and approval path", () => {+ const result = existingFixture().run({ MOCK_VERSIONS: "[]" });+ expect(result.status, result.stderr).toBe(0);+ expect(result.output).toBe("");+ expect(result.events).toBe("");+});++test.each(["MOCK_API_STATUS", "MOCK_ATTESTATION_STATUS", "MOCK_DOCKER_STATUS"])(+ "does not reuse an image when %s fails",+ (variable) => {+ const result = existingFixture().run({ [variable]: "1" });+ expect(result.status).not.toBe(0);+ expect(result.output).not.toContain("digest=");+ },+);++test.each(["source", "version", "architecture"] as const)(+ "rejects published container %s mismatches",+ (field) => {+ const { run, manifest } = existingFixture();+ if (field === "source")+ manifest.annotations["org.opencontainers.image.revision"] = "b".repeat(+ 40,+ );+ if (field === "version")+ manifest.annotations["org.opencontainers.image.version"] = "99.1.1";+ if (field === "architecture") manifest.manifests.pop();+ const result = run({ MOCK_MANIFEST: JSON.stringify(manifest) });+ expect(result.status).not.toBe(0);+ expect(result.output).toBe("");+ },+);++test("does not reuse a version whose latest tag is incomplete", () => {+ const { run, source } = existingFixture();+ const result = run({+ MOCK_VERSIONS: JSON.stringify([+ {+ name: digest,+ metadata: { container: { tags: ["99.1.2", `sha-${source}`] } },+ },+ ]),+ });+ expect(result.status).not.toBe(0);+ expect(result.stderr).toContain("matching latest tag");+ expect(result.output).not.toContain("digest=");+});++test("does not reuse a version missing its source commit tag", () => {+ const result = existingFixture().run({+ MOCK_VERSIONS: JSON.stringify([+ { name: digest, metadata: { container: { tags: ["99.1.2", "latest"] } } },+ ]),+ });+ expect(result.status).not.toBe(0);+ expect(result.output).toBe("");+});