-
-
Notifications
You must be signed in to change notification settings - Fork 2
387 lines (323 loc) · 10.5 KB
/
build.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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
name: Build Racine components
on:
push:
tags:
- "v*.*.*"
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
version:
name: Determine version
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.version_step.outputs.VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Determine version
id: version_step
run: |
sed s'/v//g' <(echo "VERSION=`make version`") >> "$GITHUB_OUTPUT"
build-app-static:
name: Build app-static
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- name: Build app-static
run: |
make app-deps app-dev-deps
make js-build
- name: Upload app-static
uses: actions/upload-artifact@v4
with:
name: app-static
path: app/static/
build-base:
name: Build base image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# TODO figure out why this step takes so long each time (why are python requirements reinstalled each time?)
# NOTE: it seems to take long to export Docker image actually -> do we really need the docker image to build app static ?
- name: Build docker image
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
push: false
target: racine-base
tags: racine-base:latest
cache-from: type=gha
cache-to: type=gha,mode=max
build-dev:
name: Build dev image
runs-on: ubuntu-latest
needs: [build-base, build-app-static]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download app-static
uses: actions/download-artifact@v4
with:
name: app-static
path: app/static/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build docker image
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
push: false
target: racine-dev
tags: racine-dev:latest
cache-from: type=gha
cache-to: type=gha,mode=max
build-docker:
name: Build main image
runs-on: ubuntu-latest
needs: [build-base, build-app-static]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download app-static
uses: actions/download-artifact@v4
with:
name: app-static
path: app/static/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build docker image
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
push: false
target: racine
tags: racine:latest
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/racine.tar
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: racine
path: /tmp/racine.tar
run-tests:
name: Run tests in docker
runs-on: ubuntu-latest
needs: build-docker
env:
COMPOSE_FILE: docker/docker-compose.yml
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run tests
run: docker compose run web python -m pytest
push-docker:
if: github.event_name == 'push'
name: Push docker image
runs-on: ubuntu-latest
needs: [build-docker, run-tests, version]
env:
COMPOSE_FILE: docker/docker-compose.yml
steps:
- name: Login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: racine
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/racine.tar
docker image ls -a
- name: Push to ghcr
run: |
docker tag racine:latest \
ghcr.io/hgrf/racine:latest && \
docker push ghcr.io/hgrf/racine:latest && \
echo Successfully pushed ghcr.io/hgrf/racine:latest
- name: Push to ghcr (tagged)
if: startsWith(github.ref, 'refs/tags/')
run: |
sed s'/refs\/tags\///g' <(echo "${{ github.ref }}") | (read TAG; \
docker tag ghcr.io/hgrf/racine:latest \
ghcr.io/hgrf/racine:$TAG && \
docker push ghcr.io/hgrf/racine:$TAG && \
echo Successfully pushed ghcr.io/hgrf/racine:$TAG
)
build-appimage:
name: Build AppImage
runs-on: ubuntu-latest
needs: [version, build-app-static]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- name: Install developer dependencies
run: make app-deps app-dev-deps
- name: Download app-static
uses: actions/download-artifact@v4
with:
name: app-static
path: app/static/
- name: Build AppImage
run: make desktop-dist
- uses: actions/upload-artifact@v4
with:
name: "RacineDesktop AppImage ${{ needs.version.outputs.VERSION }}"
path: "desktop/dist/RacineDesktop-${{ needs.version.outputs.VERSION }}.AppImage"
build-macos:
name: Build macOS x64 executable
runs-on: macos-latest
needs: [version, build-app-static]
env:
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- name: Install developer dependencies
run: make app-deps app-dev-deps
- name: Download app-static
uses: actions/download-artifact@v4
with:
name: app-static
path: app/static/
- name: Build executable
run: make desktop-dist
- uses: actions/upload-artifact@v4
with:
name: "RacineDesktop ${{ needs.version.outputs.VERSION }} macOS x64 dmg"
path: "desktop/dist/RacineDesktop-${{ needs.version.outputs.VERSION }}.dmg"
build-macos-arm64:
name: Build macOS arm64 executable
runs-on: macos-14
needs: [version, build-app-static]
env:
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- name: Install developer dependencies
run: make app-deps app-dev-deps
- name: Download app-static
uses: actions/download-artifact@v4
with:
name: app-static
path: app/static/
- name: Build executable
run: make desktop-dist
- uses: actions/upload-artifact@v4
with:
name: "RacineDesktop ${{ needs.version.outputs.VERSION }} macOS arm64 dmg"
path: "desktop/dist/RacineDesktop-${{ needs.version.outputs.VERSION }}-arm64.dmg"
build-windows:
name: Build Windows executable
runs-on: windows-latest
needs: [version, build-app-static]
env:
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- name: Install developer dependencies
run: make app-deps app-dev-deps
shell: bash
# c.f. https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
- name: Download app-static
uses: actions/github-script@v7
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.run_id }},
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == 'app-static'
})[0];
if (!matchArtifact) {
throw new Error('Could not find app-static artifact');
}
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/app-static.zip`, Buffer.from(download.data));
- name: Unzip app-static
run: unzip -o app-static.zip -d app/static/
- name: Build executable
run: make desktop-dist
- uses: actions/upload-artifact@v4
with:
name: "RacineDesktop Setup ${{ needs.version.outputs.VERSION }}"
path: "desktop/dist/RacineDesktop Setup ${{ needs.version.outputs.VERSION }}.exe"
release:
name: Publish release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [version, build-appimage, build-macos, build-macos-arm64, build-windows, build-docker, run-tests]
steps:
- name: Download AppImage
uses: actions/download-artifact@v4
with:
name: "RacineDesktop AppImage ${{ needs.version.outputs.VERSION }}"
- name: Download macOS x64 executable
uses: actions/download-artifact@v4
with:
name: "RacineDesktop ${{ needs.version.outputs.VERSION }} macOS x64 dmg"
- name: Download macOS arm64 executable
uses: actions/download-artifact@v4
with:
name: "RacineDesktop ${{ needs.version.outputs.VERSION }} macOS arm64 dmg"
- name: Download Windows executable
uses: actions/download-artifact@v4
with:
name: "RacineDesktop Setup ${{ needs.version.outputs.VERSION }}"
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
RacineDesktop-${{ needs.version.outputs.VERSION }}.AppImage
RacineDesktop-${{ needs.version.outputs.VERSION }}.dmg
RacineDesktop-${{ needs.version.outputs.VERSION }}-arm64.dmg
RacineDesktop Setup ${{ needs.version.outputs.VERSION }}.exe