publish-on-tag #14
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-on-tag | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| npm-publish: | |
| description: 'Try to publish to NPM' | |
| default: false | |
| type: boolean | |
| permissions: | |
| contents: read | |
| jobs: | |
| publish-to-npm: | |
| runs-on: ubuntu-latest | |
| if: ${{ (github.event_name != 'workflow_dispatch') || (inputs.npm-publish && always()) }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 2 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 | |
| with: | |
| cache: npm | |
| node-version-file: '.nvmrc' | |
| registry-url: 'https://registry.npmjs.org' | |
| # Ensure npm 11.5.1 or later is installed | |
| - name: Update npm | |
| run: npm install -g npm@11.4.0 | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build and bundle | |
| run: npm run bundle | |
| env: | |
| NODE_ENV: 'production' | |
| - name: Publish | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |