-
-
Notifications
You must be signed in to change notification settings - Fork 399
300 lines (240 loc) · 9.55 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
name: build
on:
push:
paths-ignore:
- '*.md'
- 'docs/**'
pull_request:
paths-ignore:
- '*.md'
- 'docs/**'
env:
# Github container registry https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
REGISTRY: ghcr.io
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# We don't use yarn lint here in order to have faster CI.
# Keep version and script up to date!
- uses: DeLaGuardo/setup-clj-kondo@master
with:
version: '2022.03.09'
- name: Lint
run: clj-kondo --lint src
style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/custom-actions/clojure-env
- name: Style
run: yarn style
carve:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/custom-actions/clojure-env
- name: Carve unused vars
run: yarn carve
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/custom-actions/clojure-env
- uses: ./.github/custom-actions/node-env
- name: Run JVM tests
run: yarn server:test
- name: Run Karma tests
run: yarn client:test
# TODO: these tests cause the test runner to never exist, so they
# can't be ran on CI. Please run them manually for now.
# See https://github.com/fluree/db/issues/163.
# - name: Start Fluree process
# run: yarn server:fluree
# - name: Run Fluree tests
# run: yarn server:test:fluree
# e2e:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: ./.github/custom-actions/clojure-env
# - uses: ./.github/custom-actions/node-env
# # Caching the build is generally a terrible idea, but e2e is really slow
# # and shadow-cljs is usually pretty good at cache invalidation.
# # Still, if you think this cache is breaking builds, just bump the version number.
# - name: Restore shadow-cljs build cache
# uses: actions/cache@v2
# id: restore-shadow-cljs-build-cache
# with:
# path: ./.shadow-cljs
# key: ${{ runner.os }}-v2-shadow-cljs-build-cache-${{ hashFiles('yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-v2-shadow-cljs-build-cache
# - name: Compile JS assets for dev
# run: yarn client:dev-build
# - name: Run client e2e tests over dev build
# run: yarn client:e2e
build-app:
needs: [test, lint, style, carve]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/custom-actions/clojure-env
- uses: ./.github/custom-actions/node-env
- name: Compile JS Assets for production
run: yarn prod --config-merge "{:closure-defines {athens.core/SENTRY_DSN \"${SENTRY_DSN}\" athens.util/COMMIT_URL \"${COMMIT_URL}\"}}"
env:
SENTRY_DSN: ${{ secrets.sentry_dsn }}
COMMIT_URL: "https://github.com/${{github.repository}}/commit/${{github.sha}}"
# - name: Run client e2e tests over the prod build
# run: yarn client:e2e
- name: Upload built app for release-web, release-electron
uses: actions/upload-artifact@v2
with:
name: app
path: resources
release-web:
needs: [build-app]
# Only deploy on v2.* tag pushes to the default branch (main).
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/custom-actions/node-env
- name: Download built app
uses: actions/download-artifact@v2
with:
name: app
path: resources
- name: Copy built app to a vercel prod deploy folder
run: mkdir -p vercel-release/vercel-static/athens && cp -R resources/public/. vercel-release/vercel-static/athens/
- uses: amondnet/vercel-action@v20
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID}}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}}
scope: athens-research
vercel-args: './vercel-release/'
# Poor mans ternary operator https://github.com/actions/runner/issues/409#issuecomment-727565588
alias-domains: ${{ env.PRERELEASE == 'true' && env.PRERELEASE_DOMAIN || env.RELEASE_DOMAIN }}
env:
PRERELEASE: ${{ contains(github.ref, '-alpha.') || contains(github.ref, '-beta.') || contains(github.ref, '-rc.')}}
PRERELEASE_DOMAIN: beta.athensresearch.org
RELEASE_DOMAIN: web.athensresearch.org
release-electron:
needs: [build-app]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ${{ matrix.os }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- uses: ./.github/custom-actions/node-env
- name: Prepare for app notarization (macOS)
if: startsWith(matrix.os, 'macos')
# Import Apple API key for app notarization on macOS
run: |
mkdir -p ~/private_keys/
echo '${{ secrets.api_key }}' > ~/private_keys/AuthKey_${{ secrets.api_key_id }}.p8
- name: Download built app
uses: actions/download-artifact@v2
with:
name: app
path: resources
- name: Build and Publish Electron App
uses: samuelmeuli/action-electron-builder@v1
with:
# Don't run `yarn build`, which otherwise happens by default
skip_build: true
# GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings)
github_token: ${{ secrets.github_token }}
# macOS code signing certificate
mac_certs: ${{ secrets.mac_certs }}
mac_certs_password: ${{ secrets.mac_certs_password }}
# If the commit is tagged with a version (e.g. "v1.0.0"),
# release the app after building
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
env:
# macOS notarization API key
API_KEY_ID: ${{ secrets.api_key_id }}
API_KEY_ISSUER_ID: ${{ secrets.api_key_issuer_id }}
release-server:
runs-on: ubuntu-latest
needs: [test, lint, style, carve, build-app]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v2
- uses: ./.github/custom-actions/clojure-env
- name: Download built app
uses: actions/download-artifact@v2
with:
name: app
path: resources
- name: Compile server code
run: yarn server:compile
- name: Build server executable uberjar
run: yarn server:uberjar
# we need QEMU for multi-arch build
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Github Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract server metadata (tags, labels) for athens docker image
id: athens-meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
- name: Extract server metadata (tags, labels) for nginx docker image
id: nginx-meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/nginx
- name: Build and push athens
uses: docker/build-push-action@v2
with:
# Use the current folder as context instead of the branch.
# Needed to use artifacts like the server jar.
context: .
platforms: linux/amd64,linux/arm64
file: athens.dockerfile
push: true
tags: ${{ steps.athens-meta.outputs.tags }}
labels: ${{ steps.athens-meta.outputs.labels }}
# Use GitHub actions cache.
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#github-cache
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push nginx
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
file: nginx.dockerfile
push: true
tags: ${{ steps.nginx-meta.outputs.tags }}
labels: ${{ steps.nginx-meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Replace version in docker-compose
run: sed -i.bk 's/:latest/:${{ steps.athens-meta.outputs.version }}/' docker-compose.yml
- name: Publish Docker compose
uses: ncipollo/release-action@v1
with:
artifacts: "docker-compose.yml"
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
prerelease: true
draft: true