-
Notifications
You must be signed in to change notification settings - Fork 119
189 lines (152 loc) · 5.35 KB
/
build_and_test.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Build and Test
on:
release:
types: [published]
pull_request:
push:
branches:
- 'alpha'
- 'beta'
- 'feat/deno-runtime'
env:
DENO_DIR: .deno
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- name: Github Info
run: |
echo "GITHUB_ACTION: $GITHUB_ACTION"
echo "GITHUB_ACTOR: $GITHUB_ACTOR"
echo "GITHUB_REF: $GITHUB_REF"
echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF"
echo "GITHUB_BASE_REF: $GITHUB_BASE_REF"
echo "github.event_name: ${{ github.event_name }}"
cat $GITHUB_EVENT_PATH
- name: Use Node.js 14.19.3
uses: actions/setup-node@v2
with:
node-version: '14.19.3'
- uses: actions/checkout@v2
- name: Versions
run: |
npm --versions
node -v
git version
- name: check package-lock
run: |
npx package-lock-check
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v2
with:
path: |
./node_modules
./deno-runtime/${{ env.DENO_DIR }}
key: ${{ runner.OS }}-node_modules-deno-cache-5-${{ hashFiles('./package-lock.json', './deno-runtime/deno.lock', '.github/workflows/build_and_test.yml') }}
- name: npm install
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm install
- name: Deno Info
run: npx deno-bin info
- name: Prepare workspace
run: |
tar czf /tmp/workspace.tar.gz .
- uses: actions/upload-artifact@v4
with:
name: workspace
path: /tmp/workspace.tar.gz
lint:
runs-on: ubuntu-latest
needs: prepare
steps:
- name: Use Node.js 14.19.3
uses: actions/setup-node@v2
with:
node-version: '14.19.3'
- uses: actions/download-artifact@v4
with:
name: workspace
path: /tmp
- name: Decompress workspace
run: |
tar xzf /tmp/workspace.tar.gz .
- name: Lint TypeScript Code
run: npm run lint
test:
runs-on: ubuntu-latest
needs: build
steps:
- name: Use Node.js 14.19.3
uses: actions/setup-node@v2
with:
node-version: '14.19.3'
- uses: actions/download-artifact@v4
with:
name: workspace
path: /tmp
- name: Decompress workspace
run: |
tar xzf /tmp/workspace.tar.gz .
- name: Test TypeScript Code
run: npm run test
build:
runs-on: ubuntu-latest
needs: lint
steps:
- name: Use Node.js 14.19.3
uses: actions/setup-node@v2
with:
node-version: '14.19.3'
- uses: actions/download-artifact@v4
with:
name: workspace
path: /tmp
- name: Decompress workspace
run: |
tar xzf /tmp/workspace.tar.gz .
- name: Compile TypeScript into JavaScript
run: npm run compile
- name: Prepare workspace
run: |
tar czf /tmp/workspace.tar.gz .
- uses: actions/upload-artifact@v4
with:
name: workspace
path: /tmp/workspace.tar.gz
overwrite: true
publish:
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.ref == 'refs/heads/alpha' || github.ref == 'refs/heads/beta'
needs: test
steps:
- name: Use Node.js 14.19.3
uses: actions/setup-node@v2
with:
node-version: '14.19.3'
- uses: actions/download-artifact@v4
with:
name: workspace
path: /tmp
- name: Decompress workspace
run: |
tar xzf /tmp/workspace.tar.gz .
- name: Authenticate with registry
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
- name: Publish package
run: |
if [[ '${{ github.event_name }}' = 'release' ]]; then
npm publish --tag latest
else
ls -la
# Add build number to the end of the version
npm version "$(node -p "require('./package.json').version").${{ github.run_number }}" --no-git-tag-version
GIT_BRANCH="${GITHUB_REF#*heads/}"
if [[ $GIT_BRANCH == 'alpha' ]]; then
npm run go-publish-alpha
else
npm run go-publish-beta
fi;
fi;