Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 80 additions & 63 deletions .github/workflows/build-deb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jobs:
build-deb:
runs-on: ubuntu-latest
env:
DEB_BUILD_OPTIONS: nocheck
DEB_BUILD_OPTIONS: "compress=gzip nocheck"
PKGNAME: "robotkernel-service-helper"
strategy:
matrix:
distro: [debian-12, debian-11, ubuntu-24.04, ubuntu-22.04]
Expand All @@ -52,9 +53,10 @@ jobs:

steps:
- name: Install build dependencies
shell: bash
run: |
apt-get update
apt-get install -y build-essential devscripts debhelper autotools-dev autoconf-archive fakeroot sed git tar gzip python3-pip python3-venv curl jq
apt-get install -y build-essential devscripts debhelper autoconf-archive autotools-dev pkg-config sed git curl jq rsync

- name: Checkout source
uses: actions/checkout@v4
Expand All @@ -66,92 +68,107 @@ jobs:

- 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: |
# baue mit dpkg-buildpackage (ohne signieren)
export DEBEMAIL="robert.burger@dlr.de"
export DEBFULLNAME="Robert Burger"
CODENAME=$(lsb_release -sc)
DEBEMAIL="robert.burger@dlr.de"
DEBFULLNAME="Robert Burger"

if ! dpkg-parsechangelog | grep -q "~${CODENAME}"; then
dch --local ~${CODENAME} "Build for ${CODENAME}";
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 -S
dpkg-buildpackage -us -uc -d
dpkg-buildpackage -us -uc -sa

- name: Collect .deb artifact
- name: Debug artifact files
run: |
mkdir -p artifacts/${{ matrix.os }}/${{ matrix.version }}
mv ../robotkernel-service-helper*.deb artifacts/${{ matrix.os }}/${{ matrix.version }}

ls -l ../

- name: Set sanitized image name
id: sanitize
run: |
version=$(dpkg-parsechangelog | sed -n 's/^Version: //p')
echo "sanitized_image=$(echo "${version}_amd64" | tr '/:' '--')" >> $GITHUB_OUTPUT
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 }}"

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" "$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 "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: robotkernel-service-helper-${{ steps.sanitize.outputs.sanitized_image }}
path: artifacts/${{ matrix.os }}/${{ matrix.version }}/

- name: Debug artifact files
run: |
ls -l ./artifacts/${{ matrix.os }}/${{ matrix.version }}/
name: ${{ env.PKGNAME }}-artifacts-${{ steps.sanitize.outputs.sanitized_image }}
path: artifacts/

# Fetch the release upload URL dynamically on tag builds
- name: Get Release Upload URL
- name: Upload all artifacts to Release
if: startsWith(github.ref, 'refs/tags/')
id: get_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REF_NAME: ${{ github.ref_name }}
run: |
release_json=$(curl -sSL \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-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 "upload_url=$upload_url" >> $GITHUB_OUTPUT
env:
GITHUB_REF_NAME: ${{ github.ref_name }}

- name: Upload asset manually with curl
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
UPLOAD_URL: ${{ steps.get_release.outputs.upload_url }}
FILE_PATH: ./artifacts/${{ matrix.os }}/${{ matrix.version }}/robotkernel-service-helper_${{ steps.sanitize.outputs.sanitized_image }}.deb
FILE_NAME: robotkernel_${{ steps.sanitize.outputs.sanitized_image }}.deb
run: |
echo "Uploading $FILE_PATH to $UPLOAD_URL?name=$FILE_NAME"
curl --fail -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/vnd.debian.binary-package" \
--data-binary @"$FILE_PATH" \
"$UPLOAD_URL?name=$FILE_NAME"

- name: Upload to Cloudsmith (${{ matrix.os }}/${{ matrix.version }})
#if: startsWith(github.ref, 'refs/tags/')
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
shell: bash
run: |
FILENAME="artifacts/${{ matrix.os }}/${{ matrix.version }}/robotkernel-service-helper_${{ steps.sanitize.outputs.sanitized_image }}.deb"

python3 -m venv cloudsmith
cd cloudsmith
source bin/activate

python3 -m pip install --upgrade pip
pip3 install cloudsmith-cli

cloudsmith push deb robertburger/robotkernel/${{ matrix.os }}/${{ matrix.version }} ../${FILENAME} \
--republish \
--api-key "$CLOUDSMITH_API_KEY"
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
2 changes: 1 addition & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
robotkernel-service-helper (6.0.0~pre1) unstable; urgency=low
robotkernel-service-helper (6.0.0) unstable; urgency=low

* prepare: deb package release

Expand Down
2 changes: 2 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export DH_VERBOSE = 1
%:
dh $@

override_dh_builddeb:
dh_builddeb -- -Zgzip

# dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 )
Expand Down