hate-no-d/.forgejo/workflows/release.yml
pedro-bento 3b9bbd529a
All checks were successful
release / linux/aarch64 (push) Successful in 1m55s
release / linux/armv7 (push) Successful in 2m18s
release / linux/i686 (push) Successful in 2m11s
release / linux/x86_64 (push) Successful in 1m54s
release / android (push) Successful in 2m50s
release / freebsd/x86_64 (push) Successful in 4m55s
release / windows/i686 (push) Successful in 2m7s
release / windows/x86_64 (push) Successful in 2m11s
Add raylib
Co-authored-by: pedro-bento <mail@pbento.pt>
Co-committed-by: pedro-bento <mail@pbento.pt>
2026-10-22 22:47:20 +01:00

311 lines
12 KiB
YAML

# Build every supported target and attach the binaries to a Forgejo release.
#
# push / pull_request -> build only
# tag 'v*' -> build + release assets
#
# Assets: one archive per target, named hate-no-d-<os>-<arch>.tar.gz (zip on
# Windows), each unpacking to a directory of the same name holding the binary
# plus LICENSE and README.md. Release attachments are a flat list with no
# folders, so the archive is what groups a target's files together.
# macOS lives in apple.yml; everything here builds on the Linux runner.
name: release
on:
push:
branches: [master]
tags: ['v*']
pull_request:
workflow_dispatch:
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
# Forgejo ignores `permissions:`; the workflow token already has write access
# to its own repo, and fork PRs never reach the tag-gated upload steps.
env:
FORGEJO_API_URL: ${{ github.server_url }}/api/v1
FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }}
jobs:
# ---------------------------------------------------------------------------
# Linux. bookworm sets the glibc 2.36 floor (Debian 12, Ubuntu 24.04+) and is
# shared with the android/windows jobs. Do not fall back to bullseye: its LTS
# ended 2026-08 and deb.debian.org no longer serves bullseye-security.
# ---------------------------------------------------------------------------
linux:
name: linux/${{ matrix.arch }}
runs-on: docker
container:
image: node:20-bookworm # node + git: actions/checkout is a JS action
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
machine: X86-64
make_args: ''
multiarch: ''
packages: 'libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev'
# 32-bit target: leaving HOST_CC unset keeps minilua/buildvm 32-bit
# too. Host and target pointer sizes must match -- do not use HOST_CC=gcc.
- arch: i686
machine: 'Intel 80386'
make_args: 'CC="gcc -m32"'
multiarch: 'i386'
packages: 'gcc-multilib libc6-dev-i386 libx11-dev:i386 libxrandr-dev:i386 libxinerama-dev:i386 libxcursor-dev:i386 libxi-dev:i386 libgl-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'
multiarch: 'arm64'
packages: 'gcc-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user-static libx11-dev:arm64 libxrandr-dev:arm64 libxinerama-dev:arm64 libxcursor-dev:arm64 libxi-dev:arm64 libgl-dev:arm64'
# 32-bit target, so the host tools must be 32-bit too. gcc-multilib
# cannot be installed (gcc-12-arm-linux-gnueabihf conflicts with it);
# lib32gcc-12-dev + libc6-dev-i386 replace it, and linux-libc-dev:i386
# adds the 32-bit asm/ headers.
- arch: armv7
machine: ARM
make_args: 'CC=arm-linux-gnueabihf-gcc HOST_CC="gcc -m32"'
multiarch: 'armhf i386'
packages: 'gcc-arm-linux-gnueabihf libc6-dev-armhf-cross lib32gcc-12-dev libc6-dev-i386 linux-libc-dev:i386 qemu-user-static libx11-dev:armhf libxrandr-dev:armhf libxinerama-dev:armhf libxcursor-dev:armhf libxi-dev:armhf libgl-dev:armhf'
steps:
- name: Checkout
uses: https://data.forgejo.org/actions/checkout@v4
with:
submodules: false
- name: Fetch submodules
run: git submodule update --init --recursive
- name: Install toolchain
run: |
set -eu
# raylib's GLFW backend needs the X11/GL headers even when only a
# static archive is produced, and the final link needs the target's
# libX11/libGL stubs. Cross jobs therefore install the *foreign* arch
# dev packages; only the native job installs the host's.
# armv7 additionally needs linux-libc-dev:i386 for its 32-bit host
# tools (gcc -m32), hence two foreign arches there.
if [ -n '${{ matrix.multiarch }}' ]; then
for arch in ${{ matrix.multiarch }}; do
dpkg --add-architecture "$arch"
done
fi
apt-get update -qq
apt-get install -y --no-install-recommends \
make gcc libc6-dev binutils jq curl ca-certificates luajit ${{ matrix.packages }}
- name: Build
run: make ${{ matrix.make_args }} all
# A mis-set CC silently yields a host binary, so check the ELF machine.
- name: Verify architecture
run: |
set -eu
readelf -h ./hate-no-d | grep -F 'Machine:' | grep -F '${{ matrix.machine }}'
echo "architecture ok: ${{ matrix.machine }}"
# The parser tables are generated into build/api from the pinned raylib
# headers, so assert they still reproduce the shipped binding byte for
# byte before it goes into a release archive.
- name: Verify bindings
run: make check-bindings
- name: Package
run: sh .forgejo/scripts/make-archive.sh "hate-no-d-linux-${{ matrix.arch }}" tar.gz ./hate-no-d ./hate-no-d.lua
- name: Attach to release
if: startsWith(github.ref, 'refs/tags/')
run: sh .forgejo/scripts/release-asset.sh "./hate-no-d-linux-${{ matrix.arch }}.tar.gz"
# ---------------------------------------------------------------------------
# Android. One job for all ABIs so the ~630 MB NDK is downloaded once. The
# binaries are Bionic ELF, so only the ELF header can be checked here.
# ---------------------------------------------------------------------------
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: false
- name: Fetch submodules
run: git submodule update --init --recursive
- name: Install toolchain
# gcc-multilib: armeabi-v7a needs 32-bit host tools.
run: |
set -eu
apt-get update -qq
apt-get install -y --no-install-recommends \
make gcc libc6-dev binutils jq curl ca-certificates unzip luajit \
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'
mkdir -p "dist/$abi"
cp ./hate-no-d "dist/$abi/hate-no-d"
done
- name: Package
run: |
set -eu
for abi in arm64-v8a armeabi-v7a x86_64; do
sh .forgejo/scripts/make-archive.sh "hate-no-d-android-$abi" tar.gz \
"dist/$abi/hate-no-d" ./hate-no-d.lua
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 "hate-no-d-android-$abi.tar.gz"
done
# ---------------------------------------------------------------------------
# FreeBSD. Compiled inside a QEMU/KVM guest, so no FreeBSD runner is needed.
# The container must expose /dev/kvm (act_runner: options: "--device /dev/kvm"),
# otherwise QEMU falls back to TCG and the boot crawls. ~1m40s end to end.
# ---------------------------------------------------------------------------
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: false
- name: Fetch submodules
run: git submodule update --init --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 .
# Both artifacts come back from the guest (the VM builds its own
# hate-no-d.lua), so package dist/, not the checked-out copy.
- name: Package
run: |
sh .forgejo/scripts/make-archive.sh hate-no-d-freebsd-x86_64 tar.gz \
dist/hate-no-d dist/hate-no-d.lua
- name: Attach to release
if: startsWith(github.ref, 'refs/tags/')
run: sh .forgejo/scripts/release-asset.sh ./hate-no-d-freebsd-x86_64.tar.gz
# ---------------------------------------------------------------------------
# Windows. Cross-compiled with mingw-w64; no Windows machine or MSVC involved.
# i686 needs a 32-bit host compiler for the native buildvm. The asset is a zip
# (Windows convention) holding hate-no-d.exe; the toolchain is not part of the
# name because it is not a compatibility axis for anyone downloading it.
# ---------------------------------------------------------------------------
windows:
name: windows/${{ matrix.arch }}
runs-on: docker
container:
image: node:20-bookworm
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
host_cc: gcc
- arch: i686
host_cc: gcc -m32
steps:
- name: Checkout
uses: https://data.forgejo.org/actions/checkout@v4
with:
submodules: false
- name: Fetch submodules
run: git submodule update --init --recursive
# --no-install-recommends omits libc6-dev, and minilua needs limits.h.
# zip: the release asset is a .zip, matching the Windows convention.
- 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 zip luajit
- 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"
# raylib imports the Win32 system DLLs (gdi32/user32/shell32/winmm)
# plus what the mingw link records (advapi32/ole32/...); anything
# outside that set is a toolchain DLL leaking into a release. Names
# are case-insensitive: mingw writes WINMM.dll, not winmm.dll.
# (opengl32 is in the list for the MSVC path, where it does appear.)
bad=$(printf '%s\n' "$deps" | grep -viE '^(kernel32|gdi32|user32|shell32|winmm|opengl32|advapi32|ole32|oleaut32|uuid|msvcrt|api-ms-win-[a-z0-9-]+)\.dll$' || true)
[ -z "$bad" ] || { echo "unexpected runtime DLL dependency: $bad" >&2; exit 1; }
# raylib loads GL through the driver at runtime, so there is no
# opengl32 import to assert; what must hold is that ffi.C can resolve
# raylib through the exe's export table (PE has no --export-dynamic).
${{ matrix.arch }}-w64-mingw32-objdump -p "./$bin" | grep -qw InitWindow \
|| { echo "hate-no-d.exe does not export raylib symbols" >&2; exit 1; }
- name: Package
run: |
sh .forgejo/scripts/make-archive.sh "hate-no-d-windows-${{ matrix.arch }}" zip \
./hate-no-d.exe ./hate-no-d.lua
- name: Attach to release
if: startsWith(github.ref, 'refs/tags/')
run: sh .forgejo/scripts/release-asset.sh "./hate-no-d-windows-${{ matrix.arch }}.zip"