-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (67 loc) · 1.76 KB
/
publish-npm.yaml
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
name: Build
on:
push:
jobs:
check_eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install modules
run: |
sudo npm install -g eslint
- run: eslint index.js --ext .js,.jsx,.ts,.tsx
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@master
- name: Set up Node.js
uses: actions/setup-node@master
with:
node-version: 17
- run: |
npm install
- run: |
npm run-script test
npm:
name: npm-publish
if: "github.event_name == 'push'"
runs-on: ubuntu-latest
needs: [check_eslint, test]
steps:
- name: Checkout repository
uses: actions/checkout@master
- name: Set up Node.js
uses: actions/setup-node@master
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- name: Install modules
run: |
npm install
- name: Test
run: npm test
- run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,' | sed -e 's/^v//')
jq '.version="'"$VERSION"'"' package.json > /tmp/a
mv /tmp/a package.json
if: "startsWith(github.ref, 'refs/tags/v')"
- run: |
npm whoami
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- run: |
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
if: "startsWith(github.ref, 'refs/tags/v')"
- uses: actions/setup-node@v2
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
if: "startsWith(github.ref, 'refs/tags/v')"
- run: |
npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
if: "startsWith(github.ref, 'refs/tags/v')"