ci: Split up build workflow

This commit is contained in:
Matt Borgerson
2026-01-03 02:53:39 -07:00
committed by mborgerson
parent a672d723b8
commit a99e4347f4
12 changed files with 566 additions and 475 deletions
+120
View File
@@ -0,0 +1,120 @@
name: Build for Linux
on:
workflow_call:
jobs:
ubuntu:
name: Build for Ubuntu (${{matrix.arch}}, ${{ matrix.configuration }})
runs-on: ${{ matrix.runs-on }}
strategy:
matrix:
include:
- arch: x86_64
configuration: Debug
build_param: --debug
artifact_name: xemu-ubuntu-x86_64-debug
artifact_filename: xemu-ubuntu-x86_64-debug.tgz
runs-on: ubuntu-22.04
- arch: x86_64
configuration: Release
build_param:
artifact_name: xemu-ubuntu-x86_64-release
artifact_filename: xemu-ubuntu-x86_64-release.tgz
runs-on: ubuntu-22.04
- arch: aarch64
configuration: Debug
build_param: --debug
artifact_name: xemu-ubuntu-aarch64-debug
artifact_filename: xemu-ubuntu-aarch64-debug.tgz
runs-on: ubuntu-22.04-arm
- arch: aarch64
configuration: Release
build_param:
artifact_name: xemu-ubuntu-aarch64-release
artifact_filename: xemu-ubuntu-aarch64-release.tgz
runs-on: ubuntu-22.04-arm
env:
CCACHE_DIR: /tmp/xemu-ccache
CCACHE_MAXSIZE: 512M
XEMU_BUILD_OPTIONS: ${{ matrix.build_param }}
steps:
- name: Initialize compiler cache
id: cache
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v4
with:
path: /tmp/xemu-ccache
key: cache-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.configuration }}-${{ github.sha }}
restore-keys: cache-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.configuration }}-
- name: Download source package
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v4
with:
name: src.tar.gz
- name: Extract source package
run: |
mkdir src
tar -C src -xf src.tar.gz
- name: Create debian changelog
run: |
pushd src
echo -e "\
xemu (1:0.0.0-0) unstable; urgency=medium\n\
Built from $(cat XEMU_VERSION)\n\
-- Matt Borgerson <contact@mborgerson.com> $(date -R)" > debian/changelog
popd
- name: Install dependencies
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get -qy update
sudo apt-get install ccache libfuse2 libusb-1.0-0-dev
pushd src
sudo apt-get -qy build-dep .
- name: Setup ccache
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
ccache -z
- name: Compile
run: |
# XXX: dpkg-genbuildinfo takes two minutes on GH runners. Nuke it for now.
sudo rm /usr/bin/dpkg-genbuildinfo
sudo ln -s /bin/true /usr/bin/dpkg-genbuildinfo
pushd src
dpkg-buildpackage --no-sign -b
popd
mkdir -p dist
mv *.deb *.ddeb dist
- name: Test
run: |
pushd src/build
./pyvenv/bin/meson compile test-xbox
./pyvenv/bin/meson test --suite xbox --no-rebuild
popd
- name: Report ccache stats
run: ccache -s
- name: Generate AppImage
run: |
wget --no-verbose https://github.com/linuxdeploy/linuxdeploy/releases/latest/download/linuxdeploy-${{ matrix.arch }}.AppImage
chmod +x linuxdeploy-${{ matrix.arch }}.AppImage
ar x dist/*.deb
mkdir appimage
tar -C appimage -xf data.tar*
install -DT src/xemu.metainfo.xml appimage/usr/share/metainfo/xemu.metainfo.xml
export VERSION=v$(cat src/XEMU_VERSION)
if [[ "${{ matrix.configuration }}" == "Debug" ]]; then
export VERSION=$VERSION-dbg
fi
./linuxdeploy-${{ matrix.arch }}.AppImage --output appimage --appdir appimage
mv xemu-*.AppImage dist
- name: Bundle artifacts
run: |
tar -czvf ${{ matrix.artifact_filename }} --transform "s#^dist#xemu#" dist
- name: Upload build artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_filename }}
+120
View File
@@ -0,0 +1,120 @@
name: Build for macOS
on:
workflow_call:
jobs:
macos:
name: Build for macOS (${{ matrix.arch }}, ${{ matrix.configuration }})
runs-on: macOS-14
strategy:
matrix:
include:
- arch: x86_64
configuration: Debug
build_param: --debug -a x86_64
artifact_name: xemu-macos-x86_64-debug
artifact_filename: xemu-macos-x86_64-debug-unsigned.zip
- arch: x86_64
configuration: Release
build_param: -a x86_64
artifact_name: xemu-macos-x86_64-release
artifact_filename: xemu-macos-x86_64-release-unsigned.zip
- arch: arm64
configuration: Debug
build_param: --debug -a arm64
artifact_name: xemu-macos-arm64-debug
artifact_filename: xemu-macos-arm64-debug-unsigned.zip
- arch: arm64
configuration: Release
build_param: -a arm64
artifact_name: xemu-macos-arm64-release
artifact_filename: xemu-macos-arm64-release-unsigned.zip
steps:
- name: Download source package
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v4
with:
name: src.tar.gz
- name: Extract source package
run: tar xf src.tar.gz
- uses: actions/setup-python@v6.1.0
with:
python-version: '3.12'
- name: Install dependencies
run: |
export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_INSTALL_CLEANUP=1
brew install \
ccache \
coreutils \
dylibbundler
pip install pyyaml requests
- name: Initialize compiler, library cache
id: cache
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v4
with:
path: |
xemu-ccache
macos-pkgs
key: cache-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.configuration }}-${{ github.sha }}
restore-keys: cache-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.configuration }}-
- name: Compile
run: |
export CCACHE_DIR=${GITHUB_WORKSPACE}/xemu-ccache
export CCACHE_MAXSIZE=512M
export PATH="/usr/local/opt/ccache/libexec:$PATH"
ccache -z
./build.sh ${{ matrix.build_param }}
echo -e "\nCompiler Cache Stats:"
ccache -s
pushd dist
zip -r ../${{ matrix.artifact_filename }} *
popd
- name: Upload build artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_filename }}
macos_universal:
name: Build macOS Universal Bundle (${{ matrix.configuration }})
runs-on: macOS-14
needs: macos
strategy:
matrix:
configuration: ["debug", "release"]
steps:
- name: Download x86_64 build
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v4
with:
name: xemu-macos-x86_64-${{ matrix.configuration }}
path: xemu-macos-x86_64-${{ matrix.configuration }}
- name: Download arm64 build
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v4
with:
name: xemu-macos-arm64-${{ matrix.configuration }}
path: xemu-macos-arm64-${{ matrix.configuration }}
- name: Build Universal bundle
run: |
mkdir dist
for arch in x86_64 arm64; do
pushd xemu-macos-${arch}-${{ matrix.configuration }}
unzip xemu-macos-${arch}-${{ matrix.configuration }}-unsigned.zip
popd
pushd dist
unzip -o ../xemu-macos-${arch}-${{ matrix.configuration }}/xemu-macos-${arch}-${{ matrix.configuration }}-unsigned.zip
popd
done
pushd dist
rm xemu.app/Contents/MacOS/xemu
lipo -create -output xemu.app/Contents/MacOS/xemu \
../xemu-macos-x86_64-${{ matrix.configuration }}/xemu.app/Contents/MacOS/xemu \
../xemu-macos-arm64-${{ matrix.configuration }}/xemu.app/Contents/MacOS/xemu
codesign --force --deep --preserve-metadata=entitlements,requirements,flags,runtime --sign - xemu.app/Contents/MacOS/xemu
zip -r ../xemu-macos-universal-${{ matrix.configuration }}-unsigned.zip *
popd
- name: Upload build artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4
with:
name: xemu-macos-universal-${{ matrix.configuration }}
path: xemu-macos-universal-${{ matrix.configuration }}-unsigned.zip
+110
View File
@@ -0,0 +1,110 @@
name: Build for Windows
on:
workflow_call:
jobs:
windows:
name: Build for Windows (${{ matrix.arch }}, ${{ matrix.configuration }})
runs-on: ubuntu-latest
strategy:
matrix:
include:
- configuration: Debug
build_param: --debug
artifact_name: xemu-win-x86_64-debug
arch: x86_64
- configuration: Release
build_param:
artifact_name: xemu-win-x86_64-release
arch: x86_64
- configuration: Debug
build_param: --debug
artifact_name: xemu-win-aarch64-debug
arch: aarch64
- configuration: Release
build_param:
artifact_name: xemu-win-aarch64-release
arch: aarch64
env:
DOCKER_IMAGE_NAME: ghcr.io/xemu-project/xemu-win64-toolchain:sha-0d06ce8
steps:
- name: Download source package
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v4
with:
name: src.tar.gz
- name: Extract source package
run: tar xf src.tar.gz
- name: Initialize compiler cache
id: cache
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v4
with:
path: /tmp/xemu-ccache
key: cache-wincross-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.configuration }}-${{ github.sha }}
restore-keys: cache-wincross-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.configuration }}-
- name: Pull Docker image
run: docker pull $DOCKER_IMAGE_NAME
- name: Compile
run: |
mkdir -p /tmp/xemu-ccache
docker run --rm \
-v $PWD:/xemu -w /xemu \
-v /tmp/xemu-ccache:/tmp/xemu-ccache \
-e CCACHE_DIR=/tmp/xemu-ccache \
-e CCACHE_MAXSIZE=512M \
-e CROSSPREFIX=${{ matrix.arch }}-w64-mingw32.static- \
-e CROSSAR=${{ matrix.arch }}-w64-mingw32.static-ar \
-u $(id -u):$(id -g) \
$DOCKER_IMAGE_NAME \
bash -c "ccache -z; ./build.sh -p win64-cross ${{ matrix.build_param }} && ccache -s"
- name: Upload build artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4
with:
name: ${{ matrix.artifact_name }}
path: dist
# Generate a symbols package for Windows. Use cv2pdb to generate PDBs from
# DWARF and update + strip the executable. Re-package the original release
# and create symbols package.
windows_pdb:
name: Generate PDB for Windows (${{ matrix.arch }}, ${{ matrix.configuration }})
runs-on: windows-latest
needs: windows
strategy:
matrix:
include:
- configuration: Debug
artifact_name: xemu-win-x86_64-debug
arch: x86_64
- configuration: Release
artifact_name: xemu-win-x86_64-release
arch: x86_64
- configuration: Debug
artifact_name: xemu-win-aarch64-debug
arch: aarch64
- configuration: Release
artifact_name: xemu-win-aarch64-release
arch: aarch64
steps:
- name: Download artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v4
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_name }}
- name: Generate PDB
run: |
Invoke-WebRequest -Uri "https://github.com/rainers/cv2pdb/releases/download/v0.52/cv2pdb-0.52.zip" -OutFile "cv2pdb.zip"
Invoke-WebRequest -Uri "https://github.com/mstorsjo/llvm-mingw/releases/download/20241217/llvm-mingw-20241217-ucrt-x86_64.zip" -OutFile "llvm-mingw.zip"
7z x -ocv2pdb -y cv2pdb.zip
7z x -y llvm-mingw.zip
cd ${{ matrix.artifact_name }}
../cv2pdb/cv2pdb64.exe xemu.exe
../llvm-mingw-20241217-ucrt-x86_64/bin/${{ matrix.arch }}-w64-mingw32-strip.exe xemu.exe
mkdir ../dist
7z a -tzip ../dist/${{ matrix.artifact_name }}.zip * "-xr!*.pdb"
7z a -tzip ../dist/${{ matrix.artifact_name }}-pdb.zip "-ir!*.pdb"
- name: Upload build artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4
with:
name: ${{ matrix.artifact_name }}-pdb
path: dist
File diff suppressed because it is too large Load Diff
+16
View File
@@ -0,0 +1,16 @@
name: CI
on:
pull_request:
push:
branches:
- "**"
tags-ignore:
- "v*"
jobs:
build:
name: Build
uses: ./.github/workflows/build.yml
with:
ref: ${{ github.ref }}
+41
View File
@@ -0,0 +1,41 @@
name: Release (Dispatched)
on:
workflow_dispatch:
jobs:
tag:
name: Create release tag
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tag: ${{ steps.semver.outputs.next }}
steps:
- name: Clone tree
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4
- name: Determine new tag version
id: semver
run: |
latest=$(
git ls-remote --tags --refs "https://github.com/${GITHUB_REPOSITORY}.git" 'v[0-9]*.[0-9]*.[0-9]*' |
awk '{print $2}' | sed 's#refs/tags/##' | sort -V | tail -n 1
)
[ -z "$latest" ] && latest="v0.0.0"
ver="${latest#v}"
IFS=. read -r major minor patch <<< "$ver"
next="v${major}.${minor}.$((patch+1))"
echo "next=$next" >> "$GITHUB_OUTPUT"
- name: Push new tag
run: |
git config user.name "nobody"
git config user.email "nobody@nowhere"
git tag -a "${{ steps.semver.outputs.next }}" -m "${{ steps.semver.outputs.next }}"
git push origin "${{ steps.semver.outputs.next }}"
release:
name: Release
needs: tag
uses: ./.github/workflows/release.yml
with:
tag: ${{ needs.tag.outputs.tag }}
+12
View File
@@ -0,0 +1,12 @@
name: Release (Tag Pushed)
on:
push:
tags: ['v*']
jobs:
release:
name: Release
uses: ./.github/workflows/release.yml
with:
tag: ${{ github.ref_name }}
+17
View File
@@ -0,0 +1,17 @@
name: Release (Published)
on:
release:
types: [published]
jobs:
update_website:
name: Update website
if: github.repository_owner == 'xemu-project'
uses: ./.github/workflows/update-website.yml
update_ppa_snapshot:
name: Update PPA snapshot
uses: ./.github/workflows/update-ppa.yml
with:
release: ${{ github.event.release.name }}
+47
View File
@@ -0,0 +1,47 @@
name: Release
on:
workflow_call:
inputs:
tag:
description: "Tag to release (e.g. v1.2.3)"
required: true
type: string
jobs:
build:
name: Build
uses: ./.github/workflows/build.yml
with:
ref: ${{ inputs.tag }}
release:
name: Create release
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v4
with:
path: dist
merge-multiple: true
- name: Extract source package
run: tar xf dist/src.tar.gz
- name: Extract Ubuntu artifacts
run: |
pushd dist
for arch in x86_64 aarch64; do
for config in release debug; do
tar xvf xemu-ubuntu-$arch-$config.tgz
done
done
- name: Add transitionary package alias
run: |
cp dist/xemu-win-x86_64-release.zip dist/xemu-win-release.zip
- name: Create release draft
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
name: ${{ inputs.tag }}
tag_name: ${{ inputs.tag }}
draft: true
files: dist/*
+46
View File
@@ -0,0 +1,46 @@
# Sync archive version of source (including submodule code) to the
# ppa-snapshot branch to work around limitations of the Launchpad platform,
# namely: no network egress on package build, no custom scripting in source
# package creation.
name: Update PPA Snapshot
on:
workflow_call:
inputs:
release:
description: "Release to use for snapshot"
required: true
type: string
jobs:
push_to_ppa:
name: Push to PPA Snapshot Branch
runs-on: ubuntu-latest
steps:
- name: Download release source
env:
GH_TOKEN: ${{ github.token }}
run: gh release download "${{ inputs.release }}" --repo="${GITHUB_REPOSITORY}" -p src.tar.gz
- name: Extract source package
run: |
mkdir src
tar -C src -xf src.tar.gz
# Ensure subprojects are uploaded
find src/subprojects -name "*.gitignore" -exec rm {} \;
- name: Create minimal changelog
run: |
pushd src
echo -e "\
xemu (1:$(cat XEMU_VERSION)-0) unstable; urgency=medium\n\
Built from $(cat XEMU_VERSION)\n\
-- Matt Borgerson <contact@mborgerson.com> $(date -R)" > debian/changelog
popd
- name: Deploy source archive to branch
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./src
publish_branch: ppa-snapshot
force_orphan: true
+17
View File
@@ -0,0 +1,17 @@
name: Update Website
on:
workflow_call:
jobs:
update_website:
runs-on: ubuntu-latest
steps:
- name: Trigger website update
if: github.repository_owner == 'xemu-project'
uses: benc-uk/workflow-dispatch@e2e5e9a103e331dad343f381a29e654aea3cf8fc # v1.2.4
with:
workflow: build.yml
repo: xemu-project/xemu-website
token: ${{ secrets.XEMU_ROBOT_TOKEN }}
ref: master
-10
View File
@@ -1,10 +0,0 @@
#!/usr/bin/env python3
import argparse, re
ap = argparse.ArgumentParser()
ap.add_argument('semver', help='Input semver X.Y.Z')
args = ap.parse_args()
m = re.match(r'(?P<pfx>[^\d]*)(?P<maj>\d+)\.(?P<min>\d+)\.(?P<pat>\d+)',
args.semver)
assert m, 'Invalid version format'
print(m.group('pfx') + '.'.join([m.group('maj'), m.group('min'),
str(int(m.group('pat')) + 1)]))