-
Notifications
You must be signed in to change notification settings - Fork 0
362 lines (316 loc) · 12.6 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
# GitHub Action to build a self-contained binary of the toolkit
---
name: "Build & Release"
on:
push:
branches: [main]
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
env:
HASH_FILENAME_WINDOWS: ucrtool-windows.hash
HASH_FILENAME_MAC: ucrtool-macos.hash
HASH_FILENAME: ucrtool-ubuntu.hash
jobs:
build-windows:
runs-on: windows-latest
strategy:
matrix:
node-version: [ '22.x' ]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# History of 200 should be more than enough to calculate commit count since last release tag.
fetch-depth: 200
- name: Fetch all tags to determine version
run: |
chcp 65001 #set code page to utf-8
git fetch origin +refs/tags/*:refs/tags/*
echo VERSION="v$(jq .version -r package.json)" >> $env:GITHUB_ENV
#echo "VERSION=$(git describe --match "v[0-9]*" --tags HEAD --always)" >> $env:GITHUB_ENV
- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Build Angular
run: |
npm i
# npm run test:ci
# npm run build:ci
npm run-script build
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Build node JS
run: |
cd server
npm ci
echo "Building NodeJS app to bundle compatible with CommonJS format for executable injection"
npx esbuild --format=cjs --target=node22 --platform=node --bundle --outfile=bundle.js dist/app.js
echo "Creating blob for injection"
node --experimental-sea-config sea-config.json
node -e "require('fs').copyFileSync(process.execPath, 'ucrtool-server.exe')"
echo "Injecting blob in NodeJS executable"
npx postject ucrtool-server.exe NODE_SEA_BLOB sea-prep.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
# signtool remove /s ucrtool-server.exe
# signtool sign /fd SHA256 ucrtool-server.exe
- name: Prepare artifacts
shell: bash
run: |
mkdir -p artifacts
cp server/ucrtool-server.exe artifacts/
cp -r server/public artifacts/
echo "ARTIFACT_NAME=ucrtool-${{ env.VERSION }}-windows" >> $GITHUB_ENV
- name: Create upload artifact
run: |
Compress-Archive -Path ${{ github.workspace }}/artifacts/* -Destination ${{ env.ARTIFACT_NAME }}.zip
- uses: actions/upload-artifact@v4
id: upload_artifact
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_NAME }}.zip
if-no-files-found: error
retention-days: 3
build-macos:
runs-on: macos-latest
strategy:
matrix:
node-version: [ '22.x']
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# History of 200 should be more than enough to calculate commit count since last release tag.
fetch-depth: 200
- name: Fetch all tags to determine version
run: |
git fetch origin +refs/tags/*:refs/tags/*
echo VERSION="v$(jq .version -r package.json)" >> $GITHUB_ENV
# echo "VERSION=$(git describe --match "v[0-9]*" --tags HEAD --always)" >> $GITHUB_ENV
- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Build Angular
run: |
npm i
# npm run test:ci
# npm run build:ci
npm run-script build
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Build node JS
run: |
cd server
npm ci
echo "Building NodeJS app to bundle compatible with CommonJS format for executable injection"
npx esbuild --format=cjs --target=node22 --platform=node --bundle --outfile=bundle.js dist/app.js
echo "Creating blob for injection"
node --experimental-sea-config sea-config.json
cp $(command -v node) ucrtool-server
codesign --remove-signature ucrtool-server
echo "Injecting blob in NodeJS executable"
npx postject ucrtool-server NODE_SEA_BLOB sea-prep.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 --macho-segment-name NODE_SEA
codesign --sign - ucrtool-server
- name: Prepare artifacts
shell: bash
run: |
mkdir -p artifacts
cp server/ucrtool-server artifacts/
cp -r server/public artifacts/
echo "ARTIFACT_NAME=ucrtool-${{ env.VERSION }}-macos" >> $GITHUB_ENV
- name: Create upload artifact
shell: bash
run: |
tar czvf ${{ env.ARTIFACT_NAME }}.tar.gz -C ${GITHUB_WORKSPACE}/artifacts .
ls -lah
- uses: actions/upload-artifact@v4
id: upload_artifact
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_NAME }}.tar.gz
if-no-files-found: error
retention-days: 3
build-ubuntu:
runs-on: ubuntu-latest
environment: Ubuntu
strategy:
matrix:
node-version: [ '22.x']
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# History of 200 should be more than enough to calculate commit count since last release tag.
fetch-depth: 200
- name: Fetch all tags to determine version
run: |
git fetch origin +refs/tags/*:refs/tags/*
echo VERSION="v$(jq .version -r package.json)" >> $GITHUB_ENV
# echo "VERSION=$(git describe --match "v[0-9]*" --tags HEAD --always)" >> $GITHUB_ENV
- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Build Angular
run: |
npm i
# npm run test:ci
# npm run build:ci
npm run-script build
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Build node JS
run: |
cd server
npm ci
echo "Building NodeJS app to bundle compatible with CommonJS format for executable injection"
npx esbuild --format=cjs --target=node22 --platform=node --bundle --outfile=bundle.js dist/app.js
echo "Creating blob for injection"
node --experimental-sea-config sea-config.json
cp $(command -v node) ucrtool-server
echo "Injecting blob in NodeJS executable"
npx postject ucrtool-server NODE_SEA_BLOB sea-prep.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
node --experimental-sea-config sea-config.json
# - name: Build docker image
# run : |
# docker login --username albaintor --password ${{ secrets.GH_PAT }} ghcr.io
# docker build . --tag ghcr.io/albaintor/ucr-tool:latest
# docker push ghcr.io/albaintor/ucr-tool:latest
#
# - name: Build and push Docker image
# uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
# with:
# context: .
# args: username=albaintor,password=${{ secrets.GH_PAT }}
# file: Dockerfile
# platforms: ${{ matrix.platforms }}
# push: true
# outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Unfolded Circle Toolkit
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker to Docker Hub
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/uc-tool:latest
- name: Prepare artifacts
shell: bash
run: |
mkdir -p artifacts
cp server/ucrtool-server artifacts/
cp -r server/public artifacts/
echo "ARTIFACT_NAME=ucrtool-${{ env.VERSION }}-aarch64" >> $GITHUB_ENV
- name: Create upload artifact
shell: bash
run: |
tar czvf ${{ env.ARTIFACT_NAME }}.tar.gz -C ${GITHUB_WORKSPACE}/artifacts .
ls -lah
- uses: actions/upload-artifact@v4
id: upload_artifact
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_NAME }}.tar.gz
if-no-files-found: error
retention-days: 3
# npx postject server NODE_SEA_BLOB sea-prep.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
release:
name: Create Release
if: github.ref == 'refs/heads/main' || contains(github.ref, 'tags/v')
runs-on: ubuntu-latest
needs: [build-windows, build-ubuntu, build-macos]
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: ucrtool-*
- name: Extract build archives from downloaded files
run: |
ls -R
# extract tar.gz build archives from downloaded artifacts
# (wrapped in tar from actions/upload-artifact, then extracted into a directory by actions/download-artifact)
for D in *
do if [ -d "${D}" ]; then
mv $D/* ./
fi
done;
# Use a common timestamp for all matrix build artifacts
- name: Get timestamp
run: |
echo "TIMESTAMP=$(date +"%Y%m%d_%H%M%S")" >> $GITHUB_ENV
# Add timestamp to development builds
- name: Create GitHub development build archives
if: "!contains(github.ref, 'tags/v')"
run: |
# append timestamp
for filename in *.zip; do mv $filename "$(basename $filename .zip)-${{ env.TIMESTAMP }}.zip"; done;
for filename in *.zip; do echo "sha256 `sha256sum $filename`" >> ${{ env.HASH_FILENAME_WINDOWS }}; done;
for filename in *aarch64.tar.gz; do echo "sha256 `sha256sum $filename`" >> ${{ env.HASH_FILENAME }}; done;
for filename in *macos.tar.gz; do echo "sha256 `sha256sum $filename`" >> ${{ env.HASH_FILENAME_MAC }}; done;
for filename in *.tar.gz; do mv $filename "$(basename $filename .tar.gz)-${{ env.TIMESTAMP }}.tar.gz"; done;
- name: Create Pre-Release
uses: "marvinpinto/action-automatic-releases@latest"
if: "!contains(github.ref, 'tags/v')"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Development Build"
files: |
*.zip
*.tar.gz
${{ env.HASH_FILENAME_WINDOWS }}
${{ env.HASH_FILENAME }}
- name: Create GitHub release archives
if: "contains(github.ref, 'tags/v')"
run: |
for filename in *.zip; do echo "sha256 `sha256sum $filename`" >> ${{ env.HASH_FILENAME_WINDOWS }}; done;
for filename in *.tar.gz; do echo "sha256 `sha256sum $filename`" >> ${{ env.HASH_FILENAME }}; done;
- name: Create Release
uses: "marvinpinto/action-automatic-releases@latest"
if: "contains(github.ref, 'tags/v')"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
*.tar.gz
*.zip
${{ env.HASH_FILENAME_WINDOWS }}
${{ env.HASH_FILENAME }}
${{ env.HASH_FILENAME_MAC }}