Skip to content

Autopublish to npm on release creation #30

Autopublish to npm on release creation

Autopublish to npm on release creation #30

name: Autopublish to npm on release creation
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.target_commitish }}
- uses: actions/setup-node@v4
with:
node-version: 18
- run: npm i
- run: git config --global user.name "GitHub CD bot"
- run: git config --global user.email "[email protected]"
- run: npm version ${{ github.event.release.tag_name }}
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
# use "beta" tag if relevant, otherwise use "latest"
tag: ${{ contains(github.event.release.tag_name, 'beta') && 'beta' || 'latest' }}
# push the version changes to GitHub
- run: git push
env:
github-token: ${{ secrets.GITHUB_TOKEN }}