Publish to NPM #6
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: | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: read | |
| jobs: | |
| Publish: | |
| name: Publish to NPM | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| defaults: | |
| run: | |
| working-directory: ./v1/typescript-definitions | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-node@v5 | |
| with: | |
| node-version: 24 | |
| registry-url: "https://registry.npmjs.org" | |
| # Ensure npm 11.5.1 or later is installed: | |
| # - name: Update npm | |
| # run: npm install -g npm@latest | |
| - name: Prepare Environment | |
| # Install from package-lock.json: | |
| run: npm ci | |
| env: | |
| CI: true | |
| - name: Determine type of release | |
| id: release-tag | |
| run: | | |
| if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| echo "Publish latest" | |
| echo "tag=latest" >> $GITHUB_OUTPUT | |
| else | |
| echo "Publish nightly" | |
| echo "tag=nightly" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Bump version to prerelease | |
| if: github.ref != 'refs/heads/main' | |
| run: | | |
| PRERELEASE_TAG=nightly-$(echo "${{ github.ref_name }}" | sed -r 's/[^a-z0-9]+/-/gi') | |
| npm version prerelease --preid $PRERELEASE_TAG-$COMMIT_DATE-$GIT_HASH | |
| - name: Generate types | |
| run: npm run generate-types | |
| env: | |
| CI: true | |
| - name: Build | |
| run: npm run build | |
| env: | |
| CI: true | |
| - name: Publish to NPM | |
| run: npm publish --tag ${{ steps.release-tag.outputs.tag }} | |
| env: | |
| CI: true |