# Release the mnfst packages to npm via GitHub Actions OIDC Trusted Publishing. # # No npm token is stored: npm mints a short-lived credential from the workflow's # OIDC identity at publish time, and provenance attestation is generated # automatically. One workflow serves every package; each package's npm Trusted # Publisher config uses the SAME fields: # Organization or user: Manifest-X Repository: Manifest # Workflow filename: release.yml Environment name: (blank) # # Trigger it two ways: # - Actions tab -> "Release (npm OIDC)" -> Run workflow -> pick a package / "all". # - Push a tag: v* -> mnfst, render-v* -> mnfst-render, run-v* -> mnfst-run, # publish-v* -> mnfst-publish, starter-v* -> mnfst-starter, # types-v* -> mnfst-types, test-v* -> mnfst-test, export-v* -> mnfst-export, # docs-v* -> mnfst-docs. # (Tags let an agent trigger a release over git without the GitHub UI.) # Nothing publishes unless test.yml passes on the tagged commit. # Version numbers are derived from the npm registry by scripts/release-bump.mjs; # the tag name is only a trigger, it does not set the version. name: Release (npm OIDC) on: workflow_dispatch: inputs: package: description: Which package to publish type: choice default: mnfst options: - mnfst - mnfst-render - mnfst-run - mnfst-types - mnfst-test - mnfst-export - mnfst-starter - mnfst-publish - mnfst-docs - all push: tags: - 'v*' # publishes mnfst - 'render-v*' # publishes mnfst-render - 'run-v*' # publishes mnfst-run - 'publish-v*' # publishes mnfst-publish - 'starter-v*' # publishes mnfst-starter - 'types-v*' # publishes mnfst-types - 'test-v*' # publishes mnfst-test - 'export-v*' # publishes mnfst-export - 'docs-v*' # publishes mnfst-docs permissions: contents: read jobs: test: name: Test uses: ./.github/workflows/test.yml release: name: Publish ${{ matrix.pkg }} needs: test runs-on: ubuntu-latest permissions: contents: read id-token: write # REQUIRED for OIDC trusted publishing + provenance # One publish per package at a time; unselected matrix legs get a per-run group so they never displace a queued real one. concurrency: group: ${{ ((github.event_name == 'push' && startsWith(github.ref_name, matrix.tag)) || (github.event_name == 'workflow_dispatch' && (inputs.package == 'all' || inputs.package == matrix.pkg))) && format('release-{0}', matrix.pkg) || format('release-noop-{0}-{1}', github.run_id, matrix.pkg) }} cancel-in-progress: false strategy: fail-fast: false matrix: include: - pkg: mnfst tag: v dir: . root: true - pkg: mnfst-render tag: render-v dir: packages/render - pkg: mnfst-run tag: run-v dir: packages/run - pkg: mnfst-types tag: types-v dir: packages/types - pkg: mnfst-test tag: test-v dir: packages/test - pkg: mnfst-export tag: export-v dir: packages/export - pkg: mnfst-starter tag: starter-v dir: packages/create-starter - pkg: mnfst-publish tag: publish-v dir: packages/publish - pkg: mnfst-docs tag: docs-v dir: packages/docs steps: - name: Decide whether this package is selected id: gate run: | EV="${{ github.event_name }}"; REF="${{ github.ref }}"; PKG="${{ matrix.pkg }}" run=false if [ "$EV" = "push" ]; then case "$REF" in refs/tags/render-v*) [ "$PKG" = "mnfst-render" ] && run=true ;; refs/tags/run-v*) [ "$PKG" = "mnfst-run" ] && run=true ;; refs/tags/publish-v*) [ "$PKG" = "mnfst-publish" ] && run=true ;; refs/tags/starter-v*) [ "$PKG" = "mnfst-starter" ] && run=true ;; refs/tags/types-v*) [ "$PKG" = "mnfst-types" ] && run=true ;; refs/tags/test-v*) [ "$PKG" = "mnfst-test" ] && run=true ;; refs/tags/export-v*) [ "$PKG" = "mnfst-export" ] && run=true ;; refs/tags/docs-v*) [ "$PKG" = "mnfst-docs" ] && run=true ;; refs/tags/v*) [ "$PKG" = "mnfst" ] && run=true ;; esac elif [ "${{ inputs.package }}" = "all" ] || [ "${{ inputs.package }}" = "$PKG" ]; then run=true fi echo "run=$run" >> "$GITHUB_OUTPUT" - name: Checkout if: steps.gate.outputs.run == 'true' uses: actions/checkout@v4 - name: Setup Node if: steps.gate.outputs.run == 'true' uses: actions/setup-node@v4 with: node-version: 22 registry-url: https://registry.npmjs.org - name: Upgrade npm (Trusted Publishing needs npm >= 11.5.1) if: steps.gate.outputs.run == 'true' run: npm install -g npm@latest - name: Install dependencies if: steps.gate.outputs.run == 'true' run: npm ci - name: Bump version from registry (registry-latest + 1 patch) if: steps.gate.outputs.run == 'true' run: node scripts/release-bump.mjs ${{ matrix.dir }} - name: Build library (root mnfst only; lib/ from src/) if: steps.gate.outputs.run == 'true' && matrix.root == true run: npm run build - name: Publish (OIDC, with provenance) if: steps.gate.outputs.run == 'true' working-directory: ${{ matrix.dir }} # Surface the npm error as a workflow annotation: run logs need a # signed-in viewer, annotations are public, so an agent can diagnose a # failed release without GitHub credentials. run: | set -o pipefail if ! npm publish --provenance --access public 2>&1 | tee /tmp/publish.log; then tail -n 15 /tmp/publish.log | while IFS= read -r line; do echo "::error title=npm publish (${{ matrix.pkg }})::${line}"; done exit 1 fi - name: Warm CDN (root mnfst only; best-effort, never fails the release) if: steps.gate.outputs.run == 'true' && matrix.root == true run: node scripts/cdn-warm.mjs continue-on-error: true