Skip to content

Commit

Permalink
Merge pull request #11 from Auterion/ci-debian-package
Browse files Browse the repository at this point in the history
Build debian packages in CI
  • Loading branch information
ThomasDebrunner authored Dec 7, 2023
2 parents 8ee8ed3 + 84b1929 commit 136fae4
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/build-publish-debian-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build publish debian packages

on:
release:
types: [published]
pull_request:
branches:
- '*'

jobs:
build:
name: Build debian packages
runs-on: ubuntu-latest
strategy:
matrix:
platform: [linux/amd64, linux/arm64]
distro:
- ubuntu: jammy
ros2: humble
- ubuntu: jammy
ros2: rolling
- ubuntu: focal
ros2: foxy

steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set version
if: ${{ github.event_name == 'release' }}
run: sed -i "s/<version>.*<\/version>/<version>${{ github.event.release.tag_name }}<\/version>/" px4_ros2_cpp/package.xml

- name: Build build environment
run: |
docker build . -f Dockerfile.debian-buildenv \
--platform ${{ matrix.platform }} \
--build-arg="ROS2_DISTRO=${{ matrix.distro.ros2 }}" \
--build-arg="UBUNTU_DISTRO=${{ matrix.distro.ubuntu }}" \
-t buildenv:current
- name: Build debian packages
working-directory: px4_ros2_cpp
run: |
docker run --rm -v .:/work --platform ${{ matrix.platform }} buildenv:current
- name: Upload artifacts to github actions
uses: actions/upload-artifact@v3
with:
name: debian-packages
path: px4_ros2_cpp/output/*.deb


- name: Generate upload information
run: |
echo "DEBIAN_PACKAGE=$(ls px4_ros2_cpp/output/ | grep '\.deb')" >> $GITHUB_ENV
- run: |
echo "DEBIAN PACKAGE FILE: ${{ env.DEBIAN_PACKAGE }}"
- name: Push package to cloudsmith
if: ${{ github.event_name == 'release' }}
uses: cloudsmith-io/action@master
with:
api-key: ${{ secrets.AUTERION_CI_CLOUDSMITH_API_KEY }}
command: 'push'
format: 'deb'
owner: auterion
repo: public
distro: ubuntu
release: ${{ matrix.distro.ubuntu }}
file: px4_ros2_cpp/output/${{ env.DEBIAN_PACKAGE }}
40 changes: 40 additions & 0 deletions Dockerfile.debian-buildenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Dockerfile for a build environment to build Debian packages

ARG ROS2_DISTRO
ARG UBUNTU_DISTRO

FROM ros:${ROS2_DISTRO}-ros-base-${UBUNTU_DISTRO}

# Re-request ARGs to make them available in this stage
ARG ROS2_DISTRO

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4B63CF8FDE49746E98FA01DDAD19BAB3CBF125EA
RUN apt update && apt install -y \
dh-make \
python3-bloom \
python3-rosdep \
fakeroot \
dh-python

# Add auterion cloudsmith
RUN curl -1sLf \
'https://dl.cloudsmith.io/public/auterion/public/setup.deb.sh' \
| bash

RUN echo "yaml file:///work/rosdep-${ROS2_DISTRO}.yaml" > /etc/ros/rosdep/sources.list.d/99-local.list

RUN echo "#!/bin/bash" > /build_package.sh && \
echo "cd /work" >> /build_package.sh && \
echo "rosdep init" >> /build_package.sh && \
echo "rosdep update --rosdistro=$ROS2_DISTRO" >> /build_package.sh && \
echo "rosdep install --from-paths ." >> /build_package.sh && \
echo "bloom-generate rosdebian" >> /build_package.sh && \
echo "fakeroot debian/rules binary" >> /build_package.sh && \
echo "mkdir -p /work/output" >> /build_package.sh && \
echo "cp ../*.deb /work/output" >> /build_package.sh && \
chmod +x /build_package.sh

WORKDIR /work

CMD [ "/ros_entrypoint.sh", "/build_package.sh" ]
3 changes: 3 additions & 0 deletions px4_ros2_cpp/rosdep-foxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
px4_msgs:
ubuntu:
- ros-foxy-px4-msgs
3 changes: 3 additions & 0 deletions px4_ros2_cpp/rosdep-humble.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
px4_msgs:
ubuntu:
- ros-humble-px4-msgs
3 changes: 3 additions & 0 deletions px4_ros2_cpp/rosdep-rolling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
px4_msgs:
ubuntu:
- ros-rolling-px4-msgs

0 comments on commit 136fae4

Please sign in to comment.