From 8cfef907a7d2efb56cfcb7c697203f879a236179 Mon Sep 17 00:00:00 2001 From: Joey Vagedes Date: Wed, 21 Feb 2024 10:06:32 -0800 Subject: [PATCH] Add qemu binary release workflow: (#852) ## Description Add a new workflow that will build and prepare qemu binaries for both Windows and Linux. This workflow has three triggers: 1. A pull request to the main branch, which will only trigger when either the workflow itself, or the qemu version file is updated. This workflow will upload the binaries as an artifact to the workflow. 2. A release, which will upload the binaries as an artifact to the associated release 3. A manual trigger, which allows for testing the workflow on a custom branch. This will upload the binaries as an artifact to the workflow. - [ ] Impacts functionality? - **Functionality** - Does the change ultimately impact how firmware functions? - Examples: Add a new library, publish a new PPI, update an algorithm, ... - [ ] Impacts security? - **Security** - Does the change have a direct security impact on an application, flow, or firmware? - Examples: Crypto algorithm change, buffer overflow fix, parameter validation improvement, ... - [ ] Breaking change? - **Breaking change** - Will anyone consuming this change experience a break in build or boot behavior? - Examples: Add a new library class, move a module to a different repo, call a function in a new library class in a pre-existing module, ... - [ ] Includes tests? - **Tests** - Does the change include any explicit test code? - Examples: Unit tests, integration tests, robot tests, ... - [ ] Includes documentation? - **Documentation** - Does the change contain explicit documentation additions outside direct code modifications (and comments)? - Examples: Update readme file, add feature readme file, link to documentation on an a separate Web page, ... ## How This Was Tested A release was performed using this github action on a personal branch ([v0.1.9](https://github.com/Javagedes/mu_tiano_platforms/releases/tag/v0.1.9)), and was used as an external dependency on a mu_tiano_platforms [Draft PR](https://github.com/microsoft/mu_tiano_platforms/pull/851), which is passing, and will be merged once this PR has been merged and a release has been executed. ## Integration Instructions N/A --- .github/publish-qemu-config.yml | 4 + .github/workflows/publish-qemu-bin.yml | 174 +++++++++++++++++++++++++ 2 files changed, 178 insertions(+) create mode 100644 .github/publish-qemu-config.yml create mode 100644 .github/workflows/publish-qemu-bin.yml diff --git a/.github/publish-qemu-config.yml b/.github/publish-qemu-config.yml new file mode 100644 index 000000000..c072c4207 --- /dev/null +++ b/.github/publish-qemu-config.yml @@ -0,0 +1,4 @@ +{ + "windows": "2023.7.25", + "linux": "v8.0.0" +} diff --git a/.github/workflows/publish-qemu-bin.yml b/.github/workflows/publish-qemu-bin.yml new file mode 100644 index 000000000..0620f73f2 --- /dev/null +++ b/.github/workflows/publish-qemu-bin.yml @@ -0,0 +1,174 @@ +name: Publish Qemu External Dependency + +on: + workflow_dispatch: + release: + types: [published] + pull_request: + branches: + - main + paths: + - .github/workflows/publish-qemu-bin.yml + - .github/publish-qemu-config.yml + +env: + QEMU_VERSION_FILE: .github/publish-qemu-config.yml + +jobs: + qemu-windows: + name: Build Qemu for Windows + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Get current Qemu version + id: qemu-version + run: | + $qemuVersion = (Get-Content -Path $env:QEMU_VERSION_FILE | ConvertFrom-Json).windows + "QEMU_VERSION=$qemuVersion" | Out-File -FilePath "$env:GITHUB_OUTPUT" -Append + shell: pwsh + - name: Download Qemu v${{ steps.qemu-version.outputs.QEMU_VERSION }} + env: + QEMU_VERSION: ${{ steps.qemu-version.outputs.QEMU_VERSION }} + run: | + choco install qemu --version=$env:QEMU_VERSION + - name: Stage Qemu Binaries + run: | + mkdir temp + mkdir temp\share + cp "C:\Program Files\qemu\qemu-system-x86_64.exe" temp + cp "C:\Program Files\qemu\qemu-system-aarch64.exe" temp + cp "C:\Program Files\qemu\share\kvmvapic.bin" temp\share + cp "C:\Program Files\qemu\share\vgabios-cirrus.bin" temp\share + cp "C:\Program Files\qemu\share\vgabios-stdvga.bin" temp\share + Get-ChildItem -Path "C:\Program Files\qemu" -Filter *.dll | Move-Item -Destination "temp" + + - name: Upload Qemu Artifact + uses: actions/upload-artifact@v4 + with: + name: qemu-windows + path: | + temp\* + if-no-files-found: error + + qemu-linux: + name: Build Qemu for Linux + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Get current Qemu version + id: qemu-version + run: | + qemuVersion=$(jq -r .linux $QEMU_VERSION_FILE) + echo "QEMU_VERSION=$qemuVersion" >> $GITHUB_OUTPUT + shell: bash + - name: Install Dependencies + run: | + sudo apt-get update + sudo apt-get install --yes --no-install-recommends \ + autoconf \ + automake \ + autotools-dev \ + bc \ + build-essential \ + dosfstools \ + gcc \ + libglib2.0-dev \ + libgtk-3-dev \ + libpixman-1-dev \ + libsdl2-dev \ + mtools \ + ninja-build \ + tar + - name: Compile Qemu ${{ steps.qemu-version.outputs.QEMU_VERSION }} + env: + QEMU_VERSION: ${{ steps.qemu-version.outputs.QEMU_VERSION }} + QEMU_URL: "https://gitlab.com/qemu-project/qemu.git" + DEBIAN_FRONTEND: "noninteractive" + run: | + git clone $QEMU_URL --branch $QEMU_VERSION --depth 1 qemu + cd qemu + mkdir bin + cd bin + ./../configure --target-list=x86_64-softmmu,aarch64-softmmu --enable-gtk + sudo make -j $(nproc) + - name: Stage Qemu Binaries + run: | + mkdir -p temp/share + cp qemu/bin/qemu-system-x86_64 qemu/bin/qemu-system-aarch64 temp + cp qemu/bin/qemu-bundle/usr/local/share/qemu/vgabios-cirrus.bin temp/share + cp qemu/bin/qemu-bundle/usr/local/share/qemu/vgabios-stdvga.bin temp/share + cp qemu/bin/qemu-bundle/usr/local/share/qemu/kvmvapic.bin temp/share + - name: Upload Qemu Artifact + uses: actions/upload-artifact@v4 + with: + name: qemu-linux + path: | + temp/* + if-no-files-found: error + + prepare-extdep: + name: Prepare and Upload Qemu External Dependency + needs: [qemu-windows, qemu-linux] + runs-on: Ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Get current Qemu version + id: qemu-version + run: | + qemuVersion=$(jq -r .linux $QEMU_VERSION_FILE) + echo "QEMU_VERSION=$qemuVersion" >> $GITHUB_OUTPUT + - name: Download Windows Qemu Artifact + uses: actions/download-artifact@v4 + with: + name: qemu-windows + path: windows + - name: Download Linux Qemu Artifact + uses: actions/download-artifact@v4 + with: + name: qemu-linux + path: linux + - name: Download Qemu License + env: + QEMU_VERSION: ${{ steps.qemu-version.outputs.QEMU_VERSION }} + run: | + curl -L https://raw.githubusercontent.com/qemu/qemu/$QEMU_VERSION/COPYING -o COPYING + curl -L https://raw.githubusercontent.com/qemu/qemu/QEMU_VERSION/LICENSE -o LICENSE + - name: Stage Ext-Dep + run: | + mkdir -p qemu/Windows/ + mkdir -p qemu/Linux/ + mv windows/ qemu/Windows/bin/ + mv linux/ qemu/Linux/bin/ + cp COPYING qemu/Windows/ + cp COPYING qemu/Linux/ + cp LICENSE qemu/Windows/ + cp LICENSE qemu/Linux/ + chmod a+x qemu/Linux/bin/* + - name: Package Ext-Dep + run: | + cd qemu/Windows/ && zip -r ${{github.workspace}}/qemu-windows-${{github.event.release.tag_name}}.zip * + cd ../Linux/ && tar -czf ${{github.workspace}}/qemu-linux-${{github.event.release.tag_name}}.tar.gz * + + - name: Upload Ext-Dep (Artifact) + uses: actions/upload-artifact@v4 + if: github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' + with: + name: qemu-extdep-binaries + path: | + qemu-*.zip + qemu-*.gz + - name: Upload Ext-Dep (Release) + if: github.event_name == 'release' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ github.event.release.tag_name }} qemu-*.zip + gh release upload ${{ github.event.release.tag_name }} qemu-*.tar.gz