-
Notifications
You must be signed in to change notification settings - Fork 8
69 lines (60 loc) · 1.89 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
64
65
66
67
68
69
# This is a basic workflow to help you get started with Actions
name: Release to GitHub and Publish to NPM
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
on:
push:
branches: [ main ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'version bump to') || !contains(github.event.head_commit.message, 'skip ci')"
outputs:
tag: ${{ steps.tag_name.outputs.TAG }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12
- name: Automated Version Bump
uses: phips28/gh-action-bump-version@master
- run: npm ci --ignore-scripts
- run: npm run build --if-present
- name: Export TAG Parameter
id: tag_name
run: |
echo ::set-output name=TAG::`cat package.json | jq -r .version`
shell: bash
realease:
needs: [build]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12
- name: GH Release
uses: softprops/action-gh-release@v1
with:
tag_name: "v${{ needs.build.outputs.tag }}"
publish:
if: github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- name: Publish
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --ignore-scripts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}