Compare commits

..

2 commits

Author SHA1 Message Date
f552092235 Standardize release workflow
Some checks failed
release / linux/aarch64 (pull_request) Successful in 49s
release / linux/armv7 (pull_request) Successful in 52s
release / linux/i686 (pull_request) Successful in 41s
release / linux/x86_64 (pull_request) Successful in 38s
release / android (pull_request) Successful in 1m36s
release / freebsd/x86_64 (pull_request) Failing after 4m47s
release / windows/i686 (pull_request) Failing after 55s
release / windows/x86_64 (pull_request) Failing after 54s
2026-10-22 12:34:04 +01:00
0589f19985 Standardize release workflow 2026-10-22 12:33:50 +01:00
6 changed files with 228 additions and 32 deletions

View file

@ -1,8 +1,11 @@
#!/bin/sh
# Build hate-no-d inside a FreeBSD VM and copy the binary back.
# Build hate-no-d inside a FreeBSD VM and copy the binary and the static
# library back.
#
# freebsd-build.sh <output-file> [source-dir]
#
# The archive lands next to <output-file> as libhate-no-d.a.
#
# Needs qemu-system-x86, cloud-image-utils, openssh-client, xz and curl, plus
# /dev/kvm (act_runner: options: "--device /dev/kvm"); under TCG the boot takes
# many minutes. The guest runs with -snapshot, so nothing persists.
@ -125,10 +128,12 @@ ssh_vm 'set -e
tar xzf /root/src.tar.gz -C /root/src
cd /root/src
gmake CC=cc clean >/dev/null 2>&1 || true
gmake CC=cc all'
gmake CC=cc all lib'
log "fetching binary"
mkdir -p "$(dirname "$OUT")"
log "fetching artifacts"
mkdir -p "$OUT_DIR"
scp $SCP_OPTS "root@127.0.0.1:/root/src/hate-no-d" "$OUT"
scp $SCP_OPTS "root@127.0.0.1:/root/src/libhate-no-d.a" "$OUT_DIR/libhate-no-d.a"
log "built $OUT ($(wc -c < "$OUT") bytes)"
log "built $OUT_DIR/libhate-no-d.a ($(wc -c < "$OUT_DIR/libhate-no-d.a") bytes)"

View file

@ -0,0 +1,66 @@
#!/bin/sh
# Stage one release asset into a directory and pack it, so every download is a
# self-contained "folder" instead of a bare binary.
#
# make-archive.sh <asset-name> <tar.gz|zip> <payload>...
#
# asset-name e.g. hate-no-d-linux-x86_64; also the directory inside the
# archive, so unpacking never scatters files
# format tar.gz for Unix payloads (keeps the executable bit), zip for
# Windows ones
# payload files to pack, each keeping its basename
#
# LICENSE and README.md are added from the working directory when present.
# Writes ./<asset-name>.<format> and leaves the staging directory behind.
set -eu
if [ $# -lt 3 ]; then
echo "usage: $0 <asset-name> <tar.gz|zip> <payload>..." >&2
exit 2
fi
name=$1
format=$2
shift 2
# Guard the rm -rf below.
case "$name" in
'' | */*) echo "make-archive: bad asset name: '$name'" >&2; exit 2 ;;
esac
case "$format" in
tar.gz | zip) ;;
*) echo "make-archive: unknown format: '$format'" >&2; exit 2 ;;
esac
for f in "$@"; do
[ -f "$f" ] || { echo "make-archive: no such file: $f" >&2; exit 1; }
done
rm -rf "$name"
mkdir -p "$name"
# The first payload is the binary: make its mode deterministic instead of
# trusting whatever the build/copy path produced.
first=1
for f in "$@"; do
cp "$f" "$name/$(basename "$f")"
if [ "$first" = 1 ]; then
chmod 755 "$name/$(basename "$f")"
first=0
fi
done
for f in LICENSE README.md; do
if [ -f "$f" ]; then
cp "$f" "$name/"
fi
done
case "$format" in
tar.gz) tar -czf "$name.tar.gz" "$name" ;;
zip) zip -qr -X "$name.zip" "$name" >/dev/null ;;
esac
echo "make-archive: wrote $name.$format"
ls -l "$name" | sed 's/^/make-archive: /'

View file

@ -45,7 +45,7 @@ jobs:
make \
CFLAGS="-O2 -Wall -arch ${{ matrix.arch }}" \
LUAJIT_EXTRA="TARGET_FLAGS=-arch ${{ matrix.arch }}" \
all
all lib
- name: Verify architecture
run: |
@ -53,9 +53,13 @@ jobs:
file ./hate-no-d
file ./hate-no-d | grep -q '${{ matrix.arch }}'
- name: Package
run: sh .forgejo/scripts/make-archive.sh "hate-no-d-macos-${{ matrix.arch }}" tar.gz \
./hate-no-d ./libhate-no-d.a
- name: Attach to release
if: github.event.inputs.tag != ''
run: sh .forgejo/scripts/release-asset.sh ./hate-no-d "hate-no-d-macos-${{ matrix.arch }}"
run: sh .forgejo/scripts/release-asset.sh "./hate-no-d-macos-${{ matrix.arch }}.tar.gz"
# ---------------------------------------------------------------------------
# iOS. Builds only the archive (JIT compiled out) for an Xcode app target.
@ -72,15 +76,21 @@ jobs:
- name: Fetch submodules
run: git submodule update --init --recursive
- name: Build libluajit.a
run: make PLATFORM=iOS IOS_ARCH=arm64 all
- name: Build static library
run: make PLATFORM=iOS IOS_ARCH=arm64 all lib
- name: Verify archive
run: |
set -eu
lipo -info submodules/luajit/src/libluajit.a
lipo -info submodules/luajit/src/libluajit.a | grep -q arm64
# libhate-no-d.a is what ships; it must be single-arch arm64 Mach-O.
lipo -info ./libhate-no-d.a
lipo -info ./libhate-no-d.a | grep -q arm64
- name: Package
# Only a static archive ships here: iOS forbids JIT, so libhate-no-d.a is
# the deliverable to link into an Xcode target. There is no binary.
run: sh .forgejo/scripts/make-archive.sh hate-no-d-ios-arm64 tar.gz ./libhate-no-d.a
- name: Attach to release
if: github.event.inputs.tag != ''
run: sh .forgejo/scripts/release-asset.sh submodules/luajit/src/libluajit.a hate-no-d-ios-arm64-luajit.a
run: sh .forgejo/scripts/release-asset.sh ./hate-no-d-ios-arm64.tar.gz

View file

@ -3,7 +3,10 @@
# push / pull_request -> build only
# tag 'v*' -> build + release assets
#
# Assets: hate-no-d-linux-*, -android-*, -windows_mingw_w64-*.exe, -freebsd-x86_64.
# 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/iOS live in apple.yml; everything here builds on the Linux runner.
name: release
@ -87,7 +90,7 @@ jobs:
make gcc libc6-dev binutils jq curl ca-certificates ${{ matrix.packages }}
- name: Build
run: make ${{ matrix.make_args }} all
run: make ${{ matrix.make_args }} all lib
# A mis-set CC silently yields a host binary, so check the ELF machine.
- name: Verify architecture
@ -96,9 +99,12 @@ jobs:
readelf -h ./hate-no-d | grep -F 'Machine:' | grep -F '${{ matrix.machine }}'
echo "architecture ok: ${{ matrix.machine }}"
- name: Package
run: sh .forgejo/scripts/make-archive.sh "hate-no-d-linux-${{ matrix.arch }}" tar.gz ./hate-no-d ./libhate-no-d.a
- 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 }}"
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
@ -149,13 +155,23 @@ jobs:
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
ANDROID_ABI="$abi" HOST_CC="gcc -m32" all lib
else
make PLATFORM=Android ANDROID_NDK="$ANDROID_NDK" ANDROID_API="$ANDROID_API" \
ANDROID_ABI="$abi" HOST_CC=gcc all
ANDROID_ABI="$abi" HOST_CC=gcc all lib
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"
mkdir -p "dist/$abi"
cp ./hate-no-d "dist/$abi/hate-no-d"
cp ./libhate-no-d.a "dist/$abi/libhate-no-d.a"
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" "dist/$abi/libhate-no-d.a"
done
- name: Attach to release
@ -163,7 +179,7 @@ jobs:
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"
sh .forgejo/scripts/release-asset.sh "hate-no-d-android-$abi.tar.gz"
done
# ---------------------------------------------------------------------------
@ -197,16 +213,21 @@ jobs:
run: |
set -eu
mkdir -p dist
sh .forgejo/scripts/freebsd-build.sh dist/hate-no-d-freebsd-x86_64 .
sh .forgejo/scripts/freebsd-build.sh dist/hate-no-d .
- name: Package
run: sh .forgejo/scripts/make-archive.sh hate-no-d-freebsd-x86_64 tar.gz \
dist/hate-no-d dist/libhate-no-d.a
- 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
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 build stays
# hate-no-d.exe -- only the release asset name carries the toolchain.
# 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 }}
@ -218,10 +239,8 @@ jobs:
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
@ -233,15 +252,16 @@ jobs:
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
make gcc libc6-dev gcc-multilib mingw-w64 jq zip
- name: Build
run: make PLATFORM=Windows WIN_ARCH=${{ matrix.arch }} HOST_CC="${{ matrix.host_cc }}" all
run: make PLATFORM=Windows WIN_ARCH=${{ matrix.arch }} HOST_CC="${{ matrix.host_cc }}" all lib
- name: Verify executable
run: |
@ -253,6 +273,10 @@ jobs:
bad=$(printf '%s\n' "$deps" | grep -v -E '^(KERNEL32|msvcrt)\.dll$' || true)
[ -z "$bad" ] || { echo "unexpected runtime DLL dependency: $bad" >&2; exit 1; }
- name: Package
run: sh .forgejo/scripts/make-archive.sh "hate-no-d-windows-${{ matrix.arch }}" zip \
./hate-no-d.exe ./libhate-no-d.a
- 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
run: sh .forgejo/scripts/release-asset.sh "./hate-no-d-windows-${{ matrix.arch }}.zip"

10
.gitignore vendored
View file

@ -1,3 +1,13 @@
hate-no-d
hate-no-d.exe
quick-start.lua
# Release staging dirs and archives (.forgejo/scripts/make-archive.sh).
hate-no-d-*/
hate-no-d-*.tar.gz
hate-no-d-*.zip
# Build artifacts (make lib).
*.o
*.mri
libhate-no-d.a

View file

@ -6,6 +6,11 @@
# make PLATFORM=Android ANDROID_NDK=... ANDROID_ABI=armeabi-v7a ANDROID_API=21
# make PLATFORM=iOS IOS_ARCH=arm64 IOS_MIN=12.0
# make PLATFORM=Windows WIN_ARCH=x86_64 (cross build with mingw-w64)
#
# Targets:
# make the CLI (hate-no-d, or hate-no-d.exe / libluajit.a on iOS)
# make lib libhate-no-d.a, for embedding into another program
# make help every target and option
# luajit requires GNU Make (use `gmake` on FreeBSD/OpenBSD/NetBSD).
ifndef .FEATURES
@ -17,7 +22,22 @@ endif
LUAJIT_DIR := submodules/luajit
LUAJIT_SRC := $(LUAJIT_DIR)/src
LUAJIT_AR := $(LUAJIT_SRC)/libluajit.a
OBJ := hate-no-d.o
BIN := hate-no-d
LIB := libhate-no-d.a
# Everything that goes into $(LIB) besides LuaJIT itself. Empty today: the only
# C in the tree is the CLI driver, and its main() belongs to the executable an
# embedder already has, not to a library (a -all_load/--whole-archive link would
# collide). Runtime modules added later get listed here, e.g.
# LIB_OBJS += hnod.o
# and are merged into the archive automatically -- that is why the archive has
# a name of its own instead of just being LuaJIT's.
LIB_OBJS :=
# Archiver used to merge $(LIB). Cross toolchains ship their own; Apple has no
# `ar -M`, so those targets use libtool instead (see the $(LIB) rule).
AR ?= ar
LUAJIT_XCFLAGS := -DLUAJIT_ENABLE_LUA52COMPAT
LUAJIT_EXTRA :=
@ -82,6 +102,7 @@ ifeq ($(OS_KIND),windows)
endif
CC := $(WIN_ARCH)-w64-mingw32-gcc
AR := $(WIN_ARCH)-w64-mingw32-ar
HOST_CC ?= gcc
PLAT_LIBS := -lm
BIN := $(BIN).exe
@ -152,6 +173,7 @@ ifeq ($(OS_KIND),android)
ANDROID_CC := $(ANDROID_BIN)/$(ANDROID_TRIPLET)$(ANDROID_API)-clang
CC := $(ANDROID_CC)
AR := $(ANDROID_BIN)/llvm-ar
EXPORT_LDFLAGS := -Wl,-E
PLAT_LIBS := -lm
LINK_TARGET := $(BIN)
@ -201,25 +223,84 @@ $(LUAJIT_AR):
$(MAKE) -C $(LUAJIT_SRC) $(LUAJIT_MAKE_ARGS) "LJCORE_O=ljamalg.o" libluajit.a
# Targets
help:
@echo "hate-no-d -- LuaJIT-based Lua runtime"
@echo ""
@echo "Targets:"
@echo " make [all] CLI for the auto-detected platform (hate-no-d,"
@echo " hate-no-d.exe, or libluajit.a on iOS)"
@echo " make lib libhate-no-d.a: LuaJIT plus LIB_OBJS, for embedding"
@echo " make luajit LuaJIT static archive only"
@echo " make print-config resolved configuration for the current target"
@echo " make clean remove build artifacts, LuaJIT's included"
@echo " make help this text"
@echo ""
@echo "Options (pass as VAR=value):"
@echo " PLATFORM= Linux | Android | Darwin | iOS | Windows | a BSD"
@echo " (default: uname -s)"
@echo " WIN_ARCH= x86_64 | i686 [Windows]"
@echo " ANDROID_NDK= NDK root, or export ANDROID_NDK_HOME [Android]"
@echo " ANDROID_ABI= arm64-v8a | armeabi-v7a | x86_64 | x86 [Android]"
@echo " ANDROID_API= target API level, default 21 [Android]"
@echo " IOS_ARCH= IOS_MIN= arm64 / 12.0 [iOS]"
@echo " IOS_SDK= IOS_CC= Xcode paths, default from xcrun [iOS]"
@echo " MACOSX_HRT= hardened-runtime JIT, default 1 [macOS]"
@echo " MACOSX_DEPLOYMENT_TARGET= default 11.0 [macOS]"
@echo " HOST_CC= host compiler for minilua/buildvm; needed"
@echo " when the target is 32-bit and the host is not"
@echo " CFLAGS= default -O2 -Wall"
@echo " LDFLAGS= extra linker flags"
@echo " LIB_OBJS= extra objects merged into libhate-no-d.a"
@echo " AR= archiver used to merge libhate-no-d.a"
all: $(LINK_TARGET)
$(BIN): hate-no-d.c $(LUAJIT_AR)
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ hate-no-d.c \
$(OBJ): hate-no-d.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ hate-no-d.c
$(BIN): $(OBJ) $(LUAJIT_AR)
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(OBJ) \
$(LUAJIT_AR) $(EXPORT_LDFLAGS) $(LDFLAGS) $(PLAT_LIBS)
luajit: $(LUAJIT_AR)
# Static library for embedding: $(LIB_OBJS) plus LuaJIT, merged into one archive
# so a host program links a single file, and modules added to $(LIB_OBJS) later
# join it without the host's link line changing.
lib: $(LIB)
# Apple's ar (cctools) has no MRI script mode, so archives are merged with
# libtool there. Everywhere else GNU ar, binutils ar and llvm-ar all parse MRI
# scripts (ADDMOD for objects, ADDLIB for another archive).
APPLE := $(filter macos ios,$(OS_KIND))
$(LIB): $(LIB_OBJS) $(LUAJIT_AR)
ifeq ($(APPLE),)
@rm -f $@ $@.mri
@{ echo "CREATE $@"; \
for o in $(LIB_OBJS); do echo "ADDMOD $$o"; done; \
echo "ADDLIB $(LUAJIT_AR)"; \
echo "SAVE"; echo "END"; } > $@.mri
$(AR) -M < $@.mri
@rm -f $@.mri
else
@rm -f $@
libtool -static -o $@ $(LIB_OBJS) $(LUAJIT_AR)
endif
@echo "lib: built $@ ($$($(AR) t $@ | wc -l | tr -d ' ') members)"
# Show the resolved configuration for the current (or selected) platform.
# Useful for checking a cross build before committing to it.
print-config:
@echo "PLATFORM = $(PLATFORM)"
@echo "OS_KIND = $(OS_KIND)"
@echo "CC = $(CC)"
@echo "CC / AR = $(CC) / $(AR)"
@echo "CFLAGS = $(CFLAGS)"
@echo "CPPFLAGS = $(CPPFLAGS)"
@echo "EXPORT_LDFLAGS = $(EXPORT_LDFLAGS)"
@echo "PLAT_LIBS = $(PLAT_LIBS)"
@echo "LINK_TARGET = $(LINK_TARGET)"
@echo "OBJ / LIB = $(OBJ) / $(LIB) [$(LIB_OBJS)]"
@echo "LUAJIT_MAKE_ARGS = $(LUAJIT_MAKE_ARGS)"
@echo "MACOSX_DEPLOYMENT_TARGET = $(MACOSX_DEPLOYMENT_TARGET) (HRT=$(MACOSX_HRT))"
@echo "ANDROID_ABI / API = $(ANDROID_ABI) / $(ANDROID_API)"
@ -228,6 +309,6 @@ print-config:
clean:
$(MAKE) -C $(LUAJIT_DIR) clean
rm -f $(BIN)
rm -f $(BIN) $(OBJ) $(LIB) $(LIB).mri
.PHONY: all clean luajit print-config
.PHONY: all clean luajit print-config lib help