-
Notifications
You must be signed in to change notification settings - Fork 2
73 lines (66 loc) · 2.14 KB
/
build-release.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
70
71
72
73
# Reference: <https://help.github.com/en/actions/language-and-framework-guides/using-nodejs-with-github-actions>
name: Build/Release
on:
release:
types: [created]
jobs:
build:
name: Build
runs-on: windows-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v2
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Cache Node.js modules
uses: actions/cache@v1
with:
path: "%AppData%\npm-cache" # npm cache files are stored under the AppData folder on Windows
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Run unit tests
run: npm test
- name: Create package
run: npm pack
- name: Rename package to generic name
run: mv *.tgz final-hill-decorator-contracts.tgz
- name: Upload package
uses: actions/upload-artifact@v1
with:
name: artifact
path: final-hill-decorator-contracts.tgz
release:
name: Publish to npm
needs: build
runs-on: windows-latest
strategy:
matrix:
node-version: [20.x]
steps:
- name: Download artifact
uses: actions/download-artifact@v1
with:
name: artifact
- name: Extract package from artifact
run: tar -xf artifact/final-hill-decorator-contracts.tgz --strip 1
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Publish
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}