Skip to content

fix: using robotkernel-generator in github action #36

fix: using robotkernel-generator in github action

fix: using robotkernel-generator in github action #36

Workflow file for this run

name: Build and Publish Debian Package
on:
push:
jobs:
create_release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v3
- id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
body: Automated release for tag ${{ github.ref_name }}
draft: false
prerelease: false
build-deb:
runs-on: ubuntu-latest
env:
DEB_BUILD_OPTIONS: "compress=gzip nocheck"
PKGNAME: "bridge-ln"
strategy:
matrix:
distro: [debian-12, debian-11, ubuntu-24.04, ubuntu-22.04]
include:
- distro: debian-12
image: debian:12
os: debian
version: bookworm
- distro: debian-11
image: debian:11
os: debian
version: bullseye
- distro: ubuntu-24.04
image: ubuntu:24.04
os: ubuntu
version: noble
- distro: ubuntu-22.04
image: ubuntu:22.04
os: ubuntu
version: jammy
container:
image: ${{ matrix.image }}
steps:
- name: Install build dependencies
shell: bash
run: |
apt-get update
apt-get install -y build-essential devscripts debhelper autotools-dev autoconf-archive \
pkg-config fakeroot sed git tar gzip python3-pip python3-venv curl jq libyaml-cpp-dev \
g++ automake make libtool libtomcrypt-dev python3-numpy rsync
case "${{ matrix.distro }}" in
debian-11|ubuntu-22.04)
apt-get install -y libprocps-dev
;;
*)
apt-get install -y libproc2-dev
;;
esac
curl -fsSL https://deb.burger-system.de/setup.sh | bash > /dev/null
apt-get update
apt-get install -y robotkernel-generator robotkernel-dev
- name: Build and install libstring_util
run: |
git clone -b 1.2.9 --recursive https://gitlab.com/links_and_nodes/libstring_util
cd libstring_util
test -f configure || autoreconf -if
mkdir -p build
cd build
test -f Makefile || ../configure "--prefix=/usr" --disable-shared --with-pic
make -j4 install
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Mark working directory as safe
run: git config --global --add safe.directory $GITHUB_WORKSPACE
- name: update branch name and version
run: |
safe_branch=$(echo "${GITHUB_REF_NAME}" | tr '/' '-')
VERSION=$(dpkg-parsechangelog | sed -n 's/^Version: //p')
sed "s|PACKAGE_VERSION|$VERSION|" configure.ac.in > configure.ac
env:
GITHUB_REF_NAME: ${{ github.ref_name }}
- name: Build .deb package
shell: bash
run: |
if [ ! -f configure.ac ]; then
VERSION=$(echo "${{ github.ref_name }}" | tr '/:' '--')
sed "s|PACKAGE_VERSION|$VERSION|" configure.ac.in > configure.ac
fi
test -f configure || autoreconf -if
git clone https://github.com/robotkernel-hal/ln_helper.git
git clone -b 2.4.4 --recurse-submodules https://gitlab.com/links_and_nodes/links_and_nodes
cd links_and_nodes/libln
python3 ../python/links_and_nodes_base/ln_generate -o include/ln/client_lib_messages.h --md-dir ../share/message_definitions ln2/request_topic ln/parameters/query ln/parameters/query_dict ln/parameters/override_dict_single ln/parameters/request_parameter_topic ln/event/call ln/event/connect ln/log_service
python3 ./scripts/generate_ln_errors_h include/ln/ln.h include/ln/errors.h
for f in src/*.c; do echo compiling $f; gcc $f -fPIC -Iinclude -Isrc -c -D__LINUX__ -DLTM_DESC -DUSE_LTM ; done
echo compiling src/sharedlnclient.cpp; g++ -fPIC src/sharedlnclient.cpp -Iinclude -Isrc -c -D__LINUX__ -DLTM_DESC -DUSE_LTM
echo creating libln.a; ar cr libln.a *.o
cd ../..
export CXXFLAGS="$(pkg-config --cflags libstring_util)"
export LDFLAGS="$(pkg-config --libs libstring_util)"
export LINKS_AND_NODES_CFLAGS="-I$(pwd)/links_and_nodes/libln/include"
export LINKS_AND_NODES_LIBS="$(pwd)/links_and_nodes/libln/libln.a -lrt"
export LN_HELPER_CFLAGS="-I$(pwd)/ln_helper/src/main/cpp"
export LN_HELPER_LIBS=" "
# baue mit dpkg-buildpackage (ohne signieren)
export DEBEMAIL="robert.burger@dlr.de"
export DEBFULLNAME="Robert Burger"
CODENAME=$(lsb_release -sc)
VERSION=$(dpkg-parsechangelog --show-field Version)
PRE_VERSION="pre${GITHUB_RUN_NUMBER}"
# Check if version already contains codename suffix
if [[ "$VERSION" == *"~${CODENAME}"* || "$VERSION" == *"+${CODENAME}"* ]]; then
echo "Version already contains codename suffix, skipping dch."
else
if [[ ! $GITHUB_REF =~ ^refs/tags/ ]]; then
# Not a tag, so add ~pre<x>
FULL_VERSION="${VERSION}~${PRE_VERSION}-1~${CODENAME}-pre"
dch -b --newversion "${FULL_VERSION}" --distribution "${CODENAME}-pre" "Pre-release for ${CODENAME}-pre"
else
FULL_VERSION="${VERSION}-1~${CODENAME}"
dch --newversion "${FULL_VERSION}" --distribution "${CODENAME}" "Pre-release for ${CODENAME}"
fi
fi
dpkg-buildpackage -us -uc -sa
- name: Debug artifact files
run: |
ls -l ../
- name: Set sanitized image name
id: sanitize
run: |
version=$(dpkg-parsechangelog | sed -n 's/^Version: //p')
echo "sanitized_image=$(echo "${version}" | tr '/:' '--')" >> $GITHUB_OUTPUT
- name: Upload to APT repository
env:
DEPLOY_TOKEN: ${{ secrets.BS_UPLOAD_KEY }}
shell: bash
run: |
DISTRO="${{ matrix.distro }}"
SANITIZED_IMAGE="${{ steps.sanitize.outputs.sanitized_image }}"
if [[ "$DISTRO" == "ubuntu-24.04" || "$DISTRO" == "ubuntu-22.04" ]]; then
OLD_EXT=".ddeb"
NEW_EXT=".deb"
OLD_FILE="${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64${OLD_EXT}"
NEW_FILE="${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64${NEW_EXT}"
CHANGES_FILE="${PKGNAME}_${SANITIZED_IMAGE}_amd64.changes"
mv "../$OLD_FILE" "../$NEW_FILE"
sed -i "s/${OLD_FILE}/${NEW_FILE}/g" "../$CHANGES_FILE"
fi
DBG_FILE="../${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64.deb"
DEB_FILE="../${PKGNAME}_${SANITIZED_IMAGE}_amd64.deb"
CHANGES_FILE="../${PKGNAME}_${SANITIZED_IMAGE}_amd64.changes"
BUILDINFO_FILE="../${PKGNAME}_${SANITIZED_IMAGE}_amd64.buildinfo"
DSC_FILE="../${PKGNAME}_${SANITIZED_IMAGE}.dsc"
TAR_FILE="../${PKGNAME}_${SANITIZED_IMAGE}.tar.gz"
for f in "$DEB_FILE" "$DBG_FILE" "$CHANGES_FILE" "$BUILDINFO_FILE" "$DSC_FILE" "$TAR_FILE"; do
[[ -f "$f" ]] || { echo "Missing file: $f"; exit 1; }
done
curl -X POST https://deb.burger-system.de/upload \
-H "Authorization: Bearer $DEPLOY_TOKEN" \
-F "deb=@$DEB_FILE" \
-F "dbgsym=@$DBG_FILE" \
-F "changes=@$CHANGES_FILE" \
-F "buildinfo=@$BUILDINFO_FILE" \
-F "dsc=@$DSC_FILE" \
-F "source=@$TAR_FILE"
- name: Collect .deb artifact
run: |
mkdir -p artifacts/
rsync -av --exclude=${PKGNAME} ../ artifacts/
- name: Upload .deb package artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKGNAME }}-artifacts-${{ steps.sanitize.outputs.sanitized_image }}
path: artifacts/
# Fetch the release upload URL dynamically on tag builds
- name: Upload all artifacts to Release
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REF_NAME: ${{ github.ref_name }}
run: |
release_json=$(curl -sSL \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${GITHUB_REF_NAME}")
upload_url=$(echo "$release_json" | jq -r '.upload_url' | sed -e "s/{?name,label}//")
echo "Release upload URL: $upload_url"
if [ -d "./artifacts" ]; then
for file in ./artifacts/*; do
filename=$(basename "$file")
echo "Uploading $file as $filename"
curl --fail -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$file" \
"$upload_url?name=$filename"
done
else
echo "Artifacts directory not found, skipping upload."
fi