Publish to NPM (Dry run on prerelease) #5
Workflow file for this run
This file contains 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 (Dry run on prerelease) | |
on: | |
release: | |
types: [prereleased, released] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 20 | |
- run: git config --global user.name "NPM release bot" | |
- run: git config --global user.email "<>" | |
- name: Install dependencies | |
run: npm ci | |
- name: Build | |
run: npm run build | |
- run: npm version ${{ github.event.release.tag_name }} --git-tag-version=false | |
- name: Test publishing to NPM | |
if: ${{ github.event.action }} == 'prereleased' | |
run: npm publish --dry-run | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Publish to NPM | |
if: ${{ github.event.action }} == 'released' | |
run: npm publish --dry-run | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Bump version in git | |
run: | | |
git add package.json | |
git add package-lock.json | |
git add API.md | |
git commit -m "Bump version to ${{ github.event.release.tag_name }}" | |
git tag -f ${{ github.event.release.tag_name }} | |
git push | |
git push origin -f ${{ github.event.release.tag_name }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |