forked from dattaz/libzim_wasm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add options to build release and nightly wasm versions from kiwix-bui…
- Loading branch information
Showing
3 changed files
with
78 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ | |
name: Build and publish release artefacts (Docker) | ||
|
||
on: | ||
schedule: | ||
# Nightly run at 02:21 UTC | ||
- cron: '21 02 * * *' | ||
push: | ||
branches: [ main ] | ||
tags: | ||
|
@@ -19,12 +22,26 @@ on: | |
If left blank or incorrect format, archives will be archived instead of being uploaded to Releases. | ||
required: false | ||
default: '' | ||
|
||
buildtype: | ||
description: | | ||
Choose the build type - 'source' (from source code, i.e., built from scratch - this takes a long time), | ||
'release' (from libzim released binary and dependencies - recommended), or 'nightly' (from the latest libzim | ||
nightly release) | ||
type: choice | ||
options: | ||
- source | ||
- release | ||
- nightly | ||
default: 'release' | ||
required: true | ||
|
||
# Define top-level environment vars we can refer to below | ||
env: | ||
VERSION: ${{ github.ref_name }} | ||
DISPATCH_VERSION: ${{ github.event.inputs.version }} | ||
DISPATCH_TYPE: ${{ github.event.inputs.buildtype }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SSH_KEY: ${{ secrets.SSH_KEY }} | ||
|
||
jobs: | ||
build: | ||
|
@@ -35,8 +52,21 @@ jobs: | |
# Customizes the Emscripten docker container via the Dockerfile in this repo | ||
- name: Build the Docker image | ||
run: docker build -t "docker-emscripten-libzim:v3" ./docker | ||
# If we're building release version | ||
- name: Build release from libzim binaries | ||
if: github.event_name == 'pull_request' || github.event_name == 'push' || github.event.inputs.buildtype == 'release' | ||
run: | | ||
make libzim_release | ||
docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) docker-emscripten-libzim:v3 make release | ||
# If we're building nightly version | ||
- name: Build nightly from libzim binaries | ||
if: github.event.schedule || github.event.inputs.buildtype == 'nightly' | ||
run: | | ||
make libzim_nightly | ||
docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) docker-emscripten-libzim:v3 make nightly | ||
# Creates the ASM and WASM artefacts, and the JS wrappers, using the Makefile in this repo | ||
- name: Compile the libzim WASM artefacts | ||
- name: Compile the libzim WASM artefacts from source | ||
if: github.event.inputs.buildtype == 'source' | ||
run: docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) docker-emscripten-libzim:v3 make | ||
- name: List directories with updated archives | ||
run: | | ||
|
@@ -50,15 +80,15 @@ jobs: | |
- name: Archive build artefacts | ||
if: | | ||
github.event_name == 'pull_request' || github.event_name == 'push' && ! startsWith(github.ref_name, 'v') | ||
|| ! startsWith(github.event.inputs.version, 'v') | ||
|| github.event.inputs.buildtype != 'nightly' && ! github.event.schedule && ! startsWith(github.event.inputs.version, 'v') | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: libzim-wasm-artefacts | ||
path: | | ||
libzim-wasm.* | ||
libzim-asm.* | ||
tests/test_large_file_access/large_file_access.* | ||
# Otherwise, zip the artefacts into respective packages (asm and wasm), create and upload releases | ||
# If it's a release, zip the artefacts into respective packages (asm and wasm), create and upload releases | ||
- name: Zip the artefacts and create draft release | ||
id: zip-release | ||
if: github.event_name == 'push' && startsWith(github.ref_name, 'v') || startsWith(github.event.inputs.version, 'v') | ||
|
@@ -69,3 +99,18 @@ jobs: | |
# Create a draft release and upload zipped artefacts as release assets | ||
chmod +x ./scripts/create_draft_release.sh | ||
./scripts/create_draft_release.sh | ||
# If it's a nightly build, zip artefacts and upload releases | ||
- name: Zip the artefacts and upload to nightly | ||
if: github.event.schedule || github.event.inputs.buildtype == 'nightly' | ||
run: | | ||
echo "$SSH_KEY" > ./scripts/ssh_key | ||
chmod 600 ./scripts/ssh_key | ||
CURRENT_DATE=$(date +'%Y-%m-%d') | ||
target="/data/openzim/nightly/$CURRENT_DATE" | ||
zip libzim-javascript_wasm_$CURRENT_DATE.zip libzim-wasm.* | ||
zip libzim-javascript_asm_$CURRENT_DATE.zip libzim-asm.* | ||
for FILE in "libzim-javascript_wasm_$CURRENT_DATE.zip" "libzim-javascript_asm_$CURRENT_DATE.zip" | ||
do | ||
echo "Copying $FILE to $target" | ||
scp -P 30022 -o StrictHostKeyChecking=no -i ./scripts/ssh_key "$FILE" [email protected]:$target | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,6 @@ | |
/icu4c-*.tgz | ||
/xapian-core-*.tar.xz | ||
/libzim-* | ||
/libzim_wasm-*.tar.gz | ||
ssh_key | ||
github_token | ||
github_token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters