name: node-release on: push: tags: - "npm-v*" workflow_dispatch: concurrency: group: ${{ github.workflow }} queue: max jobs: recover-native: name: native / recover verified artifacts needs: eligibility if: needs.eligibility.outputs.mode == 'recover' permissions: contents: read uses: ./.github/workflows/native-artifacts.yml eligibility: if: github.repository == 'openai/codex-security' name: release tests / release eligibility runs-on: ubuntu-latest permissions: actions: read contents: read env: &release-environment NPM_CONFIG_REGISTRY: https://openai.firewall.socket.dev/npm/ PNPM_CONFIG_REGISTRY: https://openai.firewall.socket.dev/npm/ COREPACK_NPM_REGISTRY: https://openai.firewall.socket.dev/npm/ BUN_CONFIG_REGISTRY: https://openai.firewall.socket.dev/npm/ outputs: mode: ${{ steps.release.outputs.mode }} version: ${{ steps.release.outputs.version }} steps: - &checkout-release name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false - &setup-release-firewall name: Set up Socket Firewall uses: SocketDev/action@ba6de6cc0565af1f42295590380973573297e31f # v1.3.2 with: mode: firewall-free firewall-version: "1.15.4" - &setup-release-node name: Set up Node.js uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: "22.13.0" package-manager-cache: false - &activate-release-firewall name: Activate Socket Firewall shell: bash run: | set -euo pipefail npm_registry="https://openai.firewall.socket.dev/npm/" pypi_registry="https://openai.firewall.socket.dev/pypi/simple/" { printf 'NPM_CONFIG_REGISTRY=%s\n' "$npm_registry" printf 'npm_config_registry=%s\n' "$npm_registry" printf 'PNPM_CONFIG_REGISTRY=%s\n' "$npm_registry" printf 'pnpm_config_registry=%s\n' "$npm_registry" printf 'COREPACK_NPM_REGISTRY=%s\n' "$npm_registry" printf 'YARN_NPM_REGISTRY_SERVER=%s\n' "$npm_registry" printf 'BUN_CONFIG_REGISTRY=%s\n' "$npm_registry" printf 'UV_DEFAULT_INDEX=%s\n' "$pypi_registry" printf 'UV_INDEX_URL=%s\n' "$pypi_registry" printf 'PIP_INDEX_URL=%s\n' "$pypi_registry" } >> "$GITHUB_ENV" - name: Validate release tag id: release shell: bash run: | set -euo pipefail git fetch origin main if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then echo "npm release tags must point to a commit on main." >&2 exit 1 fi version="$( node sdk/typescript/scripts/release-automation.mjs release-tag \ "$GITHUB_REF_TYPE" \ "$GITHUB_REF" \ "$GITHUB_REF_NAME" \ sdk/typescript/package.json )" if ! published_versions="$( sfw npm view @openai/codex-security versions --json )"; then echo "Unable to verify published npm release history." >&2 exit 1 fi mode="$( printf '%s\n' "$published_versions" | node sdk/typescript/scripts/release-automation.mjs \ release-mode "$version" )" if [[ "$mode" == "recover" ]]; then echo "Recovering the already-published npm release." fi { printf 'version=%s\n' "$version" printf 'mode=%s\n' "$mode" } >> "$GITHUB_OUTPUT" - name: Verify reusable signing workflow ref before signing if: steps.release.outputs.mode == 'publish' shell: bash env: GH_TOKEN: ${{ github.token }} run: &verify-signing-workflow-ref | set -euo pipefail # A tag named main takes precedence over the branch in a workflow call. if ! gh api "repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/attempts/$GITHUB_RUN_ATTEMPT" | jq -e --arg workflow "$GITHUB_REPOSITORY/.github/workflows/sign-darwin-release.yml@" ' [.referenced_workflows[] | select(.path | startswith($workflow)) | .ref] == ["refs/heads/main"] ' >/dev/null; then echo "The signed addons must come from the signing workflow on protected main." >&2 exit 1 fi - name: Validate reviewed release notes if: steps.release.outputs.mode == 'publish' shell: bash env: RELEASE_VERSION: ${{ steps.release.outputs.version }} run: | set -euo pipefail release_notes_file="$(mktemp)" trap 'rm -f "$release_notes_file"' EXIT if ! git show "$GITHUB_SHA:.github/release-notes.md" \ > "$release_notes_file" 2>/dev/null; then echo "The tagged commit must include .github/release-notes.md." >&2 exit 1 fi node sdk/typescript/scripts/release-automation.mjs \ validate-release-notes "$RELEASE_VERSION" "$release_notes_file" >/dev/null sign-darwin: name: native / sign Darwin addons needs: eligibility if: needs.eligibility.outputs.mode == 'publish' permissions: contents: read id-token: write uses: openai/codex-security/.github/workflows/sign-darwin-release.yml@main # zizmor: ignore[unpinned-uses] -- The signing policy requires this protected branch in job_workflow_ref. secrets: AKV_CODESIGN_RCODESIGN_BLOB_URI: ${{ secrets.AKV_CODESIGN_RCODESIGN_BLOB_URI }} AKV_CODESIGN_RCODESIGN_SHA256: ${{ secrets.AKV_CODESIGN_RCODESIGN_SHA256 }} AKV_CODESIGN_PKCS11_LIBRARY_BLOB_URI: ${{ secrets.AKV_CODESIGN_PKCS11_LIBRARY_BLOB_URI }} AKV_CODESIGN_PKCS11_LIBRARY_SHA256: ${{ secrets.AKV_CODESIGN_PKCS11_LIBRARY_SHA256 }} AKV_CODESIGN_AZURE_CLIENT_ID: ${{ secrets.AKV_CODESIGN_AZURE_CLIENT_ID }} AKV_CODESIGN_TENANT: ${{ secrets.AKV_CODESIGN_TENANT }} AKV_CODESIGN_SUBSCRIPTION: ${{ secrets.AKV_CODESIGN_SUBSCRIPTION }} SIGNER_SERVICE_ENDPOINT: ${{ secrets.SIGNER_SERVICE_ENDPOINT }} SIGNER_SERVICE_PURPOSE: ${{ secrets.SIGNER_SERVICE_PURPOSE }} SIGNER_SERVICE_KEY_ID: ${{ secrets.SIGNER_SERVICE_KEY_ID }} SIGNING_CERTIFICATE_PEM: ${{ secrets.SIGNING_CERTIFICATE_PEM }} native: name: native / select verified artifacts needs: [eligibility, recover-native, sign-darwin] if: >- !cancelled() && needs.eligibility.result == 'success' && ((needs.eligibility.outputs.mode == 'publish' && needs.sign-darwin.result == 'success' && needs.recover-native.result == 'skipped') || (needs.eligibility.outputs.mode == 'recover' && needs.recover-native.result == 'success' && needs.sign-darwin.result == 'skipped')) runs-on: ubuntu-latest permissions: actions: read outputs: artifact-id: ${{ steps.select.outputs.native-id }} signed-darwin-id: ${{ steps.select.outputs.signed-id }} steps: - name: Verify reusable signing workflow ref if: needs.eligibility.outputs.mode == 'publish' shell: bash env: GH_TOKEN: ${{ github.token }} run: *verify-signing-workflow-ref - name: Select the native artifact IDs for this release mode id: select env: RELEASE_MODE: ${{ needs.eligibility.outputs.mode }} PUBLISH_NATIVE_ID: ${{ needs.sign-darwin.outputs.native-artifact-id }} SIGNED_ID: ${{ needs.sign-darwin.outputs.artifact-id }} RECOVER_NATIVE_ID: ${{ needs.recover-native.outputs.artifact-id }} run: | set -euo pipefail if [[ "$RELEASE_MODE" == publish ]]; then test -n "$PUBLISH_NATIVE_ID" test -n "$SIGNED_ID" echo "native-id=$PUBLISH_NATIVE_ID" >> "$GITHUB_OUTPUT" echo "signed-id=$SIGNED_ID" >> "$GITHUB_OUTPUT" else test -n "$RECOVER_NATIVE_ID" echo "native-id=$RECOVER_NATIVE_ID" >> "$GITHUB_OUTPUT" fi verify: needs: [eligibility, native] if: >- !cancelled() && needs.eligibility.result == 'success' && needs.native.result == 'success' && (needs.eligibility.outputs.mode == 'recover' || needs.native.outputs.signed-darwin-id != '') runs-on: ubuntu-latest permissions: contents: read env: *release-environment outputs: artifact-id: ${{ steps.upload.outputs.artifact-id }} mode: ${{ needs.eligibility.outputs.mode }} version: ${{ needs.eligibility.outputs.version }} steps: - *checkout-release - &require-release-native name: Require the verified native artifact ID env: NATIVE_ARTIFACT_ID: ${{ needs.native.outputs.artifact-id }} run: test -n "$NATIVE_ARTIFACT_ID" - &download-release-native name: Download verified native payload uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: artifact-ids: ${{ needs.native.outputs.artifact-id }} path: plugins/codex-security/native/prebuilt merge-multiple: true digest-mismatch: error - name: Overlay signed Darwin addons for publication if: needs.eligibility.outputs.mode == 'publish' uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: artifact-ids: ${{ needs.native.outputs.signed-darwin-id }} path: plugins/codex-security/native/prebuilt merge-multiple: true digest-mismatch: error - *setup-release-firewall - *setup-release-node - *activate-release-firewall - &setup-release-bun name: Set up Bun uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 with: bun-version-file: .bun-version no-cache: true - &setup-release-pnpm name: Enable pnpm shell: bash run: corepack enable && corepack prepare "$(node -p 'require("./package.json").packageManager')" --activate - &install-release-dependencies name: Install dependencies run: | sfw pnpm --dir sdk/typescript install --frozen-lockfile sfw pnpm --dir plugins/codex-security/mcp-app install --frozen-lockfile - &install-release-ripgrep name: Install ripgrep run: .github/scripts/install-ripgrep.sh - name: Audit bundled MCP and tokenizer dependencies uses: ./.github/actions/audit-pnpm-lockfiles with: targets: mcp tokenizer - name: Audit production dependencies run: sfw pnpm --dir sdk/typescript run audit:prod - name: Verify run: | pnpm --dir sdk/typescript run types pnpm --dir sdk/typescript run format - name: Pack working-directory: sdk/typescript shell: bash run: | set -euo pipefail npm pkg set "gitHead=$GITHUB_SHA" pnpm pack --pack-destination ../../dist - name: Inspect package working-directory: sdk/typescript shell: bash env: CODEX_SECURITY_EXPECTED_GIT_HEAD: ${{ github.sha }} run: pnpm run check:package ../../dist/*.tgz - name: Recover the published npm release archive if: needs.eligibility.outputs.mode == 'recover' shell: bash env: RELEASE_VERSION: ${{ needs.eligibility.outputs.version }} run: | set -euo pipefail shopt -s nullglob built_archives=(dist/*.tgz) if (( ${#built_archives[@]} != 1 )); then echo "Expected exactly one verified local release tarball." >&2 exit 1 fi recovery="$(mktemp -d)" trap 'rm -rf "$recovery"' EXIT npm pack "@openai/codex-security@$RELEASE_VERSION" \ --ignore-scripts \ --pack-destination "$recovery" \ --registry=https://registry.npmjs.org/ published_archives=("$recovery"/*.tgz) if (( ${#published_archives[@]} != 1 )); then echo "Expected exactly one published npm release tarball." >&2 exit 1 fi metadata="$( npm view "@openai/codex-security@$RELEASE_VERSION" \ name version gitHead dist.integrity dist.attestations \ --json \ --registry=https://registry.npmjs.org/ )" printf '%s\n' "$metadata" | node sdk/typescript/scripts/release-automation.mjs \ verify-publication \ "${published_archives[0]}" \ "$RELEASE_VERSION" \ "$GITHUB_SHA" cp "${published_archives[0]}" "${built_archives[0]}" - name: Smoke test package shell: bash run: | set -euo pipefail consumer="$(mktemp -d)" trap 'rm -rf "$consumer"' EXIT printf '%s\n' '{"name":"codex-security-smoke","private":true,"type":"module"}' > "$consumer/package.json" sfw npm install --ignore-scripts --prefix "$consumer" --include=optional --no-audit --no-fund ./dist/*.tgz (cd "$consumer" && node --input-type=module --eval 'const sdk = await import("@openai/codex-security"); if (typeof sdk.CodexSecurity !== "function") process.exit(1);') "$consumer/node_modules/.bin/codex-security" --version "$consumer/node_modules/.bin/codex-security" --help "$consumer/node_modules/.bin/cs" --version "$consumer/node_modules/.bin/cs" --help - name: Check Action against the release candidate uses: ./.github/actions/check-action-candidate - name: Upload verified package id: upload uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: npm-release-tarball path: dist/*.tgz if-no-files-found: error retention-days: 30 compression-level: 0 test: needs: native if: ${{ !cancelled() && needs.native.result == 'success' }} name: release tests / ${{ matrix.suite }} runs-on: ubuntu-latest permissions: contents: read env: *release-environment strategy: fail-fast: false matrix: suite: [1, 2, 3, mcp] steps: - *checkout-release - *require-release-native - *download-release-native - *setup-release-firewall - *setup-release-node - *activate-release-firewall - *setup-release-bun - *setup-release-pnpm - *install-release-dependencies - *install-release-ripgrep - name: Build the plugin for TypeScript tests if: matrix.suite != 'mcp' run: pnpm --dir sdk/typescript run build:plugin - name: Test TypeScript shard if: matrix.suite != 'mcp' working-directory: sdk/typescript env: TEMP: ${{ runner.temp }} TMP: ${{ runner.temp }} TMPDIR: ${{ runner.temp }} CODEX_SECURITY_ALLOW_MACHINE_POLICY_TEST: "false" run: node --experimental-strip-types scripts/run-ci-tests.mts ${{ matrix.suite }}/3 - name: Test MCP app if: matrix.suite == 'mcp' run: pnpm --dir sdk/typescript run test:mcp - name: Upload test reports if: always() continue-on-error: true uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: release-tests-${{ matrix.suite }} path: | sdk/typescript/reports/junit-*.xml plugins/codex-security/mcp-app/reports/junit.xml if-no-files-found: warn retention-days: 14 macos-review-items: name: release tests / packaged macOS review items needs: verify if: >- !cancelled() && needs.verify.result == 'success' && needs.verify.outputs.mode == 'publish' && needs.verify.outputs.artifact-id != '' runs-on: macos-15 permissions: contents: read steps: - *checkout-release - &download-verified-package name: Download verified package uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: artifact-ids: ${{ needs.verify.outputs.artifact-id }} path: dist merge-multiple: true digest-mismatch: error - name: Exercise packaged review items on macOS arm64 shell: bash run: .github/scripts/test-macos-review-items.sh dist/*.tgz publish: needs: [verify, test, macos-review-items] if: >- !cancelled() && needs.verify.result == 'success' && needs.verify.outputs.artifact-id != '' && needs.test.result == 'success' && ((needs.verify.outputs.mode == 'publish' && needs.macos-review-items.result == 'success') || (needs.verify.outputs.mode == 'recover' && needs.macos-review-items.result == 'skipped')) name: ${{ needs.verify.outputs.mode == 'recover' && 'Verify existing npm release' || 'Publish npm and container images' }} runs-on: ubuntu-latest environment: npm permissions: contents: read id-token: write steps: - name: Checkout release verification source uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 1 persist-credentials: false - name: Set up release npm uses: ./.github/actions/setup-release-npm - *download-verified-package - name: Verify recovered npm release provenance if: needs.verify.outputs.mode == 'recover' shell: bash env: RELEASE_VERSION: ${{ needs.verify.outputs.version }} run: | set -euo pipefail shopt -s nullglob release_version="$RELEASE_VERSION" archives=(dist/*.tgz) if (( ${#archives[@]} != 1 )); then echo "Expected exactly one recovered npm release tarball." >&2 exit 1 fi archive="${archives[0]}" metadata="$( npm view "@openai/codex-security@$release_version" \ name version gitHead dist.integrity dist.attestations \ --json \ --registry=https://registry.npmjs.org/ )" printf '%s\n' "$metadata" | node sdk/typescript/scripts/release-automation.mjs \ verify-publication "$archive" "$release_version" "$GITHUB_SHA" consumer="$(mktemp -d)" trap 'rm -rf "$consumer"' EXIT npm install \ --prefix "$consumer" \ --ignore-scripts \ --omit=optional \ --no-audit \ --no-fund \ --registry=https://registry.npmjs.org/ \ "@openai/codex-security@$release_version" npm audit signatures \ --prefix "$consumer" \ --registry=https://registry.npmjs.org/ \ --json \ --include-attestations | node sdk/typescript/scripts/release-automation.mjs \ verify-recovered-provenance \ "$archive" \ "$release_version" \ "$GITHUB_SHA" \ "$GITHUB_REPOSITORY" - name: Revalidate protected release tag if: needs.verify.outputs.mode == 'publish' uses: $/.github/actions/revalidate-release-tag - name: Publish to npm using trusted publishing if: needs.verify.outputs.mode == 'publish' run: npm publish ./dist/*.tgz --provenance --access public --tag latest dispatch-github-release: if: ${{ !cancelled() && needs.publish.result == 'success' }} name: dispatch GitHub release needs: publish runs-on: ubuntu-latest permissions: actions: write steps: - name: Dispatch the verified GitHub release id: dispatch shell: bash env: GH_TOKEN: ${{ github.token }} RELEASE_TAG: ${{ github.ref_name }} RELEASE_RUN_ID: ${{ github.run_id }} run: | set -euo pipefail run_id="$(gh api --method POST \ -H 'X-GitHub-Api-Version: 2026-03-10' \ "repos/$GITHUB_REPOSITORY/actions/workflows/node-github-release.yml/dispatches" \ -f ref=main \ -f "inputs[tag]=$RELEASE_TAG" \ -f "inputs[run_id]=$RELEASE_RUN_ID" --jq '.workflow_run_id')" printf 'run-id=%s\n' "$run_id" >> "$GITHUB_OUTPUT" - name: Start release progress observer if: steps.dispatch.outputs.run-id != '' continue-on-error: true shell: bash env: GH_TOKEN: ${{ github.token }} RELEASE_RUN_ID: ${{ steps.dispatch.outputs.run-id }} run: | # The downstream resolver waits for this workflow to finish. Keep the # optional notification within its 60-second completion wait. timeout --kill-after=5s 10s gh workflow run release-progress.yml \ --repo "$GITHUB_REPOSITORY" --ref main \ -f "run-id=$RELEASE_RUN_ID" -f watch=true