-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.github/workflows: add release workflow (#6)
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Release to NPM | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
type: string | ||
description: Version to release, e.g. "v0.1.2" | ||
required: false | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
npm-publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.16.0 | ||
- name: Set version env | ||
id: set_version | ||
## if version is not provided as input, use the tag name | ||
run: | | ||
echo "tag=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT | ||
if [ -z "${{ github.event.inputs.version }}" ]; then | ||
echo "tag=${{ github.ref }}" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Update version of npm package | ||
env: | ||
RELEASE_VERSION: ${{ steps.set_version.outputs.tag }} | ||
run: | | ||
npm version $RELEASE_VERSION | ||
- name: publish the npm package | ||
uses: JS-DevTools/npm-publish@v2 | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} |