-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: allow publishing to npm via github action
- Loading branch information
Showing
1 changed file
with
49 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,49 @@ | ||
name: publish-to-npm | ||
run-name: ${{ github.actor }} is publishing to npm | ||
on: | ||
workflow-dispatch: | ||
inputs: | ||
bump_level: | ||
description: type of version bump | ||
type: choice | ||
default: patch | ||
required: true | ||
options: | ||
- patch | ||
- minor | ||
- major | ||
- custom (use custom_bump_level) | ||
custom_bump_level: | ||
description: version to bump to | ||
type: string | ||
|
||
jobs: | ||
build-and-publish: | ||
name: build and publish package | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-tags: true | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: './.nvmrc' | ||
cache: npm | ||
- name: "install deps" | ||
run: npm ci | ||
- name: "export login token" | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_CLASSIC_TOKEN }} | ||
run: "echo //registry.npmjs.org/:_authToken=$NPM_TOKEN > ./.npmrc" | ||
- if: ${{ inputs.bump_level != "custom" }} | ||
name: "bump version" | ||
env: | ||
VERSION: ${{ inputs.bump_level }} | ||
run: "npm version $VERSION" | ||
- if: ${{ inputs.bump_level == "custom" }} | ||
name: "custom version bump" | ||
env: | ||
VERSION ${{ inputs.custom_bump_level }} | ||
run: "[ -n $VERSION ] && npm version $VERSION || (echo 'custom version indicated but not set' && false)" | ||
- name: "publishing" | ||
run: "npm publish" |