# Build hate-no-d for every supported target and attach the binaries to a Forgejo release. # # push to master / pull request -> build only # push a tag matching 'v*' -> build + release assets # workflow_dispatch -> same as a branch push # # Release assets are uploaded straight to the REST API, one file per platform: # hate-no-d-linux-{x86_64,i686,aarch64,armv7} # hate-no-d-macos-{arm64,x86_64} # hate-no-d-android-{arm64-v8a,armeabi-v7a,x86_64} # hate-no-d-windows_mingw_w64-{x64,x86}.exe # hate-no-d-ios-arm64-luajit.a # hate-no-d-freebsd-x86_64 # # Only Apple's targets need more than the Linux runner, and they are gated # behind a repository variable set to "true" (needs a matching runner): # ENABLE_MACOS (macOS runner, label: macos) -> macos + ios jobs name: release on: push: branches: [master] tags: ['v*'] pull_request: workflow_dispatch: concurrency: group: release-${{ github.ref }} cancel-in-progress: true # Note: Forgejo ignores `permissions:` entirely. The automatic workflow token # already has write access to its own repository, which is what the release # steps rely on. Forked pull requests get a read-only token, but they never # reach the upload steps (those are tag-gated). env: FORGEJO_API_URL: ${{ github.server_url }}/api/v1 FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} TAG: ${{ github.ref_name }} jobs: # --------------------------------------------------------------------------- # Linux. Built on Debian bullseye so the binaries carry a glibc 2.31 floor # (Debian 11, Ubuntu 20.04+, RHEL 9). Bumping the image silently raises that # floor, so do not move it without meaning to. # --------------------------------------------------------------------------- linux: name: linux/${{ matrix.arch }} runs-on: docker container: image: node:20-bullseye # node + git: actions/checkout is a JS action strategy: fail-fast: false matrix: include: - arch: x86_64 machine: X86-64 make_args: '' packages: '' # 32-bit target: HOST_CC defaults to $(CC), so leaving HOST_CC # unset builds minilua/buildvm 32-bit too. LuaJIT requires host and # target pointer sizes to match -- do not "optimise" this to # HOST_CC=gcc. - arch: i686 machine: 'Intel 80386' make_args: 'CC="gcc -m32"' packages: 'gcc-multilib libc6-dev-i386' # 64-bit host -> 64-bit target, so host tools stay native. - arch: aarch64 machine: AArch64 make_args: 'CC=aarch64-linux-gnu-gcc HOST_CC=gcc' packages: 'gcc-aarch64-linux-gnu qemu-user-static' # 32-bit target: the 32-bit host tools are mandatory here. - arch: armv7 machine: ARM make_args: 'CC=arm-linux-gnueabihf-gcc HOST_CC="gcc -m32"' packages: 'gcc-arm-linux-gnueabihf qemu-user-static gcc-multilib libc6-dev-i386' steps: - name: Checkout uses: https://data.forgejo.org/actions/checkout@v4 with: submodules: recursive - name: Install toolchain run: | set -eu apt-get update -qq apt-get install -y --no-install-recommends \ make gcc libc6-dev binutils jq curl ca-certificates ${{ matrix.packages }} - name: Build run: make ${{ matrix.make_args }} all # Guards the cross builds: a mis-set CROSS/CC silently yields a host # binary, which is otherwise indistinguishable until it is run. - name: Verify architecture run: | set -eu readelf -h ./hate-no-d | grep -F 'Machine:' | grep -F '${{ matrix.machine }}' echo "architecture ok: ${{ matrix.machine }}" - name: Attach to release if: startsWith(github.ref, 'refs/tags/') run: sh .forgejo/scripts/release-asset.sh ./hate-no-d "hate-no-d-linux-${{ matrix.arch }}" # --------------------------------------------------------------------------- # Android. One job for all three ABIs: the NDK is a ~630 MB download and # sharing it beats three parallel copies. The resulting binaries are Bionic # ELF, so they cannot be executed here -- only the ELF header is checked. # --------------------------------------------------------------------------- android: name: android runs-on: docker container: image: node:20-bookworm env: ANDROID_NDK_VERSION: r27c ANDROID_NDK: /opt/android-ndk-r27c ANDROID_API: '21' steps: - name: Checkout uses: https://data.forgejo.org/actions/checkout@v4 with: submodules: recursive - name: Install toolchain # gcc-multilib is needed for the 32-bit host tools LuaJIT requires when # the target is 32-bit (armeabi-v7a). run: | set -eu apt-get update -qq apt-get install -y --no-install-recommends \ make gcc libc6-dev binutils jq curl ca-certificates unzip \ gcc-multilib libc6-dev-i386 - name: Install NDK r27c run: | set -eu url="https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux.zip" curl -fsSL -o /tmp/ndk.zip "$url" mkdir -p /opt unzip -q /tmp/ndk.zip -d /opt rm -f /tmp/ndk.zip test -d "$ANDROID_NDK" - name: Build all ABIs run: | set -eu mkdir -p dist for abi in arm64-v8a armeabi-v7a x86_64; do make clean >/dev/null 2>&1 || true if [ "$abi" = armeabi-v7a ]; then make PLATFORM=Android ANDROID_NDK="$ANDROID_NDK" ANDROID_API="$ANDROID_API" \ ANDROID_ABI="$abi" HOST_CC="gcc -m32" all else make PLATFORM=Android ANDROID_NDK="$ANDROID_NDK" ANDROID_API="$ANDROID_API" \ ANDROID_ABI="$abi" HOST_CC=gcc all fi readelf -h ./hate-no-d | grep -F 'Machine:' | grep -E 'AArch64|ARM|X86-64' cp ./hate-no-d "dist/hate-no-d-android-$abi" done - name: Attach to release if: startsWith(github.ref, 'refs/tags/') run: | set -eu for abi in arm64-v8a armeabi-v7a x86_64; do sh .forgejo/scripts/release-asset.sh "dist/hate-no-d-android-$abi" "hate-no-d-android-$abi" done # --------------------------------------------------------------------------- # macOS. Apple SDKs are universal, so either runner arch can cross-build the # other; only the target objects get -arch, the build tools stay native. # --------------------------------------------------------------------------- macos: name: macos/${{ matrix.arch }} if: vars.ENABLE_MACOS == 'true' runs-on: macos strategy: fail-fast: false matrix: arch: [arm64, x86_64] steps: - name: Checkout uses: https://data.forgejo.org/actions/checkout@v4 with: submodules: recursive - name: Build run: | make \ CFLAGS="-O2 -Wall -arch ${{ matrix.arch }}" \ LUAJIT_EXTRA="TARGET_FLAGS=-arch ${{ matrix.arch }}" \ all - name: Verify architecture run: | set -eu file ./hate-no-d file ./hate-no-d | grep -q '${{ matrix.arch }}' - name: Attach to release if: startsWith(github.ref, 'refs/tags/') run: sh .forgejo/scripts/release-asset.sh ./hate-no-d "hate-no-d-macos-${{ matrix.arch }}" # --------------------------------------------------------------------------- # iOS. Deliberately produces no executable: the JIT is compiled out and the # archive is linked into an Xcode app target. Requires jq for the upload. # --------------------------------------------------------------------------- ios: name: ios/arm64 if: vars.ENABLE_MACOS == 'true' runs-on: macos steps: - name: Checkout uses: https://data.forgejo.org/actions/checkout@v4 with: submodules: recursive - name: Build libluajit.a run: make PLATFORM=iOS IOS_ARCH=arm64 all - name: Verify archive run: | set -eu lipo -info submodules/luajit/src/libluajit.a lipo -info submodules/luajit/src/libluajit.a | grep -q arm64 - name: Attach to release if: startsWith(github.ref, 'refs/tags/') run: sh .forgejo/scripts/release-asset.sh submodules/luajit/src/libluajit.a hate-no-d-ios-arm64-luajit.a # --------------------------------------------------------------------------- # FreeBSD. Built inside a FreeBSD VM booted with QEMU/KVM on the Linux runner, # so no FreeBSD runner is needed: the tooling lives on the Linux side and only # the compilation happens in the guest. # # The job container needs /dev/kvm, e.g. in the act_runner config: # container: # options: "--device /dev/kvm" # Without it the script fails immediately rather than crawling along on TCG. # # Measured ~1m40s end to end: 70s boot, ~15s pkg install, ~14s build. # --------------------------------------------------------------------------- bsd: name: freebsd/x86_64 runs-on: docker container: image: node:20-bookworm timeout-minutes: 20 steps: - name: Checkout uses: https://data.forgejo.org/actions/checkout@v4 with: submodules: recursive - name: Install QEMU run: | set -eu apt-get update -qq apt-get install -y --no-install-recommends \ qemu-system-x86 cloud-image-utils openssh-client xz-utils jq - name: Build in FreeBSD VM run: | set -eu mkdir -p dist sh .forgejo/scripts/freebsd-build.sh dist/hate-no-d-freebsd-x86_64 . - name: Attach to release if: startsWith(github.ref, 'refs/tags/') run: sh .forgejo/scripts/release-asset.sh dist/hate-no-d-freebsd-x86_64 hate-no-d-freebsd-x86_64 # --------------------------------------------------------------------------- # Windows. Cross-compiled with mingw-w64 on the Linux runner, so no Windows # machine and no MSVC are involved: the result is a self-contained PE that # imports only KERNEL32/msvcrt. build.bat remains for native MSVC builds. # # i686 needs a 32-bit host compiler: LuaJIT's buildvm runs natively and must # have the target's pointer size. # # Releases are named hate-no-d-windows_mingw_w64-x64.exe and # hate-no-d-windows_mingw_w64-x86.exe. The build itself stays hate-no-d.exe # (same as build.bat); the toolchain-qualified name is only the asset name. # --------------------------------------------------------------------------- windows: name: windows/${{ matrix.arch }} runs-on: docker container: image: node:20-bookworm strategy: fail-fast: false matrix: include: - arch: x86_64 tag: windows_mingw_w64-x64 host_cc: gcc - arch: i686 tag: windows_mingw_w64-x86 host_cc: gcc -m32 steps: - name: Checkout uses: https://data.forgejo.org/actions/checkout@v4 with: submodules: recursive # libc6-dev is not pulled in by gcc under --no-install-recommends, and # without it the host build of minilua cannot find limits.h. - name: Install toolchain run: | set -eu apt-get update -qq apt-get install -y --no-install-recommends \ make gcc libc6-dev gcc-multilib mingw-w64 jq - name: Build run: make PLATFORM=Windows WIN_ARCH=${{ matrix.arch }} HOST_CC="${{ matrix.host_cc }}" all - name: Verify executable run: | set -eu bin=hate-no-d.exe file "./$bin" | grep -q 'for MS Windows' deps=$(${{ matrix.arch }}-w64-mingw32-objdump -p "./$bin" | awk '/DLL Name/{print $3}') echo "$deps" bad=$(printf '%s\n' "$deps" | grep -v -E '^(KERNEL32|msvcrt)\.dll$' || true) [ -z "$bad" ] || { echo "unexpected runtime DLL dependency: $bad" >&2; exit 1; } - name: Attach to release if: startsWith(github.ref, 'refs/tags/') run: sh .forgejo/scripts/release-asset.sh ./hate-no-d.exe hate-no-d-${{ matrix.tag }}.exe