diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml new file mode 100644 index 0000000000..cba9321955 --- /dev/null +++ b/.github/workflows/build-linux.yml @@ -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 $(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 }} diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml new file mode 100644 index 0000000000..b14e1fcfec --- /dev/null +++ b/.github/workflows/build-macos.yml @@ -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 diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml new file mode 100644 index 0000000000..eb07393d7a --- /dev/null +++ b/.github/workflows/build-windows.yml @@ -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 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 50c64dd3de..cb109fb948 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,21 +1,15 @@ 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/**' + workflow_call: + inputs: + ref: + description: "Git ref (commit, branch, or tag) to build" + required: true + type: string jobs: - Init: + source: name: Create source package runs-on: ubuntu-latest steps: @@ -23,28 +17,9 @@ jobs: uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 with: fetch-depth: 0 + ref: ${{ inputs.ref }} - name: Install dependencies run: sudo apt-get install meson - # 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 @@ -55,437 +30,17 @@ jobs: name: src.tar.gz path: src.tar.gz - Windows: - name: Build for Windows (${{ matrix.arch }}, ${{ matrix.configuration }}) on Ubuntu - runs-on: ubuntu-latest - needs: Init - 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 + linux: + name: Build for Linux + needs: source + uses: ./.github/workflows/build-linux.yml - 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 + macos: + name: Build for macOS + needs: source + uses: ./.github/workflows/build-macos.yml - # 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.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 - - Ubuntu: - name: Build for Ubuntu (${{matrix.arch}}, ${{ matrix.configuration }}) - runs-on: ${{ matrix.runs-on }} - needs: Init - 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 $(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 }} - - macOS: - name: Build for macOS (${{ matrix.arch }}, ${{ matrix.configuration }}) - runs-on: macOS-14 - 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-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 }} - - macOSUniversal: - 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 - - Release: - if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) - runs-on: ubuntu-latest - needs: [Ubuntu, macOSUniversal, Windows, WindowsPdb] - steps: - - name: Download artifacts - uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v4 - 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: | - for arch in x86_64 aarch64; do - for config in release debug; do - pushd dist/xemu-ubuntu-$arch-$config - tar xvf xemu-ubuntu-$arch-$config.tgz - popd - done - done - # Architecture tags were recently added to the Windows release path. Provide an alias with the former name for a while. - - name: Add transitionary package alias - run: | - cp dist/xemu-win-x86_64-release-pdb/xemu-win-x86_64-release.zip dist/xemu-win-x86_64-release-pdb/xemu-win-release.zip - - name: Publish release - uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0 - 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-aarch64-debug-pdb/xemu-win-aarch64-debug.zip - dist/xemu-win-aarch64-debug-pdb/xemu-win-aarch64-debug-pdb.zip - dist/xemu-win-aarch64-release-pdb/xemu-win-aarch64-release.zip - dist/xemu-win-aarch64-release-pdb/xemu-win-aarch64-release-pdb.zip - dist/xemu-win-x86_64-debug-pdb/xemu-win-x86_64-debug.zip - dist/xemu-win-x86_64-debug-pdb/xemu-win-x86_64-debug-pdb.zip - dist/xemu-win-x86_64-release-pdb/xemu-win-x86_64-release.zip - dist/xemu-win-x86_64-release-pdb/xemu-win-x86_64-release-pdb.zip - dist/xemu-win-x86_64-release-pdb/xemu-win-release.zip - dist/xemu-macos-universal-release/xemu-macos-universal-release-unsigned.zip - dist/xemu-macos-universal-debug/xemu-macos-universal-debug-unsigned.zip - dist/xemu-ubuntu-x86_64-debug/xemu/xemu-v${{ env.XEMU_VERSION }}-dbg-x86_64.AppImage - dist/xemu-ubuntu-x86_64-release/xemu/xemu-v${{ env.XEMU_VERSION }}-x86_64.AppImage - dist/xemu-ubuntu-aarch64-debug/xemu/xemu-v${{ env.XEMU_VERSION }}-dbg-aarch64.AppImage - dist/xemu-ubuntu-aarch64-release/xemu/xemu-v${{ env.XEMU_VERSION }}-aarch64.AppImage - - name: Trigger website update - 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 - - # 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, Windows, WindowsPdb] - runs-on: ubuntu-latest - steps: - - 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 - - # Ensure subprojects are uploaded - find src/subprojects -name "*.gitignore" -exec rm {} \; - - name: Integrate Debian packaging - run: | - pushd src - echo -e "\ - xemu (1:$(cat XEMU_VERSION)-0) unstable; urgency=medium\n\ - Built from $(cat XEMU_VERSION)\n\ - -- Matt Borgerson $(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 + windows: + name: Build for Windows + needs: source + uses: ./.github/workflows/build-windows.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..e7d7d18a29 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 }} diff --git a/.github/workflows/release-on-dispatch.yml b/.github/workflows/release-on-dispatch.yml new file mode 100644 index 0000000000..2f51406d8b --- /dev/null +++ b/.github/workflows/release-on-dispatch.yml @@ -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 }} diff --git a/.github/workflows/release-on-tag.yml b/.github/workflows/release-on-tag.yml new file mode 100644 index 0000000000..ca7c1a94db --- /dev/null +++ b/.github/workflows/release-on-tag.yml @@ -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 }} diff --git a/.github/workflows/release-published.yml b/.github/workflows/release-published.yml new file mode 100644 index 0000000000..25bb0602b9 --- /dev/null +++ b/.github/workflows/release-published.yml @@ -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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..a25bd4a154 --- /dev/null +++ b/.github/workflows/release.yml @@ -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/* diff --git a/.github/workflows/update-ppa.yml b/.github/workflows/update-ppa.yml new file mode 100644 index 0000000000..8f83f3369a --- /dev/null +++ b/.github/workflows/update-ppa.yml @@ -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 $(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 diff --git a/.github/workflows/update-website.yml b/.github/workflows/update-website.yml new file mode 100644 index 0000000000..4257a17185 --- /dev/null +++ b/.github/workflows/update-website.yml @@ -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 diff --git a/scripts/increment-semver.py b/scripts/increment-semver.py deleted file mode 100755 index 431e41ea7e..0000000000 --- a/scripts/increment-semver.py +++ /dev/null @@ -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[^\d]*)(?P\d+)\.(?P\d+)\.(?P\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)]))