Skip to content

Commit

Permalink
Dynamically set the version of Panda Debian package in Control file b…
Browse files Browse the repository at this point in the history
…ased on the release version from GitHub
  • Loading branch information
AndrewQuijano committed Oct 28, 2024
1 parent c363487 commit eed465c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:

- name: Build package
working-directory: panda/debian
run: ./setup.sh Ubuntu ${{ matrix.ubuntu_version }}
run: ./setup.sh Ubuntu ${{ matrix.ubuntu_version }} ${{ needs.create_release.outputs.v-version }}

- name: Upload wheel and debian packages to release
uses: softprops/action-gh-release@v2
Expand Down
3 changes: 2 additions & 1 deletion panda/debian/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
panda.deb
*.deb
*.whl
8 changes: 7 additions & 1 deletion panda/debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
ARG PACKAGE_VERSION=""

# First run the main Dockerfile to build the base image and name it panda. Then we run here
# to generate a debian package

FROM debian:buster-slim
FROM debian:bookworm-slim

# Install necessary tools for packaging
RUN apt-get -qq update && \
Expand All @@ -21,6 +23,10 @@ COPY --from=panda /usr/local/share/panda /package-root/usr/local/share/panda
# Create DEBIAN directory and control file
COPY control /package-root/DEBIAN/control

# Update control file with the correct version
ARG PACKAGE_VERSION
RUN sed -i "s/^Version:.*/Version: ${PACKAGE_VERSION}/" /package-root/DEBIAN/control

# Update control file with dependencies
# Build time. We only select dependencies that are not commented out or blank
RUN dependencies=$(grep '^[a-zA-Z]' /tmp/build_dep.txt | tr '\n' ',' | sed 's/,,\+/,/g'| sed 's/,$//') && \
Expand Down
2 changes: 1 addition & 1 deletion panda/debian/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: pandare
Version: 3.1.0
Version: <version-placeholder>
Architecture: all
BUILD_DEPENDS_LIST
DEPENDS_LIST
Expand Down
22 changes: 19 additions & 3 deletions panda/debian/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,33 @@ if [[ $# -eq 1 ]]; then
echo " To build a package for current Ubuntu version:"
echo " $0"
echo " To build a package for a specific OS/version (only Ubuntu supported for now):"
echo " $0 <OS> <version>"
echo " $0 <OS> <ubutun-version> <tag-version>"
exit 1
fi

if [[ $# -eq 2 ]]; then
version=$2

else
version=$(lsb_release -r | awk '{print $2}')
fi

if [[ $# -eq 3 ]]; then
tag_version=$3
else
tag_version='v3.1.0'
fi

# Remove leading 'v' if present, e. g. v1.5.1 -> 1.5.1
if [[ "$tag_version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
tag_version=${tag_version:1}
fi

# Check if the version follows the format X.Y.Z, e. g. 1.5.1 or 1.9.1
if [[ ! "$tag_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "ERROR: Version must be in the format X.Y.Z, provided tag version: $tag_version"
exit 1
fi

# Check if the given version is supported
if [[ ! -f "../dependencies/ubuntu_${version}_base.txt" ]]; then
echo "ERROR: Ubuntu ${version} is not supported, no dependencies file found"
Expand All @@ -53,7 +69,7 @@ docker run --rm -v $(pwd):/out panda bash -c "cp /panda/panda/python/core/dist/*
DOCKER_BUILDKIT=1 docker build --target panda -t panda --build-arg BASE_IMAGE="ubuntu:${version}" ../..

# Now build the packager container from that
docker build -t packager .
docker build -t packager --build-arg PACKAGE_VERSION="${tag_version}" .

# Copy deb file out of container to host
docker run --rm -v $(pwd):/out packager bash -c "cp /pandare.deb /out"
Expand Down

0 comments on commit eed465c

Please sign in to comment.