Publish npm Package #2
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 npm Package | |
on: | |
workflow_dispatch: | |
inputs: | |
release_type: | |
type: choice | |
description: 'Release Tag' | |
required: true | |
default: 'latest' | |
options: | |
- latest | |
- next | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Install jslib globally | |
run: yarn install | |
- name: Publish to npm | |
uses: JS-DevTools/npm-publish@v3 | |
with: | |
package: packages/cli | |
token: ${{ secrets.NPM_TOKEN }} | |
tag: ${{ github.event.inputs.release_type }} | |
- name: Create Git tag | |
run: | | |
# Create a new tag based on the current version in package.json | |
VERSION=$(node -p "require('./packages/cli/package.json.json').version") | |
TAG="v$VERSION" | |
git tag $TAG | |
git push origin $TAG | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub Token to authenticate the push |