Skip to content

Build

Build #15

Workflow file for this run

# Builds all engines for amd64 and arm64 architectures,
# creates a new GitHub release with built binaries.
#
# SPDX-FileCopyrightText: 2026 Ivan Krasilnikov
# SPDX-License-Identifier: MIT
name: Build
on:
workflow_dispatch:
schedule:
- cron: '0 3 1,15 * *' # biweekly, 1st and 15th of month at 03:00 UTC
permissions:
contents: write # gh release create/edit/upload
packages: write # GHCR push
jobs:
# Init vars and create draft release
init:
runs-on: ubuntu-24.04
outputs:
build_date: ${{ steps.init.outputs.build_date }}
engines_amd64: ${{ steps.init.outputs.engines_amd64 }}
engines_arm64: ${{ steps.init.outputs.engines_arm64 }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Set BUILD_DATE and engine lists
id: init
run: |
BUILD_DATE=$(date +%Y%m%d)
echo "build_date=$BUILD_DATE" >> "$GITHUB_OUTPUT"
AMD64=$(cd engines && DOCKER_ARCH=amd64 make list | jq -R . | jq -sc .)
echo "engines_amd64=$AMD64" >> "$GITHUB_OUTPUT"
ARM64=$(cd engines && DOCKER_ARCH=arm64 make list | jq -R . | jq -sc .)
echo "engines_arm64=$ARM64" >> "$GITHUB_OUTPUT"
- name: Create draft release
run: |
BUILD_DATE=${{ steps.init.outputs.build_date }}
gh release delete $BUILD_DATE --yes 2>/dev/null || true
gh release create $BUILD_DATE --title $BUILD_DATE --draft --target $GITHUB_SHA
# Builds base toolchain images (build/jsz-*.Dockerfile) and pushes them to GHCR.
# Images are tagged {name}:{arch}, e.g.:
# ghcr.io/ivankra/javascript-zoo/jsz-gcc:amd64
# ghcr.io/ivankra/javascript-zoo/jsz-clang23:arm64
base:
needs: init
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
runner: [ubuntu-24.04, ubuntu-24.04-arm]
steps:
- name: Log in to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: Build and push base toolchain images
run: DOCKER_PUSH=1 DOCKER_REGISTRY=ghcr.io/ivankra/javascript-zoo make -C build all
# Builder for amd64 binaries
engine-amd64:
needs: [init, base]
runs-on: ubuntu-24.04
timeout-minutes: 360
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
fail-fast: false
matrix:
engine: ${{ fromJson(needs.init.outputs.engines_amd64) }}
steps:
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
- name: Log in to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: System info
run: uname -a; lscpu; cat /proc/cpuinfo; gcc -march=native -Q --help=target
- name: Build engine
uses: nick-fields/retry@v3
with:
max_attempts: 3
timeout_minutes: 360
command: DIST_REMOVE_IMAGE=1 DOCKER_REGISTRY=ghcr.io/ivankra/javascript-zoo make -C engines/${{ matrix.engine }} dist
- name: Pack dist artifact tarball
run: tar -cf dist-amd64-${{ matrix.engine }}.tar -C dist/amd64 .
- name: Upload dist artifact
uses: actions/upload-artifact@v4
with:
name: dist-amd64-${{ matrix.engine }}
path: dist-amd64-${{ matrix.engine }}.tar
if-no-files-found: error
- name: Package and upload to release
run: |
rm -f dist/amd64/jscript-dist/jscript*.dll dist/amd64/jscript9-dist/jscript*.dll # proprietary DLLs, amd64 only
rm -f dist/amd64/*.dbg
tar -c -C dist/amd64 . | zstd -19 -o ${{ matrix.engine }}.amd64.tar.zst
gh release upload ${{ needs.init.outputs.build_date }} ${{ matrix.engine }}.amd64.tar.zst \
|| (sleep 15 && gh release upload ${{ needs.init.outputs.build_date }} ${{ matrix.engine }}.amd64.tar.zst) \
|| (sleep 30 && gh release upload ${{ needs.init.outputs.build_date }} ${{ matrix.engine }}.amd64.tar.zst)
- name: Cleanup
if: always()
run: rm -rf dist/
# Builder for arm64 binaries
engine-arm64:
needs: [init, base]
runs-on: ubuntu-24.04-arm
timeout-minutes: 360
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
fail-fast: false
matrix:
engine: ${{ fromJson(needs.init.outputs.engines_arm64) }}
steps:
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
- name: Log in to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: System info
run: uname -a; lscpu; cat /proc/cpuinfo; gcc -march=native -Q --help=target
- name: Build engine
uses: nick-fields/retry@v3
with:
max_attempts: 3
timeout_minutes: 360
command: |
DIST_REMOVE_IMAGE=1 DOCKER_REGISTRY=ghcr.io/ivankra/javascript-zoo make -C engines/${{ matrix.engine }} dist
- name: Pack dist artifact tarball
run: tar -cf dist-arm64-${{ matrix.engine }}.tar -C dist/arm64 .
- name: Upload dist artifact
uses: actions/upload-artifact@v4
with:
name: dist-arm64-${{ matrix.engine }}
path: dist-arm64-${{ matrix.engine }}.tar
if-no-files-found: error
- name: Package and upload to release
run: |
rm -f dist/arm64/*.dbg
tar -c -C dist/arm64 . | zstd -19 -o ${{ matrix.engine }}.arm64.tar.zst
gh release upload ${{ needs.init.outputs.build_date }} ${{ matrix.engine }}.arm64.tar.zst \
|| (sleep 15 && gh release upload ${{ needs.init.outputs.build_date }} ${{ matrix.engine }}.arm64.tar.zst) \
|| (sleep 30 && gh release upload ${{ needs.init.outputs.build_date }} ${{ matrix.engine }}.arm64.tar.zst)
- name: Cleanup
if: always()
run: rm -rf dist/
publish:
needs: [init, engine-amd64, engine-arm64]
runs-on: ubuntu-24.04
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Publish release
run: |
gh release edit ${{ needs.init.outputs.build_date }} --draft=false --repo ${{ github.repository }} \
|| (sleep 15 && gh release edit ${{ needs.init.outputs.build_date }} --draft=false --repo ${{ github.repository }}) \
|| (sleep 30 && gh release edit ${{ needs.init.outputs.build_date }} --draft=false --repo ${{ github.repository }})
# Create and push Docker Hub image from the latest GitHub release.
hub:
needs: [init, publish]
runs-on: ubuntu-24.04
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: Log in to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
- name: Build and push ghcr.io/ivankra/javascript-zoo/hub
run: build/hub.sh ghcr.io/ivankra/javascript-zoo/hub ${{ needs.init.outputs.build_date }}
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login docker.io -u ivankra --password-stdin
- name: Build and push docker.io/ivankra/javascript-zoo
run: build/hub.sh docker.io/ivankra/javascript-zoo ${{ needs.init.outputs.build_date }}