mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 18:20:30 +08:00
Add local release pipeline and migrate CI to GitHub Actions
Builds macOS DMG, Linux amd64 deb and AppImage from a single macOS Apple Silicon machine using Podman containers. See RELEASE.md and scripts/release for details. Replaces Woodpecker CI with GitHub Actions workflows for lint, unit tests, e2e tests, and Arch package validation.
This commit is contained in:
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
# The build container (Dockerfile.ubuntu) runs as native ARM64, but Tauri's
|
||||
# AppImage bundler downloads and runs linuxdeploy-x86_64.AppImage — an x86_64
|
||||
# binary that bundles the app's shared library dependencies (GTK, WebKit, …)
|
||||
# into the AppDir so the AppImage is self-contained on any x86_64 Linux system.
|
||||
# Without intervention the ARM64 kernel cannot execute it and returns "Exec
|
||||
# format error". binfmt_misc is a Linux kernel feature that maps file magic
|
||||
# bytes to an interpreter; by registering a handler here, the kernel
|
||||
# automatically prepends QEMU to any x86_64 ELF execution, making x86_64
|
||||
# binaries work transparently inside the ARM64 container without any changes to
|
||||
# the code that invokes them.
|
||||
#
|
||||
# Register an x86_64 binfmt_misc handler so the ARM64 kernel transparently
|
||||
# routes x86_64 ELF executables through QEMU. This is needed because Tauri's
|
||||
# AppImage bundler downloads and runs linuxdeploy-x86_64.AppImage.
|
||||
#
|
||||
# binfmt_misc registration format:
|
||||
# :name:type:offset:magic:mask:interpreter:flags
|
||||
#
|
||||
# The magic matches an x86_64 ELF executable header:
|
||||
# \x7fELF — ELF magic
|
||||
# \x02 — 64-bit (EI_CLASS)
|
||||
# \x01 — little-endian (EI_DATA)
|
||||
# \x01 — version
|
||||
# \x00... — OS/ABI + padding (bytes 7-15)
|
||||
# \x02\x00 — ET_EXEC (executable)
|
||||
# \x3e\x00 — x86-64 machine type
|
||||
#
|
||||
# The mask has \x00 for bytes 7-15 (the padding area). A zero mask bit means
|
||||
# "don't check this byte". This is necessary because AppImages embed the
|
||||
# two-byte marker 'AI' in bytes 8-9 of the ELF padding. The standard x86_64
|
||||
# mask checks those bytes exactly (\xff), so it rejects AppImages. With the
|
||||
# permissive mask both plain ELFs and AppImages are intercepted.
|
||||
#
|
||||
# echo (not printf): the \x.. sequences must reach the kernel binfmt_misc
|
||||
# parser as literal text (e.g. the four characters \, x, 7, f), which the
|
||||
# kernel then interprets as byte values. printf would expand them to raw bytes
|
||||
# first, the parser would misread the entry, and the broken handler would
|
||||
# intercept ARM64 binaries and route them through QEMU, breaking the container.
|
||||
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc 2>/dev/null || true
|
||||
echo ':qemu-x86_64-appimage:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00:\xff\xff\xff\xff\xff\xfe\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xff\xff\xff:/usr/bin/qemu-x86_64-static:' \
|
||||
> /proc/sys/fs/binfmt_misc/register 2>/dev/null || true
|
||||
export APPIMAGE_EXTRACT_AND_RUN=1
|
||||
# linuxdeploy-plugin-gtk.sh calls pkg-config to find GTK 3; on an ARM64 host
|
||||
# with amd64 multiarch the default search path misses the amd64 .pc files.
|
||||
export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig
|
||||
# Ubuntu 24.04 installs gtk-query-immodules-3.0 under the t64 directory.
|
||||
# The plugin needs it in PATH; binfmt-misc handles it as x86_64 via QEMU.
|
||||
export PATH=/usr/lib/x86_64-linux-gnu/libgtk-3-0t64:$PATH
|
||||
npm exec -- tauri build \
|
||||
--config '{"build":{"beforeBuildCommand":""}}' \
|
||||
--target x86_64-unknown-linux-gnu \
|
||||
--bundles appimage
|
||||
cp target/x86_64-unknown-linux-gnu/release/bundle/appimage/*.AppImage /output/
|
||||
Executable
+173
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Build release artifacts for all platforms.
|
||||
#
|
||||
# Usage: scripts/release [OPTIONS]
|
||||
#
|
||||
# Options:
|
||||
# --only-dmg Build macOS aarch64 DMG only
|
||||
# --only-deb Build Linux amd64 deb only
|
||||
# --only-appimage Build Linux amd64 AppImage only
|
||||
# --rebuild-image Force rebuild of podman container images
|
||||
# --clean Wipe target-release/, node_modules/ and Linux build volumes
|
||||
# --help Show this help
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
|
||||
# ---- Flags ----
|
||||
|
||||
BUILD_DMG=true
|
||||
BUILD_DEB=true
|
||||
BUILD_APPIMAGE=true
|
||||
REBUILD_IMAGE=false
|
||||
CLEAN=false
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--only-dmg) BUILD_DMG=true; BUILD_DEB=false; BUILD_APPIMAGE=false ;;
|
||||
--only-deb) BUILD_DMG=false; BUILD_DEB=true; BUILD_APPIMAGE=false ;;
|
||||
--only-appimage) BUILD_DMG=false; BUILD_DEB=false; BUILD_APPIMAGE=true ;;
|
||||
--rebuild-image) REBUILD_IMAGE=true ;;
|
||||
--clean) CLEAN=true; BUILD_DMG=false; BUILD_DEB=false; BUILD_APPIMAGE=false ;;
|
||||
--help|-h)
|
||||
head -20 "$0" | grep '^#' | sed 's/^# \?//'
|
||||
exit 0
|
||||
;;
|
||||
*) echo "Unknown option: $arg" >&2; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# ---- Helpers ----
|
||||
|
||||
step() { echo; echo "==> $*"; }
|
||||
|
||||
# Builds a container image if it does not already exist (or --rebuild-image).
|
||||
# $1: image name, $2: dockerfile path (relative to PROJECT_DIR), $3: platform
|
||||
ensure_image() {
|
||||
local name="$1"
|
||||
local dockerfile="$2"
|
||||
local platform="$3"
|
||||
if [[ "$REBUILD_IMAGE" == true ]] || ! podman image exists "$name" 2>/dev/null; then
|
||||
echo " Building container image: $name"
|
||||
podman build \
|
||||
--platform "$platform" \
|
||||
-t "$name" \
|
||||
-f "$PROJECT_DIR/$dockerfile" \
|
||||
"$PROJECT_DIR"
|
||||
fi
|
||||
}
|
||||
|
||||
# ---- Version and output directory ----
|
||||
|
||||
VERSION="$(jq -r '.version' "$PROJECT_DIR/crates/radicle-tauri/tauri.conf.json")"
|
||||
RELEASE_SHA="$(git -C "$PROJECT_DIR" rev-parse HEAD)"
|
||||
SHORT_SHA="$(git -C "$PROJECT_DIR" rev-parse --short=8 HEAD)"
|
||||
RELEASE_DIR="$PROJECT_DIR/releases/v$VERSION"
|
||||
|
||||
step "Building release v$VERSION (${SHORT_SHA})"
|
||||
echo " Output: $RELEASE_DIR"
|
||||
mkdir -p "$RELEASE_DIR"
|
||||
|
||||
# ---- Clean ----
|
||||
|
||||
if [[ "$CLEAN" == true ]]; then
|
||||
step "Cleaning build artifacts"
|
||||
rm -rf "$PROJECT_DIR/target-release"
|
||||
rm -rf "$PROJECT_DIR/node_modules"
|
||||
podman volume rm radicle-desktop-linux-target radicle-desktop-linux-nm radicle-desktop-linux-cargo 2>/dev/null || true
|
||||
podman image rm radicle-desktop-release-builder 2>/dev/null || true
|
||||
echo " Cleaned"
|
||||
fi
|
||||
|
||||
# ---- macOS aarch64 DMG ----
|
||||
|
||||
if [[ "$BUILD_DMG" == true ]]; then
|
||||
step "Building macOS aarch64 DMG"
|
||||
cd "$PROJECT_DIR"
|
||||
npm install
|
||||
CARGO_TARGET_DIR="$PROJECT_DIR/target-release" \
|
||||
npm exec -- tauri build --bundles dmg
|
||||
cp "target-release/release/bundle/dmg/Radicle_${VERSION}_aarch64.dmg" \
|
||||
"$RELEASE_DIR/radicle-desktop-aarch64.dmg"
|
||||
echo " radicle-desktop-aarch64.dmg"
|
||||
fi
|
||||
|
||||
# ---- Linux amd64 deb ----
|
||||
#
|
||||
# Runs in the native ARM64 Ubuntu container, which cross-compiles Rust to
|
||||
# x86_64. Build artifacts are cached in named podman volumes so subsequent
|
||||
# runs only recompile what changed.
|
||||
#
|
||||
# When to clear volumes:
|
||||
# After a Rust toolchain bump or dependency change that confuses incremental
|
||||
# compilation: podman volume rm radicle-desktop-linux-target radicle-desktop-linux-cargo
|
||||
# After a major npm dependency change: podman volume rm radicle-desktop-linux-nm
|
||||
|
||||
if [[ "$BUILD_DEB" == true ]]; then
|
||||
step "Building Linux amd64 deb"
|
||||
ensure_image "radicle-desktop-release-builder" "Dockerfile.release" "linux/arm64"
|
||||
|
||||
podman run --rm \
|
||||
-v "$PROJECT_DIR:/workspace:z" \
|
||||
-v radicle-desktop-linux-target:/workspace/target:z \
|
||||
-v radicle-desktop-linux-nm:/workspace/node_modules:z \
|
||||
-v radicle-desktop-linux-cargo:/root/.cargo/registry:z \
|
||||
-v "$RELEASE_DIR:/output:z" \
|
||||
-w /workspace \
|
||||
-e CI=true \
|
||||
radicle-desktop-release-builder \
|
||||
bash -c "
|
||||
set -euo pipefail
|
||||
npm ci
|
||||
npm exec -- tauri build --target x86_64-unknown-linux-gnu --bundles deb
|
||||
cp target/x86_64-unknown-linux-gnu/release/bundle/deb/*.deb /output/
|
||||
"
|
||||
|
||||
echo " radicle-desktop_${VERSION}_amd64.deb"
|
||||
fi
|
||||
|
||||
# ---- Linux amd64 AppImage ----
|
||||
#
|
||||
# See scripts/appimage-build for the full setup. Key points:
|
||||
# - --privileged to mount binfmt_misc for x86_64 emulation via QEMU
|
||||
# - APPIMAGE_EXTRACT_AND_RUN=1 so linuxdeploy-x86_64.AppImage runs without FUSE
|
||||
# - PKG_CONFIG_PATH for the GTK plugin to find amd64 packages
|
||||
# - PATH includes libgtk-3-0t64 dir where gtk-query-immodules-3.0 lives
|
||||
# The script is mounted from the workspace (heredocs pipe to host, not container)
|
||||
|
||||
if [[ "$BUILD_APPIMAGE" == true ]]; then
|
||||
step "Building Linux amd64 AppImage"
|
||||
ensure_image "radicle-desktop-release-builder" "Dockerfile.release" "linux/arm64"
|
||||
|
||||
podman run --rm \
|
||||
--privileged \
|
||||
-v "$PROJECT_DIR:/workspace:z" \
|
||||
-v radicle-desktop-linux-target:/workspace/target:z \
|
||||
-v radicle-desktop-linux-nm:/workspace/node_modules:z \
|
||||
-v radicle-desktop-linux-cargo:/root/.cargo/registry:z \
|
||||
-v "$RELEASE_DIR:/output:z" \
|
||||
-w /workspace \
|
||||
-e CI=true \
|
||||
radicle-desktop-release-builder \
|
||||
bash /workspace/scripts/appimage-build
|
||||
|
||||
echo " radicle-desktop_${VERSION}_amd64.AppImage"
|
||||
fi
|
||||
|
||||
if [[ "$CLEAN" == false ]]; then
|
||||
# ---- latest.json ----
|
||||
|
||||
step "Generating latest.json"
|
||||
printf '{"sha": "%s", "version": "%s"}' "$RELEASE_SHA" "$VERSION" \
|
||||
> "$RELEASE_DIR/latest.json"
|
||||
echo " latest.json"
|
||||
|
||||
# ---- Summary ----
|
||||
|
||||
echo
|
||||
echo "Done. Artifacts in $RELEASE_DIR:"
|
||||
ls -lh "$RELEASE_DIR"
|
||||
fi
|
||||
Reference in New Issue
Block a user