Publish to npm #11
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: | |
| workflow_run: | |
| workflows: ["Pre-publish validation"] | |
| types: [completed] | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| publish: | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| cache: pnpm | |
| - name: Update npm | |
| run: npm install -g npm@latest | |
| - name: Check versions | |
| run: | | |
| echo "Node: $(node --version)" | |
| echo "npm: $(npm --version)" | |
| echo "pnpm: $(pnpm --version)" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Publish | |
| run: | | |
| NAME=$(node -p "require('./package.json').name") | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "Package: ${NAME}" | |
| echo "Version: ${VERSION}" | |
| if npm view "${NAME}@${VERSION}" version >/dev/null 2>&1; then | |
| echo "Skipping publish: ${NAME}@${VERSION} already exists on npm" | |
| exit 0 | |
| fi | |
| npm publish --access public |