-
Notifications
You must be signed in to change notification settings - Fork 22
122 lines (108 loc) · 3.17 KB
/
node.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Node.js NPM
on:
push:
branches:
- main
pull_request:
paths:
- 'openapi/**'
- 'proto/**'
- 'src/**'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
cache-dependency-path: package.json
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Install Protoc
uses: arduino/setup-protoc@v1
- name: Install Dependencies
run: |
npm install
npm run install:protoc
- name: Generate gRPC Stubs
run: npm run generate
- name: Test
run: npm test
pack:
name: Pack
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
cache-dependency-path: package.json
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Install Protoc
uses: arduino/setup-protoc@v1
- name: Install Protoc 3rd party protos
run: npm run install:protoc
- name: Install Dependencies
run: npm install
- name: Generate Package JSON
run: ./scripts/generate-package-json.sh
- name: Pack Testing
run: ./scripts/npm-pack-testing.sh
publish:
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/v'))
name: Publish
needs: [build, pack]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
registry-url: https://registry.npmjs.org/
cache: npm
cache-dependency-path: package.json
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Install Protoc
uses: arduino/setup-protoc@v1
- name: Install Protoc 3rd party protos
run: npm run install:protoc
- name: Install Dependencies
run: npm install
- name: Generate Package JSON
run: ./scripts/generate-package-json.sh
- name: Set Publish Config
run: ./scripts/package-publish-config-tag.sh
- run: npm run dist
- name: Check Branch
id: check-branch
run: |
if [[ ${{ github.ref }} =~ ^refs/heads/(main|v[0-9]+\.[0-9]+.*)$ ]]; then
echo ::set-output name=match::true
fi # See: https://stackoverflow.com/a/58869470/1123955
- name: Is A Publish Branch
if: steps.check-branch.outputs.match == 'true'
run: |
NAME=$(npx pkg-jq -r .name)
VERSION=$(npx pkg-jq -r .version)
if npx version-exists "$NAME" "$VERSION"
then echo "$NAME@$VERSION exists on NPM, skipped."
else npm publish
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- name: Is Not A Publish Branch
if: steps.check-branch.outputs.match != 'true'
run: echo 'Not A Publish Branch'