From 9f737f87e6718838059c052d41450b5f0dd41fd5 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Sun, 4 Jan 2026 23:04:49 -0700 Subject: [PATCH] ci: Pass build version using job outputs --- .github/workflows/build-linux.yml | 16 +++++++++------- .github/workflows/build-macos.yml | 20 ++++++++++++-------- .github/workflows/build-windows.yml | 20 ++++++++++---------- .github/workflows/build.yml | 21 ++++++++++++++++++--- .github/workflows/release.yml | 2 +- 5 files changed, 50 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 93740afba7..44bbeec0f8 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -2,6 +2,11 @@ name: Build for Linux on: workflow_call: + inputs: + pkg_version: + description: Build version + required: true + type: string jobs: build: @@ -32,13 +37,13 @@ jobs: - name: Extract source package run: | mkdir src - tar -xf xemu-*.tar.zst -C src --strip-components=2 + 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 $(cat XEMU_VERSION)\n\ + Built from ${{ inputs.pkg_version }})\n\ -- Matt Borgerson $(date -R)" > debian/changelog popd - name: Install dependencies @@ -72,6 +77,8 @@ jobs: - 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 @@ -81,11 +88,6 @@ jobs: tar -C appimage -xf data.tar* install -DT src/xemu.metainfo.xml appimage/usr/share/metainfo/xemu.metainfo.xml - export VERSION=$(cat src/XEMU_VERSION) - if [[ "${{ matrix.configuration }}" == "debug" ]]; then - export VERSION=$VERSION-dbg - fi - ./linuxdeploy-${{ matrix.arch }}.AppImage --output appimage --appdir appimage - name: Bundle artifacts run: | diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index be88a95b9f..3a0f115058 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -2,6 +2,11 @@ name: Build for macOS on: workflow_call: + inputs: + pkg_version: + description: Build version + required: true + type: string jobs: build: @@ -22,7 +27,7 @@ jobs: with: name: src - name: Extract source package - run: tar -xf xemu-*.tar.zst --strip-components=2 + run: tar -xf xemu-${{ inputs.pkg_version }}.tar.zst --strip-components=2 - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: '3.12' @@ -54,13 +59,10 @@ jobs: run: ccache -s - name: Package id: package + env: + VERSION: ${{ inputs.pkg_version }}${{ matrix.configuration == 'debug' && '-dbg' || '' }} run: | - # Determine package filename - version="$(cat XEMU_VERSION)" - if [[ "${{ matrix.configuration}}" == "debug" ]]; then - version="${version}-dbg" - fi - pkg_filename="xemu-${version}-macos-${{ matrix.arch }}-unsigned.zip" + pkg_filename="xemu-${VERSION}-macos-${{ matrix.arch }}-unsigned.zip" echo "pkg_filename=${pkg_filename}" >> $GITHUB_OUTPUT pushd dist @@ -99,8 +101,10 @@ jobs: popd - name: Package id: package + env: + VERSION: ${{ inputs.pkg_version }}${{ matrix.configuration == 'debug' && '-dbg' || '' }} run: | - pkg_filename="$(ls -1 xemu-*.zip | head -n1 | sed -E 's/(.*)(arm64|x86_64)/\1universal/')" + pkg_filename="xemu-${VERSION}-macos-universal-unsigned.zip" echo "pkg_filename=${pkg_filename}" >> $GITHUB_OUTPUT pushd dist zip -r ../${pkg_filename} * diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index bfd4407ec6..b899d459dc 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -2,6 +2,11 @@ name: Build for Windows on: workflow_call: + inputs: + pkg_version: + description: Build version + required: true + type: string jobs: build: @@ -19,7 +24,7 @@ jobs: with: name: src - name: Extract source package - run: tar -xf xemu-*.tar.zst --strip-components=2 + run: tar -xf xemu-${{ inputs.pkg_version }}.tar.zst --strip-components=2 - name: Initialize compiler cache id: cache uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v4 @@ -44,7 +49,6 @@ jobs: -u $(id -u):$(id -g) \ $DOCKER_IMAGE_NAME \ bash -c "ccache -z; ./build.sh -p win64-cross ${BUILD_FLAGS} && ccache -s" - cp XEMU_VERSION dist - name: Upload build artifact uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4 with: @@ -77,15 +81,11 @@ jobs: - name: Determine package version id: package_id shell: bash + env: + VERSION: ${{ inputs.pkg_version }}${{ matrix.configuration == 'debug' && '-dbg' || '' }} run: | - cd ${{ env.ARTIFACT_NAME }} - version="$(cat XEMU_VERSION)" - if [[ "${{ matrix.configuration}}" == "debug" ]]; then - version="${version}-dbg" - fi - echo "pkg_filename=xemu-${version}-win-${{ matrix.arch }}.zip" >> $GITHUB_OUTPUT - echo "pdb_filename=xemu-${version}-win-${{ matrix.arch }}-pdb.zip" >> $GITHUB_OUTPUT - rm XEMU_VERSION + echo "pkg_filename=xemu-${VERSION}-win-${{ matrix.arch }}.zip" >> $GITHUB_OUTPUT + echo "pdb_filename=xemu-${VERSION}-win-${{ matrix.arch }}-pdb.zip" >> $GITHUB_OUTPUT - name: Package run: | mkdir dist-pdb diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ebc81183a9..3833d7aee8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,11 +7,17 @@ on: description: "Git ref (commit, branch, or tag) to build" required: true type: string + outputs: + pkg_version: + description: Build version + value: ${{ jobs.source.outputs.pkg_version }} jobs: source: name: Create source package runs-on: ubuntu-latest + outputs: + pkg_version: ${{ steps.version.outputs.pkg_version }} steps: - name: Clone tree uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 @@ -23,9 +29,8 @@ jobs: - name: Determine release version id: version run: | - echo -n ${{ github.sha }} > XEMU_COMMIT - git describe --tags --match 'v*' | cut -c 2- | tr -d '\n' > XEMU_VERSION - echo "pkg_version=$(cat XEMU_VERSION)" >> $GITHUB_OUTPUT + TAG=$(git describe --tags --match 'v*') + echo "pkg_version=${TAG#v}" >> $GITHUB_OUTPUT - name: Create source package id: package run: | @@ -33,7 +38,11 @@ jobs: tar_filename="${pkg_name}.tar" tar_prefix="./${pkg_name}/" ./scripts/archive-source.sh ${tar_filename} ${tar_prefix} + + echo -n ${{ github.sha }} > XEMU_COMMIT + echo -n ${{ steps.version.outputs.pkg_version }} > XEMU_VERSION tar -r --file "${tar_filename}" --transform "s,^./,${tar_prefix}," ./XEMU_COMMIT ./XEMU_VERSION + zstd "${tar_filename}" echo "pkg_filename=${tar_filename}.zst" >> $GITHUB_OUTPUT - name: Upload source package artifact @@ -47,13 +56,19 @@ jobs: name: Linux needs: source uses: ./.github/workflows/build-linux.yml + with: + pkg_version: ${{ needs.source.outputs.pkg_version }} macos: name: macOS needs: source uses: ./.github/workflows/build-macos.yml + with: + pkg_version: ${{ needs.source.outputs.pkg_version }} windows: name: Windows needs: source uses: ./.github/workflows/build-windows.yml + with: + pkg_version: ${{ needs.source.outputs.pkg_version }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2cf1e72fd0..814a6707c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,7 @@ jobs: - name: Add transitionary package alias run: | pushd dist - cp xemu-$(cat XEMU_VERSION)-win-x86_64.zip xemu-win-x86_64-release.zip + cp xemu-${{ needs.build.outputs.pkg_version }}-win-x86_64.zip xemu-win-x86_64-release.zip - name: Create release draft uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0 with: