Skip to content

Fix Nit's

Fix Nit's #221

Workflow file for this run

name: Build
on:
push:
paths-ignore:
- '.github/**'
- '!.github/workflows/build.yml'
- 'README.md'
- 'ubuntu-win64-cross/**'
pull_request:
paths-ignore:
- '.github/**'
- '!.github/workflows/build.yml'
- 'README.md'
- 'ubuntu-win64-cross/**'
jobs:
Init:
name: Create source package
runs-on: ubuntu-latest
steps:
- name: Clone tree
uses: actions/checkout@v3
with:
fetch-depth: 0
# On push to master, increment patch version and create a new tag on release
- name: Increment patch version
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
git config user.name "nobody"
git config user.email "nobody@nowhere"
VERSION=$(git describe --tags --match 'v*' --abbrev=0 | xargs ./scripts/increment-semver.py)
git tag -a $VERSION -m $VERSION
echo "Generated new release version: $VERSION"
# GitHub treats the new tag as lightweight, so older tags will shadow the
# new tag. Recreate it as an annotated tag now so the version script picks
# it up properly.
- name: Annotate release tag
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
git config user.name "nobody"
git config user.email "nobody@nowhere"
VERSION=${GITHUB_REF/refs\/tags\//}
git tag -a -f $VERSION $VERSION -m $VERSION
echo "Recreated release tag: $VERSION"
- name: Create source package
run: |
./scripts/archive-source.sh src.tar
gzip -1 src.tar
- name: Upload source package artifact
uses: actions/upload-artifact@v3
with:
name: src.tar.gz
path: src.tar.gz
Windows:
name: Build for Windows (${{ matrix.configuration }}) on Ubuntu
runs-on: ubuntu-latest
needs: Init
strategy:
matrix:
include:
- configuration: Debug
build_param: --debug
artifact_name: xemu-win-debug
- configuration: Release
build_param:
artifact_name: xemu-win-release
env:
DOCKER_IMAGE_NAME: ghcr.io/xemu-project/xemu-win64-toolchain:sha-d0d3e7b
steps:
- name: Download source package
uses: actions/download-artifact@v3
with:
name: src.tar.gz
- name: Extract source package
run: tar xf src.tar.gz
- name: Initialize compiler cache
id: cache
uses: actions/cache@v3
with:
path: /tmp/xemu-ccache
key: cache-wincross-${{ runner.os }}-${{ matrix.configuration }}-${{ github.sha }}
restore-keys: cache-wincross-${{ runner.os }}-${{ 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 \
-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@v3
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.
WindowsPdb:
name: Generate PDB for Windows (${{ matrix.configuration }})
runs-on: windows-latest
needs: Windows
strategy:
matrix:
include:
- configuration: Debug
artifact_name: xemu-win-debug
- configuration: Release
artifact_name: xemu-win-release
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
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"
7z x -ocv2pdb -y cv2pdb.zip
cd ${{ matrix.artifact_name }}
../cv2pdb/cv2pdb64.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@v3
with:
name: ${{ matrix.artifact_name }}-pdb
path: dist
Ubuntu:
name: Build for Ubuntu (${{ matrix.configuration }})
runs-on: ubuntu-latest
needs: Init
strategy:
matrix:
include:
- configuration: Debug
build_param: --debug
artifact_name: xemu-ubuntu-debug
artifact_filename: xemu-ubuntu-debug.tgz
- configuration: Release
build_param:
artifact_name: xemu-ubuntu-release
artifact_filename: xemu-ubuntu-release.tgz
steps:
- name: Initialize compiler cache
id: cache
uses: actions/cache@v3
with:
path: /tmp/xemu-ccache
key: cache-${{ runner.os }}-${{ matrix.configuration }}-${{ github.sha }}
restore-keys: cache-${{ runner.os }}-${{ matrix.configuration }}-
- name: Download source package
uses: actions/download-artifact@v3
with:
name: src.tar.gz
- name: Extract source package
run: |
mkdir src
tar -C src -xf src.tar.gz
- name: Clone Debian packaging
uses: actions/checkout@v3
with:
ref: deb
path: debian-tmp
- name: Integrate Debian packaging
run: |
mv debian-tmp/debian src
rm -rf debian-tmp
pushd src
echo -e "\
xemu (1:$(cat XEMU_VERSION)-0) unstable; urgency=medium\n\
Built from $(cat XEMU_VERSION)\n\
-- Matt Borgerson <[email protected]> $(date -R)" > debian/changelog
popd
- name: Install dependencies
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get -qy update
sudo apt-get install ccache libfuse2
pushd src
sudo apt-get -qy build-dep .
- name: Compile
run: |
export CCACHE_DIR=/tmp/xemu-ccache
export CCACHE_MAXSIZE=512M
export PATH="/usr/lib/ccache:$PATH"
export XEMU_BUILD_OPTIONS="${{ matrix.build_param }} --extra-cflags='-fuse-ld=gold'"
ccache -z
# 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
echo -e "\n\nCompiler Cache Stats:"
ccache -s
- name: Generate AppImage
run: |
wget --no-verbose https://github.com/linuxdeploy/linuxdeploy/releases/latest/download/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage
ar x dist/*.deb
mkdir appimage
tar -C appimage -xf data.tar*
install -DT src/xemu.appdata.xml appimage/usr/share/metainfo/xemu.appdata.xml
export VERSION=v$(cat src/XEMU_VERSION)
if [[ "${{ matrix.configuration }}" == "Debug" ]]; then
export VERSION=$VERSION-dbg
fi
./linuxdeploy-x86_64.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@v3
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_filename }}
macOS:
name: Build for macOS (${{ matrix.arch }}, ${{ matrix.configuration }})
runs-on: macOS-11
needs: Init
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.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.zip
- arch: arm64
configuration: Debug
build_param: --debug -a arm64
artifact_name: xemu-macos-arm64-debug
artifact_filename: xemu-macos-arm64-debug.zip
- arch: arm64
configuration: Release
build_param: -a arm64
artifact_name: xemu-macos-arm64-release
artifact_filename: xemu-macos-arm64-release.zip
steps:
- name: Download source package
uses: actions/download-artifact@v3
with:
name: src.tar.gz
- name: Extract source package
run: tar xf src.tar.gz
- name: Install dependencies
run: |
export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_INSTALL_CLEANUP=1
brew install \
ccache \
coreutils \
dylibbundler \
pkg-config \
ninja
python3 -m pip install pyyaml requests
- name: Initialize compiler, library cache
id: cache
uses: actions/cache@v3
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@v3
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_filename }}
macOSUniversal:
name: Build macOS Universal Bundle (${{ matrix.configuration }})
runs-on: macOS-11
needs: [macOS]
strategy:
matrix:
configuration: ["debug", "release"]
steps:
- name: Download x86_64 build
uses: actions/download-artifact@v3
with:
name: xemu-macos-x86_64-${{ matrix.configuration }}
path: xemu-macos-x86_64-${{ matrix.configuration }}
- name: Download arm64 build
uses: actions/download-artifact@v3
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 }}.zip
popd
pushd dist
unzip -o ../xemu-macos-${arch}-${{ matrix.configuration }}/xemu-macos-${arch}-${{ matrix.configuration }}.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 }}.zip *
popd
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: xemu-macos-universal-${{ matrix.configuration }}
path: xemu-macos-universal-${{ matrix.configuration }}.zip
Release:
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))
runs-on: ubuntu-latest
needs: [Ubuntu, macOSUniversal, WindowsPdb]
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: dist
- name: Extract source package
run: tar xf dist/src.tar.gz/src.tar.gz
- name: Get release info
run: |
echo "XEMU_VERSION=$(cat XEMU_VERSION)" >> $GITHUB_ENV
- name: Extract Ubuntu artifacts
run: |
pushd dist/xemu-ubuntu-release
tar xvf xemu-ubuntu-release.tgz
popd
pushd dist/xemu-ubuntu-debug
tar xvf xemu-ubuntu-debug.tgz
popd
- name: Publish release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.XEMU_VERSION }}
name: v${{ env.XEMU_VERSION }}
prerelease: false
draft: false
files: |
dist/src.tar.gz/src.tar.gz
dist/xemu-win-debug-pdb/xemu-win-debug.zip
dist/xemu-win-debug-pdb/xemu-win-debug-pdb.zip
dist/xemu-win-release-pdb/xemu-win-release.zip
dist/xemu-win-release-pdb/xemu-win-release-pdb.zip
dist/xemu-macos-universal-release/xemu-macos-universal-release.zip
dist/xemu-macos-universal-debug/xemu-macos-universal-debug.zip
dist/xemu-ubuntu-release/xemu/xemu-v${{ env.XEMU_VERSION }}-x86_64.AppImage
dist/xemu-ubuntu-debug/xemu/xemu-v${{ env.XEMU_VERSION }}-dbg-x86_64.AppImage
- name: Trigger website update
uses: benc-uk/[email protected]
with:
workflow: build.yml
repo: xemu-project/xemu-website
token: ${{ secrets.XEMU_ROBOT_TOKEN }}
ref: master
# 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.
PushToPPA:
name: Push to PPA Snapshot Branch
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))
needs: [Ubuntu, macOSUniversal, WindowsPdb]
runs-on: ubuntu-latest
steps:
- name: Download source package
uses: actions/download-artifact@v3
with:
name: src.tar.gz
- name: Extract source package
run: |
mkdir src
tar -C src -xf src.tar.gz
- name: Clone Debian packaging
uses: actions/checkout@v3
with:
ref: deb
path: debian-tmp
- name: Integrate Debian packaging
run: |
mv debian-tmp/debian src
rm -rf debian-tmp
pushd src
echo -e "\
xemu (1:$(cat XEMU_VERSION)-0) unstable; urgency=medium\n\
Built from $(cat XEMU_VERSION)\n\
-- Matt Borgerson <[email protected]> $(date -R)" > debian/changelog
popd
- name: Deploy source archive to branch
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./src
publish_branch: ppa-snapshot
force_orphan: true