wails/.github/workflows/build-cross-image.yml
Lea Anthony 39e5d47477 ci: install Linux dev dependencies for wails3 CLI build
The wails3 CLI requires GTK3/WebKit2GTK dev packages to build on
the GitHub runner (for CGO).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 08:58:43 +11:00

291 lines
9.1 KiB
YAML

name: Build Cross-Compiler Image
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch containing Dockerfile'
required: true
default: 'v3-alpha'
sdk_version:
description: 'macOS SDK version'
required: true
default: '14.5'
zig_version:
description: 'Zig version'
required: true
default: '0.14.0'
image_version:
description: 'Image version tag'
required: true
default: 'latest'
skip_tests:
description: 'Skip cross-compilation tests'
required: false
default: 'false'
type: boolean
push:
branches:
- v3-alpha
paths:
- 'v3/internal/commands/build_assets/docker/Dockerfile.cross'
env:
REGISTRY: ghcr.io
IMAGE_NAME: wailsapp/wails-cross
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image_tag: ${{ steps.vars.outputs.image_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.ref }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set build variables
id: vars
run: |
echo "sdk_version=${{ inputs.sdk_version || '14.5' }}" >> $GITHUB_OUTPUT
echo "zig_version=${{ inputs.zig_version || '0.14.0' }}" >> $GITHUB_OUTPUT
echo "image_version=${{ inputs.image_version || 'latest' }}" >> $GITHUB_OUTPUT
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=raw,value=${{ steps.vars.outputs.image_version }}
type=raw,value=sdk-${{ steps.vars.outputs.sdk_version }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: v3/internal/commands/build_assets/docker
file: v3/internal/commands/build_assets/docker/Dockerfile.cross
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: |
${{ steps.meta.outputs.labels }}
io.wails.zig.version=${{ steps.vars.outputs.zig_version }}
io.wails.sdk.version=${{ steps.vars.outputs.sdk_version }}
build-args: |
ZIG_VERSION=${{ steps.vars.outputs.zig_version }}
MACOS_SDK_VERSION=${{ steps.vars.outputs.sdk_version }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Test cross-compilation for all platforms (3 parallel jobs, each builds both architectures)
test-cross-compile:
needs: build
if: ${{ inputs.skip_tests != 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [darwin, linux, windows]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.ref }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache: false
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Linux dev dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev
- name: Install wails3 CLI
run: |
cd v3
go install ./cmd/wails3
- name: Set up QEMU
if: matrix.os == 'linux'
uses: docker/setup-qemu-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate wails3 test project
run: |
cd /tmp
wails3 init -n test-wails-app -t vanilla
cd test-wails-app
# Add replace directive to use the checked-out wails source
echo "" >> go.mod
echo "replace github.com/wailsapp/wails/v3 => ${{ github.workspace }}/v3" >> go.mod
# Build frontend
cd frontend && npm install && npm run build && cd ..
- name: Build ${{ matrix.os }}/amd64
run: |
cd /tmp/test-wails-app
PLATFORM_FLAG=""
if [ "${{ matrix.os }}" = "linux" ]; then
PLATFORM_FLAG="--platform linux/amd64"
fi
docker run --rm $PLATFORM_FLAG \
-v "$(pwd):/app" \
-v "${{ github.workspace }}/v3:${{ github.workspace }}/v3:ro" \
-e APP_NAME="test-wails-app" \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build.outputs.image_tag || 'latest' }} \
${{ matrix.os }} amd64
- name: Build ${{ matrix.os }}/arm64
run: |
cd /tmp/test-wails-app
PLATFORM_FLAG=""
if [ "${{ matrix.os }}" = "linux" ]; then
PLATFORM_FLAG="--platform linux/arm64"
fi
docker run --rm $PLATFORM_FLAG \
-v "$(pwd):/app" \
-v "${{ github.workspace }}/v3:${{ github.workspace }}/v3:ro" \
-e APP_NAME="test-wails-app" \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build.outputs.image_tag || 'latest' }} \
${{ matrix.os }} arm64
- name: Verify binaries
run: |
cd /tmp/test-wails-app/bin
ls -la
verify_binary() {
local binary="$1"
local expected="$2"
echo "Checking: $binary"
FILE_OUTPUT=$(file "$binary")
echo " $FILE_OUTPUT"
if echo "$FILE_OUTPUT" | grep -qE "$expected"; then
echo " ✅ Format verified"
else
echo " ❌ Format mismatch! Expected: $expected"
exit 1
fi
}
case "${{ matrix.os }}" in
darwin)
verify_binary "test-wails-app-darwin-amd64" "Mach-O 64-bit.*x86_64"
verify_binary "test-wails-app-darwin-arm64" "Mach-O 64-bit.*arm64"
;;
linux)
verify_binary "test-wails-app-linux-amd64" "ELF 64-bit LSB.*x86-64"
verify_binary "test-wails-app-linux-arm64" "ELF 64-bit LSB.*ARM aarch64"
;;
windows)
verify_binary "test-wails-app-windows-amd64.exe" "PE32.*executable.*x86-64"
verify_binary "test-wails-app-windows-arm64.exe" "PE32.*executable.*Aarch64"
;;
esac
- name: Check library dependencies (Linux only)
if: matrix.os == 'linux'
run: |
cd /tmp/test-wails-app/bin
check_libs() {
local binary="$1"
echo "## $binary"
echo ""
echo "### NEEDED libraries:"
readelf -d "$binary" | grep NEEDED || echo "No dynamic dependencies"
echo ""
NEEDED=$(readelf -d "$binary" | grep NEEDED)
MISSING=""
for lib in libwebkit2gtk-4.1.so libgtk-3.so libglib-2.0.so libc.so; do
if echo "$NEEDED" | grep -q "$lib"; then
echo "✅ $lib"
else
echo "❌ $lib MISSING"
MISSING="$MISSING $lib"
fi
done
if [ -n "$MISSING" ]; then
echo "ERROR: Missing required libraries:$MISSING"
exit 1
fi
echo ""
}
check_libs "test-wails-app-linux-amd64"
check_libs "test-wails-app-linux-arm64"
# Summary job
test-summary:
needs: [build, test-cross-compile]
if: always() && inputs.skip_tests != 'true'
runs-on: ubuntu-latest
steps:
- name: Check test results
run: |
echo "## Cross-Compilation Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.test-cross-compile.result }}" = "success" ]; then
echo "✅ **All Tests Passed**" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Some Tests Failed**" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Tested Platforms" >> $GITHUB_STEP_SUMMARY
echo "| Platform | amd64 | arm64 |" >> $GITHUB_STEP_SUMMARY
echo "|----------|-------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| Darwin | ✅ | ✅ |" >> $GITHUB_STEP_SUMMARY
echo "| Linux | ✅ | ✅ |" >> $GITHUB_STEP_SUMMARY
echo "| Windows | ✅ | ✅ |" >> $GITHUB_STEP_SUMMARY
# Fail if any test failed
if [ "${{ needs.test-cross-compile.result }}" != "success" ]; then
echo ""
echo "❌ Some tests failed. Check the individual job logs for details."
exit 1
fi