name: Publish to npm on: workflow_call: inputs: dir: description: The directory to release type: string default: "." outputs: id: description: "The npm package@version string we published" value: ${{ jobs.npm.outputs.id }} permissions: {} jobs: npm: name: Publish to npm runs-on: ubuntu-24.04 permissions: contents: read id-token: write outputs: id: ${{ steps.npm-publish.outputs.id }} steps: - name: 🧮 Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: ref: staging persist-credentials: false - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5 - name: 🔧 pnpm cache uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 with: cache: "pnpm" registry-url: "https://registry.npmjs.org" node-version-file: ${{ inputs.dir }}/package.json # Ensure npm 11.5.1 or later is installed - name: Update npm run: npm install -g npm@latest - name: 🔨 Install dependencies run: "pnpm install --frozen-lockfile" - name: 🚀 Publish to npm id: npm-publish working-directory: ${{ inputs.dir }} run: | npm publish --provenance --access public --tag "$TAG" release=$(jq -r '"\(.name)@\(.version)"' package.json) echo "id=$release" >> $GITHUB_OUTPUT env: TAG: ${{ contains(steps.npm-publish.outputs.id, '-rc.') && 'next' || 'latest' }}