name: Modern.js Release # The publish half of a release. The packages were built, tested and packed by # release-build.yml on the staging branch, and everything downstream - EdenX in # another repository among it - was built and tested against those exact # tarballs before this branch was ever created. This workflow therefore builds # nothing: it re-verifies the prepared source and the plan, fetches the # artifacts that one build produced for this very commit, and publishes them. # # This file stays the one npm trusts, so the publishing identity does not move # and the per-package Trusted Publishing bindings keep working. on: push: # One prefix per release channel. The prefix is not a label: the plan on the # branch names its channel, and release.mjs refuses to run unless the ref it # was triggered on is exactly the branch that channel prescribes for that # release id. A push to any other release-*/ branch therefore starts a run # that stops at the first step instead of publishing anything. # No path filter. The branch is created pointing at the commit the build # ran on, and a push that creates a branch at a commit the repository # already has carries no file changes for a filter to match - the # workflow simply never started. Every push to this namespace therefore # starts a run, and the run stops at its first assertion unless the # branch is the one the plan prescribes. branches: ['release-*/**'] workflow_dispatch: inputs: expected_plan_hash: description: SHA256 of stableStringify(plan) for this prepared branch required: true type: string reconcile: description: >- Finish a release whose publish stopped part way. The registry is asked which versions of this release it already serves and only the rest are published; a version it serves with other contents stops the run. required: false default: false type: boolean permissions: contents: read concurrency: group: modern-release-${{ github.ref }} cancel-in-progress: false jobs: publish: # The version-bump branch lives in the same namespace and publishes # nothing, so it is skipped rather than started and failed. if: startsWith(github.ref, 'refs/heads/release-') && !endsWith(github.ref, '-bump') runs-on: ubuntu-24.04 timeout-minutes: 45 # npm trusts this job only inside this environment, and the repository # lets only release-/ branches deploy to it. Those branches can # be created by the release App alone (repository ruleset), so a branch # pushed by anyone else - with an edited copy of this file or of the # scripts - gets no identity npm accepts. The checks in release.mjs remain # as well; this is the part GitHub and npm enforce on their own. environment: npm-release permissions: contents: read actions: read id-token: write steps: - name: Checkout exact source uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with: ref: ${{ github.sha }} fetch-depth: 0 persist-credentials: false - name: Set up Node uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 with: node-version: '24.21.0' - name: Install pinned clients without repository dependencies run: npm install --global npm@11.21.0 pnpm@10.13.1 --ignore-scripts # The contract tests run in the build workflow, which needs the # repository dependencies for Rstest. This job installs none on purpose: # it holds the OIDC token, and it only publishes artifacts that build # packed and tested for this exact commit. - name: Verify prepared source and plan id: plan env: EXPECTED_PLAN_HASH: ${{ inputs.expected_plan_hash }} run: node scripts/canary-release/release.mjs verify --expected-plan-hash "$EXPECTED_PLAN_HASH" - name: Find the build this release was approved with # Not the newest build of the commit: the one named by the # release-approval/ tag the pipeline wrote at its gate. id: build env: GITHUB_TOKEN: ${{ github.token }} run: node scripts/canary-release/release.mjs locate-build - name: Download that build's verified artifacts # Verified via GitHub API: actions/download-artifact git/ref/tags/v4. uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 with: name: canary-tarballs-${{ steps.build.outputs.build_run_id }}-${{ steps.build.outputs.build_run_attempt }} path: .release/artifacts run-id: ${{ steps.build.outputs.build_run_id }} github-token: ${{ github.token }} - name: Upload the manifest for the trigger client # The client reads what was published from the run that published it, # so this travels with the publish as well as with the build. uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with: name: canary-manifest-${{ steps.plan.outputs.release_id }} path: .release/artifacts/manifest.json include-hidden-files: true if-no-files-found: error retention-days: 30 - name: Verify all artifacts and publish through OIDC env: EXPECTED_PLAN_HASH: ${{ steps.plan.outputs.plan_hash }} MANIFEST_SHA256: ${{ steps.build.outputs.manifest_sha256 }} RECONCILE: ${{ inputs.reconcile }} run: | if [ "${RECONCILE:-false}" = "true" ]; then node scripts/canary-release/release.mjs publish --expected-plan-hash "$EXPECTED_PLAN_HASH" --manifest-sha256 "$MANIFEST_SHA256" --reconcile else node scripts/canary-release/release.mjs publish --expected-plan-hash "$EXPECTED_PLAN_HASH" --manifest-sha256 "$MANIFEST_SHA256" fi - name: Persist publish receipts even on partial failure if: always() uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with: name: canary-receipts-${{ github.run_id }}-${{ github.run_attempt }} path: .release/receipts/*.json include-hidden-files: true if-no-files-found: error retention-days: 30