1- name : Node.js Package
1+ name : Publish Package
22
33on :
44 release :
55 types : [created]
66
77jobs :
8- build :
8+ test :
99 name : Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
1010 runs-on : ${{ matrix.os }}
1111 strategy :
1212 matrix :
1313 node_version : ["8", "10", "12"]
1414 os : [ubuntu-latest, windows-latest, macOS-latest]
15- env :
16- OS : ${{ matrix.os }}
17- NODE : 10
18-
1915 steps :
2016 - name : Checkout code
2117 uses : actions/checkout@v2
2218 with :
2319 fetch-depth : 1
24- - name : Cache node modules
25- uses : actions/cache@v2
26- env :
27- cache-name : cache-node-modules
28- with :
29- # yarn cache files are stored in `~/.yarn` on Linux/macOS
30- path : ~/.yarn
31- key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
32- restore-keys : |
33- ${{ runner.os }}-build-${{ env.cache-name }}-
34- ${{ runner.os }}-build-
35- ${{ runner.os }}-
3620
3721 - name : Use Node.js ${{ matrix.node_version }}
3822 uses : actions/setup-node@v1
3923 with :
4024 node-version : ${{ matrix.node_version }}
41- - name : Npm install, build, and test
25+
26+ - name : Npm install, build and test
4227 run : |
4328 yarn install
4429 yarn build
4530 yarn test
46- - name : Use Node.js ${{ jobs.build.env.NODE }} coverage
47- uses : actions/setup-node@v1
31+
32+ coverage :
33+ needs : test
34+ name : Generate coverage
35+ runs-on : ubuntu-latest
36+ env :
37+ OS : ${{ runner.os }}
38+ NODE : 10
39+ steps :
40+ - name : Checkout code
41+ uses : actions/checkout@v2
4842 with :
49- node-version : ${{ jobs.build.env.NODE }}
43+ fetch-depth : 1
44+
45+ - uses : actions/setup-node@v1
46+ with :
47+ node-version : ${{ jobs.coverage.env.NODE }}
48+
5049 - name : Npm install, build, and coverage
5150 run : |
5251 yarn install
5352 yarn build
5453 yarn coverage
54+
5555 - name : Upload coverage to Codecov
5656 uses : codecov/codecov-action@v1
5757 with :
@@ -66,13 +66,14 @@ jobs:
6666 path_to_write_report : ./coverage/codecov_report.gz
6767
6868 publish :
69- needs : build
69+ needs : coverage
7070 runs-on : ubuntu-latest
7171 steps :
7272 - name : Checkout code
7373 uses : actions/checkout@v2
7474 with :
7575 fetch-depth : 1
76+
7677 - name : Cache node modules
7778 uses : actions/cache@v2
7879 env :
@@ -88,19 +89,24 @@ jobs:
8889
8990 - uses : actions/setup-node@v1
9091 with :
91- node-version : 12
92+ node-version : ${{ jobs.build.env.NODE }}
9293 registry-url : https://registry.npmjs.org/
94+
9395 - name : Npm install, and build
9496 run : |
9597 yarn install
9698 yarn build
99+
97100 - name : Publish to npm
98101 run : yarn publish
99102 env :
100103 NODE_AUTH_TOKEN : ${{secrets.NPMJS_TOKEN}}
104+
101105 - uses : actions/setup-node@v1
102106 with :
107+ node-version : ${{ jobs.build.env.NODE }}
103108 registry-url : https://npm.pkg.github.com/
109+
104110 - name : Publish to github package
105111 run : yarn publish
106112 env :
0 commit comments