45
45
- true
46
46
- false
47
47
default : ' false'
48
+ macosonly :
49
+ description : Do you wish to build only for macOS (primarily for testing)?
50
+ type : choice
51
+ required : false
52
+ options :
53
+ - true
54
+ - false
55
+ default : ' false'
48
56
env :
49
57
INPUT_VERSION : ${{ github.event.inputs.version }}
50
58
INPUT_TARGET : ${{ github.event.inputs.target }}
63
71
jobs :
64
72
65
73
Release_Linux :
66
- if : github.event.inputs.win11only != 'true'
74
+ if : github.event.inputs.win11only != 'true' && github.event.inputs.macosonly != 'true'
67
75
runs-on : ubuntu-latest
68
76
steps :
69
77
- uses : actions/checkout@v4
@@ -141,7 +149,7 @@ jobs:
141
149
npx electron-builder --linux AppImage:ia32 --projectDir dist
142
150
fi
143
151
- name : Upload packages to Kiwix
144
- if : github.ref_name == 'main' && github. event.inputs.target != 'artefacts'
152
+ if : github.event.inputs.target != 'artefacts'
145
153
run : |
146
154
echo "$SSH_KEY" > ./scripts/ssh_key
147
155
chmod 600 ./scripts/ssh_key
@@ -157,7 +165,85 @@ jobs:
157
165
dist/bld/Electron/*.deb
158
166
dist/bld/Electron/*.rpm
159
167
168
+ Release_macOS :
169
+ if : github.event.inputs.win11only != 'true'
170
+ runs-on : macos-latest
171
+ steps :
172
+ - uses : actions/checkout@v4
173
+ - uses : actions/setup-node@v4
174
+ - name : Install dependencies
175
+ run : npm install
176
+ - name : Rewrite app version number and file name
177
+ run : |
178
+ chmod +x ./scripts/rewrite_app_version_number.sh
179
+ ./scripts/rewrite_app_version_number.sh
180
+ # Replace -app in archive name for Electron apps (BSD sed syntax for macOS)
181
+ sed -i '' -E 's/(mdwiki[^-]+)-app_/\1_/g' ./www/js/init.js
182
+ - name : Build production code
183
+ run : npm run build-min
184
+ - name : Download archive if needed
185
+ run : |
186
+ echo "Changing to the dist directory"
187
+ cd dist && pwd
188
+ # Get archive name
189
+ packagedFile=$(grep -m1 'params\[.packagedFile' www/js/init.js | sed -E "s/^.+'([^']+\.zim)'.+/\1/")
190
+ # If packagedFile doesn't match a zim file, we don't need to download anything, so exit
191
+ if [[ ! $packagedFile =~ \.zim$ ]]; then
192
+ echo -e "\nNo zim file to download.\n"
193
+ exit 0
194
+ fi
195
+ # If file doesn't exist in FS, download it
196
+ if [ ! -f "archives/$packagedFile" ]; then
197
+ # Generalize the name if cron_launched and download it
198
+ if [[ $CRON_LAUNCHED = true ]]; then
199
+ packagedFileGeneric=$(sed -E 's/_[0-9-]+(\.zim)/\1/' <<<"$packagedFile")
200
+ echo -e "\nDownloading https://download.kiwix.org/zim/$packagedFileGeneric"
201
+ wget -nv "https://download.kiwix.org/zim/$packagedFileGeneric" -O "archives/$packagedFile"
202
+ else
203
+ flavour=$(sed -E 's/^([^_]+)_.+$/\1/' <<<"$packagedFile")
204
+ if [[ $flavour = "mdwiki" ]]; then
205
+ flavour='other'
206
+ fi
207
+ echo -e "\nDownloading https://mirror.download.kiwix.org/zim/$flavour/$packagedFile"
208
+ wget -nv "https://mirror.download.kiwix.org/zim/$flavour/$packagedFile" -O "archives/$packagedFile"
209
+ fi
210
+ fi
211
+ ls archives
212
+ if [ -f "archives/$packagedFile" ]; then
213
+ echo -e "\nFile $packagedFile now available in 'archives'.\n"
214
+ else
215
+ echo -e "\nError! We could not obtain the requested archive $packagedFile!\n"
216
+ exit 1
217
+ fi
218
+ - name : Build macOS packages
219
+ env :
220
+ USE_HARD_LINKS : false
221
+ run : |
222
+ echo "Installing dependencies in dist"
223
+ cd dist && npm install && cd ..
224
+ echo "Building macOS packages for ref_name=$REF_NAME..."
225
+ if [[ $REF_NAME = "main" ]]; then
226
+ npx electron-builder --mac zip:x64 zip:arm64 --projectDir dist
227
+ else
228
+ npx electron-builder --mac zip:x64 zip:arm64 --projectDir dist
229
+ fi
230
+ - name : Upload packages to Kiwix
231
+ if : github.event.inputs.target != 'artefacts'
232
+ run : |
233
+ echo "$SSH_KEY" > ./scripts/ssh_key
234
+ chmod 600 ./scripts/ssh_key
235
+ chmod +x ./scripts/publish_macos_packages_to_kiwix.sh
236
+ ./scripts/publish_macos_packages_to_kiwix.sh
237
+ - name : Archive build artefacts
238
+ if : github.event.inputs.target == 'artefacts'
239
+ uses : actions/upload-artifact@v4
240
+ with :
241
+ name : kiwix-js-electron_macos
242
+ path : |
243
+ dist/bld/Electron/*.zip
244
+
160
245
Release_Windows :
246
+ if : github.event.inputs.macosonly != 'true'
161
247
runs-on : windows-latest
162
248
env :
163
249
SIGNTOOL_PATH : " C:/Program Files (x86)/Windows Kits/10/bin/10.0.22621.0/x86/signtool.exe"
@@ -358,8 +444,8 @@ jobs:
358
444
if ($Env:REF_NAME -eq "main") {
359
445
./scripts/Publish-ElectronPackages.ps1 -portableonly
360
446
} else {
361
- echo "DEV: Note that only nightly builds launched from main will be published to the Kiwix server... "
362
- ./scripts/Publish-ElectronPackages.ps1 -portableonly -githubonly
447
+ echo "DEV: Note that this is a manual test build from branch $Env:REF_NAME "
448
+ ./scripts/Publish-ElectronPackages.ps1 -portableonly
363
449
}
364
450
- name : Archive build artefacts
365
451
if : github.event.inputs.target == 'artefacts'
@@ -374,7 +460,7 @@ jobs:
374
460
dist/bld/Electron/nsis-web/*.nsis.7z
375
461
376
462
Release_NWJS :
377
- if : github.ref_name == 'main' && github.event.inputs.win11only != 'true'
463
+ if : github.ref_name == 'main' && github.event.inputs.win11only != 'true' && github.event.inputs.macosonly != 'true'
378
464
runs-on : windows-latest
379
465
steps :
380
466
- uses : actions/checkout@v4
@@ -437,7 +523,12 @@ jobs:
437
523
$INPUT_VERSION = $Env:INPUT_VERSION
438
524
$INPUT_TARGET = $Env:INPUT_TARGET
439
525
$CRON_LAUNCHED = $Env:CRON_LAUNCHED
440
- ./scripts/Publish-ElectronPackages.ps1
526
+ if ($Env:REF_NAME -eq "main") {
527
+ ./scripts/Publish-ElectronPackages.ps1
528
+ } else {
529
+ echo "DEV: Note that this is a manual test build from branch $Env:REF_NAME"
530
+ ./scripts/Publish-ElectronPackages.ps1
531
+ }
441
532
- name : Archive build artefacts
442
533
if : github.event.inputs.target == 'artefacts'
443
534
uses : actions/upload-artifact@v4
0 commit comments