-
Notifications
You must be signed in to change notification settings - Fork 6
403 lines (354 loc) · 14.8 KB
/
release.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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# Copyright (c) 2021 Concurrent Technologies Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software is distributed under the License is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing permissions and limitations under the License.
---
name: Automatic Release
on:
push:
tags:
- 'v*.*.*'
env:
node_version: 18
export_cmd: |
GIT_TAG=$(echo ${GITHUB_REF#refs/*/} | cut -d 'v' -f 2)
PKG_VERSION=$(echo $(node -p "JSON.stringify(require('./package.json').version)") | sed 's|"||g')
echo "GIT_TAG=$GIT_TAG" >> $GITHUB_ENV
echo "PKG_VERSION=$PKG_VERSION" >> $GITHUB_ENV
jobs:
quality-gate:
name: Quality Gate
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Count lines of code (CLOC) 📐
id: cloc
uses: djdefi/cloc-action@6
- name: Check ratCheck ✅
uses: fountainhead/[email protected]
id: rat-check
with:
token: ${{ secrets.GITHUB_TOKEN }}
# This check name is defined as the github action job name (in .github/workflows/testing.yaml)
checkName: "Rat Check 🐀"
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Check Scala format ✅
uses: fountainhead/[email protected]
id: scala-format
with:
token: ${{ secrets.GITHUB_TOKEN }}
# This check name is defined as the github action job name (in .github/workflows/testing.yaml)
checkName: "Scala Code Format"
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Check TypeScript format ✅
uses: fountainhead/[email protected]
id: ts-format
with:
token: ${{ secrets.GITHUB_TOKEN }}
# This check name is defined as the github action job name (in .github/workflows/testing.yaml)
checkName: "TypeScript code is properly formatted"
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Check tests - macOS 13 ✅
uses: fountainhead/[email protected]
id: macos13-tests
with:
token: ${{ secrets.GITHUB_TOKEN }}
# This check name is defined as the github action job name (in .github/workflows/testing.yaml)
checkName: "Build middleware macos-13 🔧"
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Check tests - macOS 14 ✅
uses: fountainhead/[email protected]
id: macos14-tests
with:
token: ${{ secrets.GITHUB_TOKEN }}
# This check name is defined as the github action job name (in .github/workflows/testing.yaml)
checkName: "Build middleware macos-14 🔧"
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Check tests - Linux ✅
uses: fountainhead/[email protected]
id: ubuntu-tests
with:
token: ${{ secrets.GITHUB_TOKEN }}
# This check name is defined as the github action job name (in .github/workflows/testing.yaml)
checkName: "Build middleware ubuntu-20.04 🔧"
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Check tests - Windows ✅
uses: fountainhead/[email protected]
id: windows-tests
with:
token: ${{ secrets.GITHUB_TOKEN }}
# This check name is defined as the github action job name (in .github/workflows/testing.yaml)
checkName: "Build middleware windows-2019 🔧"
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Check native build arm64 - Linux ✅
uses: fountainhead/[email protected]
id: ubuntu-arm64-native
with:
token: ${{ secrets.GITHUB_TOKEN }}
# This check name is defined as the github action job name (in .github/workflows/testing.yaml)
checkName: "Native build ubuntu-20.04 arm64 🦙"
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Quality Gate ✅
if: |
steps.rat-check.outputs.conclusion != 'success' ||
steps.scala-format.outputs.conclusion != 'success' ||
steps.ts-format.outputs.conclusion != 'success' ||
steps.macos13-tests.outputs.conclusion != 'success' ||
steps.macos14-tests.outputs.conclusion != 'success' ||
steps.ubuntu-tests.outputs.conclusion != 'success' ||
steps.ubuntu-arm64-native.outputs.conclusion != 'success' ||
steps.windows-tests.outputs.conclusion != 'success'
run: |
echo "Rat Check Status: ${{ steps.rat-check.conclusion }}"
echo "Scala Format Status: ${{ steps.scala-format.conclusion }}"
echo "Typescript Format Status: ${{ steps.ts-format.conclusion }}"
echo "MacOS 13 Test Status: ${{ steps.macos13-tests.outputs.conclusion }}"
echo "MacOS 14 Test Status: ${{ steps.macos14-tests.outputs.conclusion }}"
echo "Ubuntu Test Status: ${{ steps.ubuntu-tests.conclusion }}"
echo "Ubuntu ARM64 Native Status: ${{ steps.ubuntu-arm64-native.conclusion }}"
echo "Windows Test Status: ${{ steps.windows-tests.conclusion }}"
false
create-release:
name: Create Release ✨
needs: [quality-gate]
runs-on: ubuntu-20.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Export git tag and package.json version 🚢
run: ${{ env.export_cmd }}
- name: Check if pre-release ✅
run: |
if [[ ${{ env.GIT_TAG }} == *"pre-"* || ${{ env.GIT_TAG }} == *"-pre"* ]]; then
echo "PRE_RELEASE=true" >> $GITHUB_ENV
else
echo "PRE_RELEASE=false" >> $GITHUB_ENV
fi
shell: bash
- name: Create release 🔧
uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: "${{ env.PRE_RELEASE }}"
- name: Create upload_url file 🔧
run: echo "${{ steps.create_release.outputs.upload_url }}" > upload_url
- name: Upload upload_url 🔺
uses: actions/upload-artifact@v4
with:
name: upload_url
path: upload_url
scala-publish:
needs: [create-release]
name: Scala Publish API, Native and Server ✨
runs-on: ubuntu-20.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Export git tag and package.json version 🚢
run: ${{ env.export_cmd }}
shell: bash
- name: Download upload_url 🔻
uses: actions/download-artifact@v4
with:
name: upload_url
- name: Add upload_url to GITHUB_ENV
run: |
UPLOAD_URL=$(cat upload_url)
echo "UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV
- name: Setup Java ☕
uses: actions/[email protected]
with:
distribution: temurin
java-version: 8
cache: sbt
- name: Make _install directory to store lib files
run: mkdir -p _install
- name: Download linux x86 library file 🔻
uses: dawidd6/action-download-artifact@v7
with:
workflow: tests.yml
branch: main
workflow_conclusion: success
name: ubuntu-20.04-x64-libomega_edit.so
path: _install/libomega_edit_linux_amd64.so
- name: Download linux arm64 library file 🔻
uses: dawidd6/action-download-artifact@v7
with:
workflow: tests.yml
branch: main
workflow_conclusion: success
name: ubuntu-20.04-arm64-libomega_edit.so
path: _install/libomega_edit_linux_aarch64.so
- name: Download macos-13 library file 🔻
uses: dawidd6/action-download-artifact@v7
with:
workflow: tests.yml
branch: main
workflow_conclusion: success
name: macos-13-x64-libomega_edit.dylib
path: _install/libomega_edit_macos_x86_64.dylib
- name: Download macos-14 library file 🔻
uses: dawidd6/action-download-artifact@v7
with:
workflow: tests.yml
branch: main
workflow_conclusion: success
name: macos-14-arm64-libomega_edit.dylib
path: _install/libomega_edit_macos_aarch64.dylib
- name: Download windows library file 🔻
uses: dawidd6/action-download-artifact@v7
with:
workflow: tests.yml
branch: main
workflow_conclusion: success
name: windows-2019-x64-omega_edit.dll
path: _install/omega_edit_windows_64.dll
- name: Move out library files 🛻
run: |
for lib_filename in \
"libomega_edit_linux_amd64.so" \
"libomega_edit_linux_aarch64.so" \
"libomega_edit_macos_x86_64.dylib" \
"libomega_edit_macos_aarch64.dylib" \
"omega_edit_windows_64.dll"
do
downloaded_filename=$(echo $lib_filename \
| sed "s|_linux_amd64||g" \
| sed "s|_linux_aarch64||g" \
| sed "s|_macos_x86_64||g" \
| sed "s|_macos_aarch64||g" \
| sed "s|_windows_64||g"
)
mv -v "${lib_filename}" "${lib_filename}_dir"
mv -v "${lib_filename}_dir/$downloaded_filename" "$lib_filename"
rm -rf "${lib_filename}_dir"
done
working-directory: _install
shell: bash
###########################
## Scala publish process ##
###########################
- name: Package Scala Native 🎁
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IS_RELEASE: true
run: sbt native/publish
working-directory: server/scala
- name: Package Scala API 🎁
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IS_RELEASE: true
run: sbt api/publish
working-directory: server/scala
- name: Package Scala RPC server 🎁
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IS_RELEASE: true
SERVER_RELEASE: true
run: |
rm -rf ~/.m2/repository
sbt serv/Universal/packageBin
working-directory: server/scala
shell: bash
- name: Fix folder name for Scala RPC server 🔧
run: |
mv -v \
server/scala/serv/target/universal/omega-edit-grpc-server-${{ env.PKG_VERSION }}.zip \
omega-edit-grpc-server-${{ env.PKG_VERSION }}.zip
- name: Upload Scala RPC server - Not Release 🔺
uses: actions/upload-artifact@v4
with:
name: omega-edit-grpc-server-${{ env.PKG_VERSION }}.zip
path: omega-edit-grpc-server-${{ env.PKG_VERSION }}.zip
- name: Upload Scala RPC server - Release 🔺
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: ./omega-edit-grpc-server-${{ env.PKG_VERSION }}.zip
asset_name: omega-edit-grpc-server-${{ env.PKG_VERSION }}.zip
asset_content_type: application/tar+gzip
node-build:
name: Node Release ✨
runs-on: ubuntu-20.04 # NOTE: build on older OS versions to support older OS versions
needs: [scala-publish]
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Export git tag and package.json version 🚢
run: ${{ env.export_cmd }}
- name: Download upload_url 🔻
uses: actions/download-artifact@v4
with:
name: upload_url
- name: Add upload_url to GITHUB_ENV 📐
run: |
UPLOAD_URL=$(cat upload_url)
echo "UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV
##########################
## Node release process ##
##########################
- name: Setup Node 📐
uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
node-version: ${{ env.node_version }}
- name: Download scala release file 🔻
uses: actions/download-artifact@v4
with:
name: omega-edit-grpc-server-${{ env.PKG_VERSION }}.zip
path: omega-edit-grpc-server-${{ env.PKG_VERSION }}.zip
- name: Extract scala server file 🛻
run: |
scala_pkg_file="omega-edit-grpc-server-${{ env.PKG_VERSION }}.zip"
mv -v "${scala_pkg_file}" "${scala_pkg_file}_dir"
mv -v "${scala_pkg_file}_dir/${scala_pkg_file}" "${scala_pkg_file}"
rm -rf "${scala_pkg_file}_dir"
mkdir -p server/scala/serv/target/universal || true
mv "$scala_pkg_file" "server/scala/serv/target/universal/$scala_pkg_file"
- name: Create server and client package tarball file 🔧
run: |
yarn
yarn package-no-sbt # create both client and server package
- name: Upload node server release tarball 🔺
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: ./packages/server/omega-edit-node-server-v${{ env.PKG_VERSION }}.tgz
asset_name: omega-edit-node-server-v${{ env.PKG_VERSION }}.tgz
asset_content_type: application/tar+gzip
- name: Upload node client release tarball 🔺
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: ./packages/client/omega-edit-node-client-v${{ env.PKG_VERSION }}.tgz
asset_name: omega-edit-node-client-v${{ env.PKG_VERSION }}.tgz
asset_content_type: application/tar+gzip
- name: Publish server node package to npm registry 🚀
run: yarn publish -f --access=public
working-directory: packages/server/out
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: ${{ contains(github.event.head_commit.message, '[node_publish]') }}
- name: Publish client node package to npm registry 🚀
run: yarn publish -f --access=public
working-directory: packages/client/out
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: ${{ contains(github.event.head_commit.message, '[node_publish]') }}