name: publish # Publishes @postfleet/mcp to npm with no secret of any kind. npm verifies this # workflow's OIDC identity against the trusted publisher configured on the package, # which is why there is no NODE_AUTH_TOKEN here and must never be one — a token would # defeat the point and reintroduce the expiry/2FA problem this replaces. # # Publish by pushing a tag whose version matches package.json: # npm version patch && git push --follow-tags on: push: tags: ['v*'] workflow_dispatch: jobs: publish: runs-on: ubuntu-latest permissions: id-token: write # mints the OIDC token npm checks. Without it the publish 403s. contents: read steps: - uses: actions/checkout@v5 - uses: actions/setup-node@v5 with: node-version: 24 registry-url: https://registry.npmjs.org # Trusted publishing needs npm >= 11.5.1. Node 24 ships a new enough npm today, # but pinning to latest costs one step and removes the version from the equation. - run: npm install -g npm@latest - run: npm ci # Refuse to publish a tag that disagrees with package.json, which would otherwise # ship the wrong version under the right-looking tag. - name: Tag matches package.json if: startsWith(github.ref, 'refs/tags/v') run: | tag="${GITHUB_REF_NAME#v}" pkg="$(node -p "require('./package.json').version")" [ "$tag" = "$pkg" ] || { echo "tag v$tag != package.json $pkg"; exit 1; } # prepublishOnly runs typecheck + build. Provenance is attached automatically # under trusted publishing, so --provenance is not needed. - run: npm publish --access public