Publish Package to npmjs #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: Publish Package to npmjs | |
| on: | |
| release: | |
| types: [published] | |
| # Permission to generate an OIDC token | |
| permissions: | |
| id-token: write | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # get the non-merge commit for PRs | |
| fetch-tags: true # include tags to get correct git version | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: '23.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install meson and build toolchain | |
| run: | | |
| sudo apt update -y | |
| sudo apt install -y meson ninja-build build-essential | |
| - uses: mymindstorm/setup-emsdk@v14 | |
| with: | |
| version: 5.0.1 | |
| - name: Install node dependencies and build the project | |
| run: | | |
| npm ci | |
| npm run build | |
| # See https://github.com/orgs/community/discussions/176761. `setup-node` was messing with | |
| # node authentication. This breaks publishing unless we clear the token. | |
| - name: Clear auth token for OIDC | |
| run: echo "NODE_AUTH_TOKEN=" >> $GITHUB_ENV | |
| # https://hackernoon.com/how-to-automatically-publish-your-npm-package-using-github-actions | |
| # Here we actually use `npm version from-git`, but just never commit the version. | |
| - name: Update package.json with release tag | |
| run: | | |
| npm version from-git --no-git-tag-version --allow-same-version | |
| - run: npm publish --provenance --access public |