-
Notifications
You must be signed in to change notification settings - Fork 3
63 lines (58 loc) · 1.9 KB
/
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
62
63
#
# This CI triggered when a PR is merged in main branch.
#
# 1. Increase version number (e.g. 0.0.1 => 0.0.2) in package.json and add a git tag
# 2. Publish to npm registry
#
on:
pull_request:
types: [closed]
jobs:
versioning:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
registry-url: "https://npm.pkg.github.com"
- run: |
git config --local user.email "[email protected]"
git config --local user.name "Github Action Bot"
- name: '`npm version patch` if PR has no label "minor" or "major"'
if: ${{ !contains(github.event.pull_request.labels.*.name, 'minor') && !contains(github.event.pull_request.labels.*.name, 'major') }}
run: |
npm version patch
- name: '`npm version minor` if PR has label "minor"'
if: contains(github.event.pull_request.labels.*.name, 'minor')
run: |
npm version minor
- name: '`npm version major` if PR has label "major"'
if: contains(github.event.pull_request.labels.*.name, 'major')
run: |
npm version major
- name: Push versioning commit and tag
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
tags: true
publish:
needs: versioning
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
registry-url: "https://npm.pkg.github.com"
# need this if commit/push in other jobs (versioning)
- run: git pull
- run: npm install
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: npm run build:dist
- run: |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}