5
5
name : Build and publish release artefacts (Docker)
6
6
7
7
on :
8
+ schedule :
9
+ # Nightly run at 02:21 UTC
10
+ - cron : ' 21 02 * * *'
8
11
push :
9
12
branches : [ main ]
10
13
tags :
19
22
If left blank or incorrect format, archives will be archived instead of being uploaded to Releases.
20
23
required : false
21
24
default : ' '
22
-
25
+ buildtype :
26
+ description : |
27
+ Choose the build type - 'source' (from source code, i.e., built from scratch - this takes a long time),
28
+ 'release' (from libzim released binary and dependencies - recommended), or 'nightly' (from the latest libzim
29
+ nightly release)
30
+ type : choice
31
+ options :
32
+ - source
33
+ - release
34
+ - nightly
35
+ default : ' release'
36
+ required : true
37
+
23
38
# Define top-level environment vars we can refer to below
24
39
env :
25
40
VERSION : ${{ github.ref_name }}
26
41
DISPATCH_VERSION : ${{ github.event.inputs.version }}
42
+ DISPATCH_TYPE : ${{ github.event.inputs.buildtype }}
27
43
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
44
+ SSH_KEY : ${{ secrets.SSH_KEY }}
28
45
29
46
jobs :
30
47
build :
35
52
# Customizes the Emscripten docker container via the Dockerfile in this repo
36
53
- name : Build the Docker image
37
54
run : docker build -t "docker-emscripten-libzim:v3" ./docker
55
+ # If we're building release version
56
+ - name : Build release from libzim binaries
57
+ if : github.event_name == 'pull_request' || github.event_name == 'push' || github.event.inputs.buildtype == 'release'
58
+ run : |
59
+ make libzim_release
60
+ docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) docker-emscripten-libzim:v3 make release
61
+ # If we're building nightly version
62
+ - name : Build nightly from libzim binaries
63
+ if : github.event.schedule || github.event.inputs.buildtype == 'nightly'
64
+ run : |
65
+ make libzim_nightly
66
+ docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) docker-emscripten-libzim:v3 make nightly
38
67
# Creates the ASM and WASM artefacts, and the JS wrappers, using the Makefile in this repo
39
- - name : Compile the libzim WASM artefacts
68
+ - name : Compile the libzim WASM artefacts from source
69
+ if : github.event.inputs.buildtype == 'source'
40
70
run : docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) docker-emscripten-libzim:v3 make
41
71
- name : List directories with updated archives
42
72
run : |
@@ -50,15 +80,15 @@ jobs:
50
80
- name : Archive build artefacts
51
81
if : |
52
82
github.event_name == 'pull_request' || github.event_name == 'push' && ! startsWith(github.ref_name, 'v')
53
- || ! startsWith(github.event.inputs.version, 'v')
83
+ || github.event.inputs.buildtype != 'nightly' && ! github.event.schedule && ! startsWith(github.event.inputs.version, 'v')
54
84
uses : actions/upload-artifact@v3
55
85
with :
56
86
name : libzim-wasm-artefacts
57
87
path : |
58
88
libzim-wasm.*
59
89
libzim-asm.*
60
90
tests/test_large_file_access/large_file_access.*
61
- # Otherwise , zip the artefacts into respective packages (asm and wasm), create and upload releases
91
+ # If it's a release , zip the artefacts into respective packages (asm and wasm), create and upload releases
62
92
- name : Zip the artefacts and create draft release
63
93
id : zip-release
64
94
if : github.event_name == 'push' && startsWith(github.ref_name, 'v') || startsWith(github.event.inputs.version, 'v')
69
99
# Create a draft release and upload zipped artefacts as release assets
70
100
chmod +x ./scripts/create_draft_release.sh
71
101
./scripts/create_draft_release.sh
102
+ # If it's a nightly build, zip artefacts and upload releases
103
+ - name : Zip the artefacts and upload to nightly
104
+ if : github.event.schedule || github.event.inputs.buildtype == 'nightly'
105
+ run : |
106
+ echo "$SSH_KEY" > ./scripts/ssh_key
107
+ chmod 600 ./scripts/ssh_key
108
+ CURRENT_DATE=$(date +'%Y-%m-%d')
109
+ target="/data/openzim/nightly/$CURRENT_DATE"
110
+ zip libzim-javascript_wasm_$CURRENT_DATE.zip libzim-wasm.*
111
+ zip libzim-javascript_asm_$CURRENT_DATE.zip libzim-asm.*
112
+ for FILE in "libzim-javascript_wasm_$CURRENT_DATE.zip" "libzim-javascript_asm_$CURRENT_DATE.zip"
113
+ do
114
+ echo "Copying $FILE to $target"
115
+ scp -P 30022 -o StrictHostKeyChecking=no -i ./scripts/ssh_key "$FILE" [email protected] :$target
116
+ done
0 commit comments