Skip to content

Commit

Permalink
Add qemu binary release workflow: (#852)
Browse files Browse the repository at this point in the history
## 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](#851), which is
passing, and will be merged once this PR has been merged and a release
has been executed.

## Integration Instructions

N/A
  • Loading branch information
Javagedes committed Feb 21, 2024
1 parent ec69f43 commit 8cfef90
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/publish-qemu-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"windows": "2023.7.25",
"linux": "v8.0.0"
}
174 changes: 174 additions & 0 deletions .github/workflows/publish-qemu-bin.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8cfef90

Please sign in to comment.