-
Notifications
You must be signed in to change notification settings - Fork 97
61 lines (60 loc) · 2.03 KB
/
npm-publish.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
53
54
55
56
57
58
59
60
61
name: Publish to npm
on:
workflow_dispatch:
inputs:
version:
description: 'npm version to publish'
type: choice
required: true
options:
# these are defined in ${{vars.versions}}, but ghw doesn't support yet the use of expressions in inputs.
- 'patch (x.y.z+1, bug fixes)'
- 'minor (x.y+1.0, new functionality)'
- 'major (x+1.0.0, api breaking changes)'
dry_run:
description: 'Perform all steps except npm publish'
type: boolean
default: true
required: true
jobs:
build:
if: false
uses: ./.github/workflows/build.yml
publish-npm:
# needs: build
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
ref: github-workflows
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm ci
#- run: npm run dist
- name: Setup versions in ${{'${{env}}'}}
run: |
git tag --list 'v*' --sort=-taggerdate
git tag --list 'v*' --sort=-taggerdate | head -1
echo "$(git tag --list 'v*' --sort=-taggerdate | head -1)"
PREV_PKG_VERSION=$(git tag --list 'v*' --sort=-taggerdate | head -1)
echo "PREV_PKG_VERSION=$PREV_PKG_VERSION" >> "$GITHUB_ENV"
echo "PKG_VERSION=${{fromJSON(vars.versions).values[inputs.version]}}" >> "$GITHUB_ENV"
- name: Version package
run: "npm version ${{env.PKG_VERSION}} -m \"\
Version %s (${{env.PKG_VERSION}})\
\n\
\n\
Changes since ${{env.PREV_PKG_VERSION}}:\
\n\
$(git log --pretty='format:%h %s' ${{env.PREV_PKG_VERSION}}..HEAD | grep -v '.yml')\""
env:
PKG_VERSION: ${{fromJSON(vars.versions).values[inputs.version]}}
- name: Push new version
run: git push
- name: Publish to npm
if: inputs.dry_run == false
run: echo "npm publish"
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}