Skip to content

Commit 73ecd2d

Browse files
MitchellAugustinnvmochs
authored andcommitted
CANONICAL: [Infrastructure] Add Canonical Build CI
Adds a GitHub Action pipeline to automatically build a source package that can be signed and uploaded to an LP builder Signed-off-by: Mitchell Augustin <mitchell.augustin@canonical.com> Signed-off-by: Matthew R. Ochs <mochs@nvidia.com>
1 parent 3b4f945 commit 73ecd2d

2 files changed

Lines changed: 146 additions & 0 deletions

File tree

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Builds a Debian source package for QEMU
2+
3+
name: Build Debian Source Package
4+
5+
on:
6+
push:
7+
branches:
8+
- 'nvidia/latest'
9+
- 'nvidia_stable-10.1'
10+
11+
# Allow manual triggering of the workflow from the GitHub UI
12+
workflow_dispatch:
13+
14+
jobs:
15+
build-source-package:
16+
# arm64 is the primary platform of interest for this project
17+
runs-on: ubuntu-24.04
18+
19+
steps:
20+
# Step 1: Check out the repository's code
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
# Fetch all history for all tags and branches, which can be necessary
25+
# for tools like git-buildpackage to determine version numbers.
26+
fetch-depth: 0
27+
28+
# Step 2: Install Debian packaging tools and build dependencies
29+
- name: Install Build Dependencies
30+
run: |
31+
sudo apt-get update
32+
33+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y devscripts equivs fakeroot git-buildpackage
34+
35+
# Use mk-build-deps to parse debian/control, create a dummy package
36+
# with all build dependencies, and install it. This ensures all
37+
# required build dependencies are present.
38+
# The --no-install-recommends flag keeps the environment minimal.
39+
sudo mk-build-deps -i --tool="apt-get -y --no-install-recommends"
40+
# Remove debs that this generates from the working directory after install
41+
rm -f qemu-build-deps*
42+
43+
# Step 3: Generate Upstream Tarball
44+
- name: Generate Upstream Tarball
45+
run: |
46+
# Extract source name and upstream version from debian/changelog.
47+
# The first sed command strips any epoch (e.g., "1:") from the start of the version.
48+
# The second sed command strips the Debian revision from the end of the version string.
49+
# dpkg-parsechangelog is in the dpkg-dev package, a dependency of devscripts.
50+
export SOURCE_NAME=$(dpkg-parsechangelog -S Source)
51+
export UPSTREAM_VERSION=$(dpkg-parsechangelog -S Version | sed 's/^[0-9]\+://' | sed 's/-[^-]*$//')
52+
53+
git config --global user.email "robot@builder.local"
54+
git config --global user.name "Builder Robot"
55+
# Create the .orig.tar.gz in the parent directory.
56+
./debian/build-source-package-from-git.sh
57+
58+
# Step 4: Upload Workspace for Debugging
59+
- name: Upload Workspace for Debugging
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: pre-build-workspace
63+
path: .
64+
65+
# Step 5: Build the Debian source package
66+
- name: Build Source Package
67+
run: |
68+
# Use debuild to create the source package.
69+
# -S: Build a source package only (no binaries).
70+
# -us: Do not sign the source package.
71+
# -uc: Do not sign the .changes file.
72+
# This command will find and use the .orig.tar.gz we just created.
73+
current_dir=$(pwd)
74+
cd deb
75+
# There should only be one thing in here, which is the tarball we'll extract
76+
# so wildcard should be OK in this instance.
77+
ls
78+
tar -xvf $(ls -d * | head -n 1)
79+
ls
80+
cd $(ls -d */ | head -n 1)
81+
debuild -S -us -uc
82+
cd "$current_dir"
83+
84+
# Step 6: Log MD5 Checksums
85+
- name: Log MD5 Checksums as Annotations
86+
run: |
87+
# Change to the parent directory where artifacts were created.
88+
current_dir=$(pwd)
89+
cd deb
90+
mkdir source_package_artifacts
91+
92+
# Iterate over all the generated build artifacts.
93+
for file in *.dsc *.orig.tar.* *.debian.tar.* *.changes *source.build *source.buildinfo; do
94+
# Check if files matching the pattern exist before processing.
95+
if [ -f "$file" ]; then
96+
# Calculate the MD5 sum and format it for the annotation.
97+
# The output of md5sum is "CHECKSUM FILENAME".
98+
checksum=$(md5sum "$file")
99+
100+
# Echo the checksum as a workflow notice annotation.
101+
# This will make it easily visible in the GitHub Actions UI.
102+
echo "::notice title=MD5 Checksum::$checksum"
103+
mv "$file" source_package_artifacts
104+
fi
105+
done
106+
mv source_package_artifacts "$current_dir"
107+
108+
# Step 7: Upload the generated source package files as artifacts
109+
- name: Upload Debian Source Package Artifacts
110+
uses: actions/upload-artifact@v4
111+
with:
112+
# Name of the artifact bundle to be displayed in the GitHub UI
113+
name: debian-source-package
114+
115+
path: source_package_artifacts
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
#
3+
# Produce a deb source package that can be uploaded to a Debian/Ubuntu builder.
4+
5+
if [[ $(git --no-optional-locks status -uno --porcelain) ]]; then
6+
echo "ERROR: git repository is not clean"
7+
echo "Try running:"
8+
echo " git submodule foreach --recursive 'git reset --hard && git clean -fdx'"
9+
exit 1
10+
fi
11+
12+
# Update submodules
13+
git clean -xdf
14+
git submodule update --init --recursive
15+
16+
# Clean up and include everything in the package
17+
find subprojects/ -type d -name .git -exec rm -rf {} \;
18+
find . -name .gitignore -exec rm -f {} \;
19+
20+
meson subprojects download
21+
22+
find subprojects/ -type d -name .git -exec rm -rf {} \;
23+
find . -name .gitignore -exec rm -f {} \;
24+
25+
# Import submodules in git
26+
git add .
27+
git commit -s -a -m "[DROP THIS] Include submodules for packaging"
28+
29+
# Produce an orig tarball
30+
mkdir -p deb
31+
git archive --prefix=qemu-10.1.0/ -o deb/qemu_10.1.0+nvidia1.orig.tar.gz HEAD

0 commit comments

Comments
 (0)