Fix NPM package generation and publish #5
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: NPM Package | |
| on: | |
| push: | |
| branches-ignore: | |
| - "**" | |
| tags: | |
| - v* | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Package version" | |
| required: true | |
| tag: | |
| description: "Package tag" | |
| required: true | |
| default: "latest" | |
| type: choice | |
| options: | |
| - latest | |
| - beta | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: read | |
| jobs: | |
| npm-upload: | |
| name: NPM Package Build and Upload | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| registry-url: 'https://registry.npmjs.org' | |
| # Ensure npm 11.5.1 or later is installed | |
| - name: Update npm | |
| run: npm install -g npm@latest | |
| - run: npm ci | |
| - id: semver | |
| run: | | |
| SEMVER="${{ github.event.inputs.version }}" | |
| if [ -z "$SEMVER" ]; then | |
| # No manual input, we must be running on a tag | |
| SEMVER="${GITHUB_REF/refs\/tags\/v/}" | |
| fi | |
| echo "::set-output name=semver::${SEMVER}" | |
| - run: scripts/make-npm-package.sh "${{ steps.semver.outputs.semver }}" ./build/npm-package | |
| - run: | | |
| RELEASE_TAG="${{ github.event.inputs.tag }}" | |
| if [ -z "$RELEASE_TAG" ]; then | |
| if [[ "$SEMVER" == *"-beta"* ]]; then | |
| RELEASE_TAG=beta | |
| else | |
| # No manual input, we must be running on a tag | |
| RELEASE_TAG=latest | |
| fi | |
| fi | |
| echo "RELEASE_TAG: $RELEASE_TAG / SEMVER: $SEMVER" | |
| npm publish --tag "$RELEASE_TAG" --access public | |
| working-directory: ./build/npm-package |