Workflow file for this run
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 to npm on Release | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| publish: | |
| name: Publish | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| cache: "pnpm" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run type check | |
| run: pnpm typecheck | |
| - name: Run unit tests | |
| run: pnpm test | |
| - name: Verify package version matches release tag | |
| run: | | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| PACKAGE_VERSION="$(node -p "require('./package.json').version")" | |
| echo "Release tag version: $VERSION" | |
| echo "Package version: $PACKAGE_VERSION" | |
| if [[ "$PACKAGE_VERSION" != "$VERSION" ]]; then | |
| echo "::error::package.json version must match release tag" | |
| exit 1 | |
| fi | |
| - name: Build | |
| run: pnpm build | |
| - name: Publish | |
| run: | | |
| TAG="latest" | |
| if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then | |
| TAG="next" | |
| fi | |
| pnpm publish --no-git-checks --access public --tag "$TAG" | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |