name: Build for Linux on: workflow_call: inputs: pkg_version: description: Build version required: true type: string jobs: build: name: Build for Ubuntu (${{matrix.arch}}, ${{ matrix.configuration }}) runs-on: ubuntu-22.04${{ matrix.arch == 'aarch64' && '-arm' || '' }} strategy: matrix: arch: [x86_64, aarch64] configuration: [debug, release] env: ARTIFACT_NAME: xemu-ubuntu-${{ matrix.arch }}-${{ matrix.configuration }} CCACHE_DIR: /tmp/xemu-ccache CCACHE_MAXSIZE: 512M LTO_CACHE_DIR: /tmp/xemu-lto-cache LTO_CACHE_MAXSIZE: 512m DEB_BUILD_MAINT_OPTIONS: optimize=-lto DEB_CFLAGS_MAINT_APPEND: -gdwarf-4 -gstrict-dwarf DEB_CXXFLAGS_MAINT_APPEND: -gdwarf-4 -gstrict-dwarf DEB_LDFLAGS_MAINT_APPEND: -Wl,--build-id=sha1 CC: ccache clang-21 CXX: ccache clang++-21 CC_LD: lld-21 CXX_LD: lld-21 AR: llvm-ar-21 RANLIB: llvm-ranlib-21 NM: llvm-nm-21 steps: - name: Setup build options run: | if [[ "${{ matrix.configuration }}" == "debug" ]]; then opts=( --debug ) else opts=( --extra-ldflags="-Wl,--thinlto-cache-policy=cache_size_bytes=$LTO_CACHE_MAXSIZE" -Db_lto=true -Db_lto_mode=thin -Db_thinlto_cache=true -Db_thinlto_cache_dir="$LTO_CACHE_DIR" -Dx86_version=3 ) mkdir -p ${LTO_CACHE_DIR} fi echo "XEMU_BUILD_OPTIONS=${opts[*]}" >> "$GITHUB_ENV" - name: Initialize compiler cache id: cache uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v4 with: path: | ${{ env.CCACHE_DIR }} ${{ env.LTO_CACHE_DIR }} 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@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v4 with: name: src - name: Extract source package run: | mkdir src tar -xf xemu-${{ inputs.pkg_version }}.tar.zst -C src --strip-components=2 - name: Create debian changelog run: | pushd src echo -e "\ xemu (1:0.0.0-0) unstable; urgency=medium\n\ Built from ${{ inputs.pkg_version }})\n\ -- Matt Borgerson $(date -R)" > debian/changelog popd - name: Add LLVM APT repository run: | sudo install -d /etc/apt/keyrings curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key \ | sudo gpg --dearmor -o /etc/apt/keyrings/llvm.gpg sudo tee /etc/apt/sources.list.d/llvm.list <> "$GITHUB_ENV" mkdir -p ${CCACHE_DIR} 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 deb mv *.deb *.ddeb deb - name: Report ccache stats run: ccache -s - name: Generate AppImage env: VERSION: ${{ inputs.pkg_version }}${{ matrix.configuration == 'debug' && '-dbg' || '' }} run: | wget --no-verbose https://github.com/linuxdeploy/linuxdeploy/releases/latest/download/linuxdeploy-${{ matrix.arch }}.AppImage chmod +x linuxdeploy-${{ matrix.arch }}.AppImage ar x deb/*.deb mkdir appimage tar -C appimage -xf data.tar* install -DT src/xemu.metainfo.xml appimage/usr/share/metainfo/xemu.metainfo.xml ./linuxdeploy-${{ matrix.arch }}.AppImage --output appimage --appdir appimage - name: Bundle artifacts run: | mkdir -p dist tar -czvf ./dist/${{ env.ARTIFACT_NAME }}.tgz --transform "s#^dist#${{ env.ARTIFACT_NAME }}#" deb mv xemu-*.AppImage dist - name: Upload build artifact uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v4 with: name: ${{ env.ARTIFACT_NAME }} path: dist compression-level: 0