Publish Node.js Package #316
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Node.js Package | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| tag_name: | |
| description: "Release Version" | |
| required: true | |
| default: "v1.0.0" | |
| type: string | |
| env: | |
| HUSKY: 0 | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: read | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| id-token: write # Required for OIDC trusted publishing | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24' | |
| registry-url: "https://registry.npmjs.org" | |
| scope: "@sistent" | |
| - name: "Set Package Version" | |
| env: | |
| TAG_NAME: ${{ github.event.release.tag_name || inputs.tag_name }} | |
| run: | | |
| # Strip a leading 'v' from the release tag (v0.19.0 -> 0.19.0) and | |
| # set package.json#version. --allow-same-version makes the step | |
| # idempotent when master's package.json already matches the tag | |
| # (e.g. the merged PR that cut the release had committed the bump). | |
| # --no-git-tag-version prevents npm from creating an extra tag. | |
| VERSION="${TAG_NAME#v}" | |
| npm version "$VERSION" --no-git-tag-version --allow-same-version | |
| - name: Install, Build, and Publish Package | |
| run: | | |
| npm install --legacy-peer-deps | |
| npm run build | |
| npm publish --provenance --access public --verbose | |
| env: | |
| NODE_AUTH_TOKEN: '' # Explicitly empty for install | |
| notify-dependents: | |
| needs: publish | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| release_version: ${{ steps.stripped_release_version.outputs.result }} | |
| steps: | |
| - uses: actions/github-script@v7 | |
| id: stripped_release_version | |
| with: | |
| result-encoding: string | |
| script: | | |
| let release_version = `${{github.event.release.tag_name}}` | |
| return release_version.replace(/^v/, '') |