-
Notifications
You must be signed in to change notification settings - Fork 6
334 lines (330 loc) · 16.9 KB
/
main.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
name: CI
on:
push:
branches: [ master ]
tags-ignore:
- '*'
pull_request:
branches: [ master ]
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
actions: none
checks: none
contents: write
deployments: none
id-token: none
issues: none
packages: none
pages: none
pull-requests: none
repository-projects: none
security-events: none
statuses: none
env:
# secrets.GITHUB_TOKEN is restricted by default instead of permissive, so it does not allow release publishing. We can use a Personal Access Token with limited scope and expiration, or configure the token for this workflow using the 'permissions' key
# GITHUB_TOKEN_RELEASE_PUBLISH: ${{ secrets.RELEASE_PUBLISH }}
GITHUB_TOKEN_RELEASE_PUBLISH: ${{ secrets.GITHUB_TOKEN }}
# Electron Builder workaround
USE_HARD_LINKS: 'false'
jobs:
build:
# if: "!contains(toJSON(github.event.commits.*.message), '[skip-ci]')"
if: "github.event_name == 'pull_request' || !contains(github.event.head_commit.message, 'skip ci')"
runs-on: ${{ matrix.runson }}
strategy:
fail-fast: false
matrix:
# ------------------------------
# uncomment below to use GitHub Actions to generate all but MacOS artefacts (MacOS = KeyChain code-signing certificate + notarization, Windows = signed in a VM manually using a USB hardware token)
osarch: [windows-intel, windows-arm, linux-intel, linux-arm]
include:
- osarch: windows-intel
runson: windows-latest #windows-2022
packname: win
release_tag: latest-windows-intel-prod
- osarch: windows-arm
runson: windows-latest #windows-2022
packname: win
release_tag: latest-windows-arm-prod
- osarch: linux-intel
runson: ubuntu-20.04 #ubuntu-latest is ubuntu-24.04
packname: linux
release_tag: latest-linux-intel-prod
- osarch: linux-arm
runson: ubuntu-20.04 #ubuntu-latest is ubuntu-24.04
packname: linux
release_tag: latest-linux-arm-prod
# ------------------------------
# osarch: [windows-intel, windows-arm, macos-intel, macos-arm, linux-intel, linux-arm]
# AceApp for MacOS x64 and arm64 is built on GitHub Actions arm64 runners
# AceApp for Linux x64 and arm64 is built on GitHub Actions x64 runners
# AceApp for Windows x64 and arm64 is built on GitHub Actions x64 runners
# To ensure arm64, the trick is:
# npm ci --foreground-scripts --arch=arm64 --cpu=arm64
# Replace "x64" with "arm64" in `package.json` (and optionally the electron-builder `src/package.json`, if needed)
# To ensure x64, the trick is:
# npm ci --foreground-scripts --arch=x64 --cpu=x64
# `package.json` already specifies "x64"
# windows-latest is currently windows-2022
# https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md
# windows-2025 is beta / public preview
# https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-Readme.md
# https://github.com/actions/runner-images/issues/11228
# windows-11-preview_aarch64 ?
# https://github.com/actions/partner-runner-images/issues/19#issuecomment-2569992032
# macos-latest is currently macos-14-arm64
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
# macos-15-arm64 is beta / public preview
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md
# ubuntu-latest is ubuntu-24.04
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
# ubuntu-20.04 is the oldest available (used here)
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2004-Readme.md
# include:
# - osarch: windows-intel
# runson: windows-latest #windows-2022
# packname: win
# release_tag: latest-windows-intel
# - osarch: windows-arm
# runson: windows-latest #windows-2022
# packname: win
# release_tag: latest-windows-arm
# - osarch: macos-intel
# runson: macos-latest #macos-14-arm64
# packname: 'mac:skip-notarize'
# release_tag: latest-macos-intel
# - osarch: macos-arm
# runson: macos-latest #macos-14-arm64
# packname: 'mac:skip-notarize'
# release_tag: latest-macos-arm
# - osarch: linux-intel
# runson: ubuntu-20.04 #ubuntu-latest is ubuntu-24.04
# packname: linux
# release_tag: latest-linux-intel
# - osarch: linux-arm
# runson: ubuntu-20.04 #ubuntu-latest is ubuntu-24.04
# packname: linux
# release_tag: latest-linux-arm
env:
RELEASE_TAG: ${{ matrix.release_tag }}
steps:
# graceful fail?
- run: |-
pwdx || echo OK || true
shell: cmd
continue-on-error: true
- name: Microsoft Windows dumpbin to PATH
if: startsWith(matrix.osarch, 'windows-')
run: >
$VS_ROOT = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC"; $VS_VERSION = (Get-ChildItem -Path $VS_ROOT | Sort-Object Name -Descending | Select-Object -First 1).Name; $VS_BIN = "$VS_ROOT\$VS_VERSION\bin\Hostx64\x64"; echo $VS_BIN >> $env:GITHUB_PATH; echo $VS_BIN
shell: powershell
- name: Microsoft Windows dumpbin check
if: startsWith(matrix.osarch, 'windows-')
run: >
dumpbin /headers "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34433\bin\Hostx64\x64\dumpbin.exe" | findstr /i machine
shell: cmd
# - name: Microsoft Windows msbuild to PATH
# if: startsWith(matrix.osarch, 'windows-')
# uses: microsoft/setup-msbuild@v2
# "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin"
# "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools"
# "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\bin\amd64"
# "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64"
# "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34433\bin\Hostx64\x64"
- run: echo 'RELEASE_TAG:' ${{ env.RELEASE_TAG }}
- run: 'echo "GITHUB_RUN_NUMBER: ${{ github.run_number }}"'
- run: 'echo "GITHUB_RUN_ID: ${{ github.run_id }}"'
- run: 'echo "GITHUB_SHA: ${{ github.sha }}"'
- run: echo "${{ matrix.osarch }} // ${{ runner.arch }}"
- name: System arch (non Windows)
#if: ${{ matrix.osarch != 'windows-intel' && matrix.osarch != 'windows-arm' }}
if: ${{ !startsWith(matrix.osarch, 'windows-') }}
run: uname -m && arch
- name: Checkout
uses: actions/checkout@v4
# with:
# persist-credentials: false
# - name: Git config global dump (pre)
# run: 'git config --global --list || echo NO_GIT_GLOBAL_CONFIG || true'
# shell: bash
# - name: Git config local dump (pre)
# run: 'git config --list || echo NO_GIT_GLOBAL_CONFIG || true'
# shell: bash
# - name: git HTTP authentication instead SSH (NPM >=7) 1
# run: >
# git config --global url."https://github.com/".insteadOf ssh://[email protected]/
# shell: bash
# - name: git HTTP authentication instead SSH (NPM >=7) 2
# run: >
# git config --global url."https://github.com".insteadOf ssh://[email protected]
# shell: bash
# - name: git HTTP authentication instead SSH (NPM >=7) 3
# run: >
# git config --global url."http://github.com/".insteadOf [email protected]:
# shell: bash
# - name: git HTTP authentication instead SSH (NPM >=7) 4
# run: >
# git config --global url."http://".insteadOf git://
# shell: bash
- name: Git config global dump (post)
run: 'git config --global --list || echo NO_GIT_GLOBAL_CONFIG || true'
shell: bash
- name: Git config local dump (post)
run: 'git config --list || echo NO_GIT_GLOBAL_CONFIG || true'
shell: bash
- uses: actions/setup-node@v4
with:
node-version: '22'
#check-latest: true
- run: node --version && npm --version
- run: npm --global install npm@^10
- run: npm --version
- run: npm --global install yarn@^1
# - run: ((curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.22.5) || echo "YARN OK")
# - run: export PATH="$HOME/.yarn/bin:$PATH"
- run: yarn --version
- run: yarn config set network-timeout 300000 || echo ok
# - run: yarn --global install asar
- name: package patch 1
if: ${{ !endsWith(matrix.release_tag, '-prod') }}
run: node build/package-ci-patch.js package.json ${{ github.run_id }} && cat package.json | grep -i VERSION && cat package.json
shell: bash
- name: package patch 2
if: ${{ !endsWith(matrix.release_tag, '-prod') }}
run: node build/package-ci-patch.js package-asar.json ${{ github.run_id }} && cat package-asar.json | grep -i VERSION && cat package-asar.json
shell: bash
- name: package patch 3
if: ${{ !endsWith(matrix.release_tag, '-prod') }}
run: node build/package-ci-patch.js package-asar-dev.json ${{ github.run_id }} && cat package-asar-dev.json | grep -i VERSION && cat package-asar-dev.json
shell: bash
- run: git submodule init && git submodule update
- run: git --no-pager diff package.json && git --no-pager diff package-asar.json && git --no-pager diff package-asar-dev.json
- run: git --no-pager diff
- run: npm cache clean --force
- run: npm cache verify
#- run: pwd && ls && cd .. && pwd && ls && git clone https://github.com/daisy/ace.git && cd ace && pwd && ls && git checkout ace-next-local-packs && yarn ace-app-prepare && pwd && ls && cd .. && pwd && ls && cd ace-gui && pwd && ls
#- run: rm -f yarn.lock && rm -rf node_modules && yarn install
- name: YARN install (arm64) (non Windows)
#if: ${{ matrix.osarch == 'linux-arm' || matrix.osarch == 'macos-arm' }}
if: ${{ !startsWith(matrix.osarch, 'windows-') && endsWith(matrix.osarch, '-arm') }}
run: export npm_config_arch=arm64 && export npm_config_cpu=arm64 && yarn --frozen-lockfile
#--arch=arm64
- name: YARN install (arm64) (Windows)
#if: ${{ startsWith(matrix.osarch, 'windows-') && endsWith(matrix.osarch, '-arm') }}
if: ${{ matrix.osarch == 'windows-arm' }}
run: SET "npm_config_arch=arm64" && SET "npm_config_cpu=arm64" && yarn --frozen-lockfile
shell: cmd
#--arch=arm64
- name: YARN install (x64) (non Windows)
#if: ${{ matrix.osarch == 'linux-intel' || matrix.osarch == 'macos-intel' }}
if: ${{ !startsWith(matrix.osarch, 'windows-') && endsWith(matrix.osarch, '-intel') }}
run: export npm_config_arch=x64 && export npm_config_cpu=x64 && yarn --frozen-lockfile
#--arch=x64
- name: YARN install (x64) (Windows)
#if: ${{ startsWith(matrix.osarch, 'windows-') && endsWith(matrix.osarch, '-intel') }}
if: ${{ matrix.osarch == 'windows-intel' }}
run: SET "npm_config_arch=x64" && SET "npm_config_cpu=x64" && yarn --frozen-lockfile
shell: cmd
#--arch=x64
- name: Electron version + arch (Windows)
#if: ${{ matrix.osarch == 'windows-intel' || matrix.osarch == 'windows-arm' }}
if: startsWith(matrix.osarch, 'windows-')
run: >
(dumpbin /headers "node_modules\electron\dist\electron.exe" | findstr /i machine) && (node_modules\\electron\\dist\\electron.exe --no-sandbox --version || echo INVALID_ARCH || true) && (node_modules\\electron\\dist\\electron.exe --no-sandbox --abi || echo INVALID_ARCH || true)
shell: cmd
continue-on-error: true
- name: Electron version + arch (Linux)
#if: ${{ matrix.osarch == 'linux-intel' || matrix.osarch == 'linux-arm' }}
if: startsWith(matrix.osarch, 'linux-')
run: >
(file node_modules/electron/dist/electron) && (node_modules/electron/dist/electron --no-sandbox --version || echo INVALID_ARCH) && (node_modules/electron/dist/electron --no-sandbox --abi || echo INVALID_ARCH)
- name: Electron version + arch (MacOS)
#if: ${{ matrix.osarch == 'macos-intel' || matrix.osarch == 'macos-arm' }}
if: startsWith(matrix.osarch, 'macos-')
run: >
(file node_modules/electron/dist/Electron.app/Contents/MacOS/Electron) && (node_modules/electron/dist/Electron.app/Contents/MacOS/Electron --no-sandbox --version || echo INVALID_ARCH) && (node_modules/electron/dist/Electron.app/Contents/MacOS/Electron --no-sandbox --abi || echo INVALID_ARCH)
- name: PR action (just build)
if: ${{ github.event_name == 'pull_request' }}
run: yarn build:prod
- name: non-PR action (build and package) ARM
#if: ${{ github.event_name != 'pull_request' && (matrix.osarch == 'linux-arm' || matrix.osarch == 'windows-arm' || matrix.osarch == 'macos-arm') }}
if: ${{ github.event_name != 'pull_request' && endsWith(matrix.osarch, '-arm') }}
#run: sed 's/x64/arm64/g' ./package.json > ./package.json.new && mv ./package.json.new ./package.json && yarn package:${{ matrix.packname }} && sed 's/arm64/x64/g' ./package.json > ./package.json.new && mv ./package.json.new ./package.json
run: >
node -e 'const path = require("path"); const fs = require("fs"); const filePath = path.join(process.cwd(), "package.json"); let fileStr = fs.readFileSync(filePath, { encoding: "utf8" }); fileStr = fileStr.replace(/x64/g, "arm64"); fs.writeFileSync(filePath, fileStr, { encoding: "utf8" });' && yarn package:${{ matrix.packname }}
- name: non-PR action (build and package) INTEL
#if: ${{ github.event_name != 'pull_request' && (matrix.osarch == 'linux-intel' || matrix.osarch == 'windows-intel' || matrix.osarch == 'macos-intel') }}
if: ${{ github.event_name != 'pull_request' && endsWith(matrix.osarch, '-intel') }}
run: yarn package:${{ matrix.packname }}
#- run: ls -alsR release
#- run: npm install @octokit/rest
- name: GitHub Tagged Release Delete/ReCreate and Upload Build Artefacts
if: ${{ github.event_name != 'pull_request' }}
run: node build/release-github.mjs
# - name: Upload Artifact
# if: ${{ github.event_name != 'pull_request' }}
# uses: actions/upload-artifact@v2
# with:
# name: AceApp
# path: ./release/*.exe
# - name: Delete Release
# if: ${{ github.event_name != 'pull_request' }}
# uses: author/action-rollback@stable
# with:
# tag: $RELEASE_TAG
# always_delete_tag: true
# - name: GitHub Release
# if: ${{ github.event_name != 'pull_request' }}
# id: create_release
# uses: actions/create-release@v1
# with:
# tag_name: $RELEASE_TAG
# release_name: '[$RELEASE_TAG] continuous test build (prerelease)'
# body: 'GitHub Action build job: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID'
# draft: false
# prerelease: true
# - name: GitHub Release Assets
# if: ${{ github.event_name != 'pull_request' }}
# id: upload-release-asset
# uses: actions/upload-release-asset@v1
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./release/*.exe
# asset_name: AceApp.exe
# asset_content_type: application/octet-stream
# - name: GitHub Script Release And Assets
# if: ${{ github.event_name != 'pull_request' }}
# env:
# - GH_RELEASE_ID: ${{ steps.create_release.outputs.id }}
# uses: actions/github-script@v2
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# console.log('process.versions', process.versions, process.env.GH_RELEASE_ID);
# const fs = require('fs').promises;
# const { repo: { owner, repo }, sha } = context;
# /*
# const release = await github.repos.createRelease({
# name: `[${process.env.RELEASE_TAG}] continuous test build (prerelease)`,
# body: `GitHub Action build job: ${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`,
# owner,
# repo,
# tag_name: process.env.RELEASE_TAG,
# draft: false,
# prerelease: true,
# target_commitish: sha
# });
# */
# for (let file of await fs.readdir('release')) {
# if (!file.endsWith('.exe') || !file.endsWith('.AppImage') || !file.endsWith('.msi') || !file.endsWith('.deb') || !file.endsWith('.dmg')) {
# continue;
# }
# await github.repos.uploadReleaseAsset({
# owner,
# repo,
# release_id: process.env.GH_RELEASE_ID, // release.data.id,
# name: file,
# data: await fs.readFile(`./release/${file}`)
# });
# }