forked from yodhcn/kikoeru-express
-
Notifications
You must be signed in to change notification settings - Fork 53
316 lines (265 loc) · 9.06 KB
/
build-artifacts.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
name: Build artifacts
on:
push:
branches-ignore:
- "dependabot/**"
tags:
- v*
jobs:
build-front-end:
runs-on: ubuntu-18.04
name: Build front end PWA from source
steps:
- name: Check out latest front end
uses: actions/checkout@v2
with:
repository: kikoeru-project/kikoeru-quasar
ref: unstable
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 14
- run: npm install -g @quasar/cli
- run: npm ci
- run: quasar build && quasar build -m pwa
- name: 'Upload PWA'
uses: actions/upload-artifact@v2
with:
name: PWA-unstable
path: dist/pwa
if-no-files-found: error
- name: 'Upload SPA'
uses: actions/upload-artifact@v2
with:
name: SPA-unstable
path: dist/spa
if-no-files-found: error
build:
needs: build-front-end
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
node_version: 14
architecture: x64
pkg_target: node14-linux-x64
archive_name_prefix: kikoeru-linux-x64
- os: macos-10.15
node_version: 14
architecture: x64
pkg_target: node14-macos-x64
archive_name_prefix: kikoeru-darwin-x64
- os: windows-2019
node_version: 14
architecture: x64
pkg_target: node14-win-x64
archive_name_prefix: kikoeru-win-x64
name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}
architecture: ${{ matrix.architecture }}
- run: npm install
- run: npm test
- name: check node-sqlite3 bindings
run: echo $(ls node_modules/sqlite3/lib/binding)
- name: 'Upload bindings'
uses: actions/upload-artifact@v2
with:
name: node-${{ matrix.node_version }}-${{ matrix.architecture }}-${{ matrix.os }}-binding
path: node_modules/sqlite3/lib/binding
if-no-files-found: error
# refs/tags/v1.2.3 => v1.2.3
# refs/heads/unstable => unstable
# refs/heads/feature/foo => foo
# refs/pull/421/merge => merge
- name: Get branch or tag name
id: source_name
run: echo ::set-output name=SOURCE_NAME::${GITHUB_REF##*/}
- name: Install pkg
run: npm install -g pkg@4.5.1
- name: Make empty dirs to suppress pkg warnings
run: mkdir -p config sqlite covers VoiceWork
- name: Download front-end artifact (PWA)
uses: actions/download-artifact@v2
with:
name: PWA-unstable
path: dist
- name: Check front-end artifacts
run: ls -al dist/
- name: Package to executables
run: pkg package.json -t ${pkg_target} --out-path package
env:
pkg_target: ${{ matrix.pkg_target }}
- name: Create archive
run: |
mkdir ${archive_name}
cp package/* ${archive_name}/
cp node_modules/sqlite3/lib/binding/*/*.node ${archive_name}/
env:
archive_name: ${{ matrix.archive_name_prefix }}-${{ steps.source_name.outputs.SOURCE_NAME }}
- name: 'Prepare release archive'
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.archive_name_prefix }}-${{ steps.source_name.outputs.SOURCE_NAME }}
path: ${{ matrix.archive_name_prefix }}-${{ steps.source_name.outputs.SOURCE_NAME }}
if-no-files-found: error
build-docker:
runs-on: ubuntu-18.04
name: Prepare multiarch docker images
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/unstable') || startsWith(github.ref, 'refs/heads/stable')
needs: build
steps:
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU for cross platform builds
id: qemu
uses: docker/setup-qemu-action@v1
- name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# Convert to a valid docker tagname
# refs/tags/v1.2.3 => v1.2.3
# refs/heads/unstable => unstable
# refs/heads/feature/foo => foo
# refs/pull/421/merge => merge
- name: Get branch or tag name
id: source_name
run: echo ::set-output name=SOURCE_NAME::${GITHUB_REF##*/}
- uses: haya14busa/action-cond@v1
name: Decide front-end version
id: front_version
with:
cond: startsWith(github.ref, 'refs/tags/')
if_true: ${{ steps.source_name.outputs.SOURCE_NAME }}
if_false: "unstable"
- name: Show conditional value from pervious step
run: echo "${{ steps.front_version.outputs.value }}"
- name: Build and push
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
pull: true
tags: |
muveex/kikoeru-express:${{ steps.source_name.outputs.SOURCE_NAME }}
muveex/kikoeru-express:dev
muveex/kikoeru:${{ steps.source_name.outputs.SOURCE_NAME }}
muveex/kikoeru:dev
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
build-args:
FRONTEND_VERSION=${{ steps.front_version.outputs.value }}
# Temp fix according to official document at
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#registry-cache
# They are working to refactor with GitHub cache backend
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
test-pkg-archive:
runs-on: ${{ matrix.os }}
name: Test pkg release archives on ${{ matrix.os }} x64
needs: [build]
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
archive_name_prefix: kikoeru-linux-x64
- os: macos-10.15
archive_name_prefix: kikoeru-darwin-x64
- os: windows-2019
archive_name_prefix: kikoeru-win-x64
steps:
- name: Get branch or tag name
id: source_name
run: echo ::set-output name=SOURCE_NAME::${GITHUB_REF##*/}
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: ${{ matrix.archive_name_prefix }}-${{ steps.source_name.outputs.SOURCE_NAME }}
- name: List files
run: ls -al .
- name: Test pkg binary on *nix
if: ${{ matrix.os == 'ubuntu-18.04' || matrix.os == 'macos-10.15' }}
run: |
set -e
chmod +x ./kikoeru-express
nohup ./kikoeru-express &
sleep 10 && cat nohup.out 2>/dev/null &&
curl --fail -I http://localhost:8888/
pkill -TERM kikoeru-express
- name: Test pkg binary on Windows
if: ${{ matrix.os == 'windows-2019' }}
shell: pwsh
run: |
$PSVersionTable
Start-Job { ./kikoeru-express.exe }
sleep 5 &&
Get-Job | Receive-Job
sleep 5 &&
curl --fail -I http://localhost:8888/
Get-Job | Stop-Job
Get-job | Remove-Job
test-docker-image:
runs-on: ubuntu-latest
name: Test Docker image on linux/amd64
needs: build-docker
container: 'muveex/kikoeru:dev'
steps:
- name: Show running process
run: ps -a
- name: Test
run: |
set -e
apk update && apk add curl
nohup node /usr/src/kikoeru/app.js &
sleep 10 && cat nohup.out 2>/dev/null &&
curl --fail -I http://localhost:8888/
pkill -TERM node
publish:
runs-on: ubuntu-18.04
name: Prepare release draft
if: startsWith(github.ref, 'refs/tags/')
needs: [test-pkg-archive]
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Packup artifacts
run: cd artifacts && for i in */; do zip -r "${i%/}.zip" "$i"; done
- name: List artifacts
run: ls -al artifacts/
- name: Release
uses: softprops/action-gh-release@v1
with:
draft: true
files:
artifacts/kikoeru-*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}