name: npm-publish # Publishing is a maintainer-triggered event, not a side effect of merging to # main. `published` excludes draft releases -- drafting doesn't publish, # hitting "Publish release" does. See ai-planning/41-proposal-release-gated-npm-publish.md. on: release: types: [published] jobs: npm-publish: name: npm-publish runs-on: ubuntu-latest # id-token: write is what lets this job request an OIDC token from GitHub # and exchange it for a short-lived npm publish token -- npm's Trusted # Publisher feature (https://docs.npmjs.com/trusted-publishers), set up # separately on npmjs.com for this repo + this workflow file. No # NPM_AUTH_TOKEN secret needed once this is configured on both sides. permissions: contents: read id-token: write steps: - name: Checkout repository uses: actions/checkout@v7 - name: Set up Bun uses: oven-sh/setup-bun@v2 with: bun-version: 1.3.14 - run: bun install --frozen-lockfile - run: bun run lint - run: bun run test - run: bun run build # Deliberately placed AFTER lint/test/build and immediately before the # verification step, whose whole point is exercising the oldest Node we # claim to support. `setup-node` changes the `node` on PATH for every # subsequent step, but the publish step further down installs its own, # newer Node -- see the comment there. - name: Set up Node (the floor of our declared engines range) uses: actions/setup-node@v7 with: node-version: '18' # The gate that would have stopped the broken release: pack, install with # npm, and run the artifacts under the OLDEST Node we claim to support. # # `bun run test` cannot catch this -- it imports src/ under Bun. This runs # the tarball. It also fails if dist/index.js is not bundled, which is the # regression that a stray `tsgo` invocation would otherwise reintroduce # silently. See ai-planning/29-proposal-node-runtime-verification.md. - name: Verify the packed artifacts on Node and Bun run: ./scripts/verify-node-runtime.sh env: RUNTIMES: node bun # Trusted publishing needs npm >= 11.5.1 and Node >= 22.14.0 # (https://docs.npmjs.com/trusted-publishers), well above the Node 18 # floor the verification step above deliberately tests against -- so this # is a second, separate Node setup, scoped to just the publish step below. - name: Set up Node for npm trusted publishing (needs npm >= 11.5.1) uses: actions/setup-node@v7 with: node-version: '22' - run: npm install -g npm@latest - name: Publish packages whose version has been updated run: ./scripts/publish-changed.sh