Skip to content

Commit

Permalink
build: allow publishing to npm via github action
Browse files Browse the repository at this point in the history
  • Loading branch information
ashtonG committed Jan 18, 2024
1 parent e4fb70c commit 54d305f
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/publish-to-npm.yml
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"

0 comments on commit 54d305f

Please sign in to comment.