-
Notifications
You must be signed in to change notification settings - Fork 1
52 lines (51 loc) · 1.52 KB
/
publish-to-npm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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"
- env:
BUMP_LEVEL: ${{ inputs.bump_level }}
run: "echo $BUMP_LEVEL"
- if: ${{ inputs.bump_level != 'custom' }}
name: "bump version"
env:
VERSION: ${{ inputs.bump_level }}
run: "npm version $VERSION --dry-run"
- if: ${{ inputs.bump_level == 'custom' }}
name: "custom version bump"
env:
VERSION: ${{ inputs.custom_bump_level }}
run: "[ -n $VERSION ] && npm version $VERSION --dry-run || (echo 'custom version indicated but not set' && false)"
- name: "publishing"
run: "npm publish --dry-run"