Add npm upgrade step for OIDC auth support #7
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: Release to npm | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| - name: Update npm to latest (>= 11.5 required for OIDC auth) | |
| run: npm install -g npm@latest | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Lint | |
| run: npm run lint | |
| # TODO: Re-enable once test suite is migrated to the new TypeScript codebase | |
| # - name: Test | |
| # run: npm test | |
| - name: Build | |
| run: npm run build | |
| - name: Validate tag matches package.json version | |
| run: | | |
| TAG_VERSION="${GITHUB_REF_NAME#v}" | |
| PKG_VERSION=$(node -p "require('./package.json').version") | |
| if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then | |
| echo "::error::Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)" | |
| exit 1 | |
| fi | |
| - name: Determine npm dist-tag | |
| id: dist-tag | |
| run: | | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| if [[ "$VERSION" == *"-beta"* ]]; then | |
| echo "tag=beta" >> "$GITHUB_OUTPUT" | |
| elif [[ "$VERSION" == *"-alpha"* ]]; then | |
| echo "tag=alpha" >> "$GITHUB_OUTPUT" | |
| elif [[ "$VERSION" == *"-rc"* ]]; then | |
| echo "tag=rc" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "tag=latest" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Publish to npm | |
| run: npm publish --provenance --tag ${{ steps.dist-tag.outputs.tag }} |