v0.3.1 #4
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 npm | |
| on: | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| environment: npm | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: "24" | |
| registry-url: https://registry.npmjs.org | |
| package-manager-cache: false | |
| - run: npm ci | |
| - run: npm test | |
| - name: Verify release version | |
| env: | |
| RELEASE_TAG: ${{ github.event.release.tag_name }} | |
| run: | | |
| PACKAGE_VERSION="$(node -p "require('./package.json').version")" | |
| test "v${PACKAGE_VERSION}" = "${RELEASE_TAG}" | |
| - name: Check whether version is already published | |
| id: npm-version | |
| run: | | |
| PACKAGE_NAME="$(node -p "require('./package.json').name")" | |
| PACKAGE_VERSION="$(node -p "require('./package.json').version")" | |
| if npm view "${PACKAGE_NAME}@${PACKAGE_VERSION}" version --registry=https://registry.npmjs.org >/dev/null 2>&1; then | |
| echo "publish=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "publish=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Publish package | |
| if: steps.npm-version.outputs.publish == 'true' | |
| run: npm publish --access public |