Skip to content

Commit 72da3a1

Browse files
committed
change: unified deb build action
1 parent 7414565 commit 72da3a1

File tree

3 files changed

+100
-66
lines changed

3 files changed

+100
-66
lines changed

.github/workflows/build-deb.yaml

Lines changed: 95 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ jobs:
2626
build-deb:
2727
runs-on: ubuntu-latest
2828
env:
29-
DEB_BUILD_OPTIONS: nocheck
29+
DEB_BUILD_OPTIONS: "compress=gzip nocheck"
30+
PKGNAME: "module-posix-timer"
3031
strategy:
3132
matrix:
3233
distro: [debian-12, debian-11, ubuntu-24.04, ubuntu-22.04]
@@ -52,11 +53,15 @@ jobs:
5253

5354
steps:
5455
- name: Install build dependencies
56+
shell: bash
5557
run: |
5658
apt-get update
57-
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
59+
apt-get install -y build-essential devscripts debhelper autoconf-archive autotools-dev pkg-config sed git tar gzip curl jq libyaml-cpp-dev rsync
60+
61+
CODENAME=$(lsb_release -sc)
62+
curl -fsSL https://deb.burger-system.de/deb.burger-system.de.gpg | tee /usr/share/keyrings/deb.burger-system.de.gpg > /dev/null
63+
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/deb.burger-system.de.gpg] https://deb.burger-system.de/debian ${CODENAME} main" | tee /etc/apt/sources.list.d/burger-system.list > /dev/null
5864
59-
curl -1sLf 'https://dl.cloudsmith.io/basic/robertburger/robotkernel/setup.deb.sh' | bash
6065
apt-get update
6166
apt-get install -y robotkernel-service-helper robotkernel-dev service-provider-process-data-inspection-dev
6267
@@ -70,11 +75,8 @@ jobs:
7075

7176
- name: update branch name and version
7277
run: |
73-
safe_branch=$(echo "${GITHUB_REF_NAME}" | tr '/' '-')
7478
VERSION=$(dpkg-parsechangelog | sed -n 's/^Version: //p')
7579
sed "s|PACKAGE_VERSION|$VERSION|" configure.ac.in > configure.ac
76-
env:
77-
GITHUB_REF_NAME: ${{ github.ref_name }}
7880
7981
- name: Build .deb package
8082
shell: bash
@@ -83,79 +85,110 @@ jobs:
8385
CODENAME=$(lsb_release -sc)
8486
DEBEMAIL="[email protected]"
8587
DEBFULLNAME="Robert Burger"
86-
87-
if ! dpkg-parsechangelog | grep -q "~${CODENAME}"; then
88-
dch --local ~${CODENAME} "Build for ${CODENAME}";
88+
VERSION=$(dpkg-parsechangelog --show-field Version)
89+
90+
# Check if version already contains codename suffix
91+
if [[ "$VERSION" == *"~${CODENAME}"* || "$VERSION" == *"+${CODENAME}"* ]]; then
92+
echo "Version already contains codename suffix, skipping dch."
93+
else
94+
# If there's already a ~ in version (like ~pre1), add +codename
95+
if [[ "$VERSION" == *"~"* ]]; then
96+
dch --local +${CODENAME} --distribution ${CODENAME} "Build for ${CODENAME}"
97+
else
98+
dch --local ~${CODENAME} --distribution ${CODENAME} "Build for ${CODENAME}"
99+
fi
89100
fi
90101
91-
dpkg-buildpackage -us -uc -S
92-
dpkg-buildpackage -us -uc -d
102+
dpkg-buildpackage -us -uc -sa
93103
94-
- name: Collect .deb artifact
104+
- name: Debug artifact files
95105
run: |
96-
mkdir -p artifacts/${{ matrix.os }}/${{ matrix.version }}
97-
mv ../module-posix-timer*.deb artifacts/${{ matrix.os }}/${{ matrix.version }}
98-
106+
ls -l ../
107+
99108
- name: Set sanitized image name
100109
id: sanitize
101110
run: |
102111
version=$(dpkg-parsechangelog | sed -n 's/^Version: //p')
103-
echo "sanitized_image=$(echo "${version}_amd64" | tr '/:' '--')" >> $GITHUB_OUTPUT
112+
echo "sanitized_image=$(echo "${version}" | tr '/:' '--')" >> $GITHUB_OUTPUT
113+
114+
- name: Upload to APT repository
115+
env:
116+
DEPLOY_TOKEN: ${{ secrets.BS_UPLOAD_KEY }}
117+
shell: bash
118+
run: |
119+
DISTRO="${{ matrix.distro }}"
120+
SANITIZED_IMAGE="${{ steps.sanitize.outputs.sanitized_image }}"
121+
122+
if [[ "$DISTRO" == "ubuntu-24.04" || "$DISTRO" == "ubuntu-22.04" ]]; then
123+
OLD_EXT=".ddeb"
124+
NEW_EXT=".deb"
125+
126+
OLD_FILE="${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64${OLD_EXT}"
127+
NEW_FILE="${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64${NEW_EXT}"
128+
CHANGES_FILE="${PKGNAME}_${SANITIZED_IMAGE}_amd64.changes"
129+
130+
mv "../$OLD_FILE" "../$NEW_FILE"
131+
sed -i "s/${OLD_FILE}/${NEW_FILE}/g" "../$CHANGES_FILE"
132+
fi
133+
134+
DBG_FILE="../${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64.deb"
135+
DEV_FILE="../${PKGNAME}-dev_${SANITIZED_IMAGE}_amd64.deb"
136+
DEB_FILE="../${PKGNAME}_${SANITIZED_IMAGE}_amd64.deb"
137+
CHANGES_FILE="../${PKGNAME}_${SANITIZED_IMAGE}_amd64.changes"
138+
BUILDINFO_FILE="../${PKGNAME}_${SANITIZED_IMAGE}_amd64.buildinfo"
139+
DSC_FILE="../${PKGNAME}_${SANITIZED_IMAGE}.dsc"
140+
TAR_FILE="../${PKGNAME}_${SANITIZED_IMAGE}.tar.gz"
141+
142+
for f in "$DEB_FILE" "$DEV_FILE" "$DBG_FILE" "$CHANGES_FILE" "$BUILDINFO_FILE" "$DSC_FILE" "$TAR_FILE"; do
143+
[[ -f "$f" ]] || { echo "Missing file: $f"; exit 1; }
144+
done
145+
146+
curl -X POST https://deb.burger-system.de/upload \
147+
-H "Authorization: Bearer $DEPLOY_TOKEN" \
148+
-F "deb=@$DEB_FILE" \
149+
-F "deb-dev=@$DEV_FILE" \
150+
-F "dbgsym=@$DBG_FILE" \
151+
-F "changes=@$CHANGES_FILE" \
152+
-F "buildinfo=@$BUILDINFO_FILE" \
153+
-F "dsc=@$DSC_FILE" \
154+
-F "source=@$TAR_FILE"
155+
156+
- name: Collect .deb artifact
157+
run: |
158+
mkdir -p artifacts/
159+
rsync -av --exclude=${PKGNAME} ../ artifacts/
104160
105161
- name: Upload .deb package artifact
106162
uses: actions/upload-artifact@v4
107163
with:
108-
name: module-posix-timer-${{ steps.sanitize.outputs.sanitized_image }}
109-
path: artifacts/${{ matrix.os }}/${{ matrix.version }}/
110-
111-
- name: Debug artifact files
112-
run: |
113-
ls -l ./artifacts/${{ matrix.os }}/${{ matrix.version }}/
164+
name: ${{ env.PKGNAME }}-artifacts-${{ steps.sanitize.outputs.sanitized_image }}
165+
path: artifacts/
114166

115167
# Fetch the release upload URL dynamically on tag builds
116-
- name: Get Release Upload URL
168+
- name: Upload all artifacts to Release
117169
if: startsWith(github.ref, 'refs/tags/')
118-
id: get_release
170+
env:
171+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
172+
GITHUB_REF_NAME: ${{ github.ref_name }}
119173
run: |
120174
release_json=$(curl -sSL \
121-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
175+
-H "Authorization: token $GITHUB_TOKEN" \
122176
-H "Accept: application/vnd.github.v3+json" \
123177
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${GITHUB_REF_NAME}")
178+
124179
upload_url=$(echo "$release_json" | jq -r '.upload_url' | sed -e "s/{?name,label}//")
125-
echo "upload_url=$upload_url" >> $GITHUB_OUTPUT
126-
env:
127-
GITHUB_REF_NAME: ${{ github.ref_name }}
128-
129-
- name: Upload asset manually with curl
130-
if: startsWith(github.ref, 'refs/tags/')
131-
env:
132-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133-
UPLOAD_URL: ${{ steps.get_release.outputs.upload_url }}
134-
FILE_PATH: ./artifacts/${{ matrix.os }}/${{ matrix.version }}/module-posix-timer_${{ steps.sanitize.outputs.sanitized_image }}.deb
135-
FILE_NAME: module-posix-timer_${{ steps.sanitize.outputs.sanitized_image }}.deb
136-
run: |
137-
echo "Uploading $FILE_PATH to $UPLOAD_URL?name=$FILE_NAME"
138-
curl --fail -X POST \
139-
-H "Authorization: token $GITHUB_TOKEN" \
140-
-H "Content-Type: application/vnd.debian.binary-package" \
141-
--data-binary @"$FILE_PATH" \
142-
"$UPLOAD_URL?name=$FILE_NAME"
143-
144-
- name: Upload to Cloudsmith (${{ matrix.os }}/${{ matrix.version }})
145-
#if: startsWith(github.ref, 'refs/tags/')
146-
env:
147-
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
148-
shell: bash
149-
run: |
150-
FILENAME="artifacts/${{ matrix.os }}/${{ matrix.version }}/module-posix-timer_${{ steps.sanitize.outputs.sanitized_image }}.deb"
151-
152-
python3 -m venv cloudsmith
153-
cd cloudsmith
154-
source bin/activate
155-
156-
python3 -m pip install --upgrade pip
157-
pip3 install cloudsmith-cli
158-
159-
cloudsmith push deb robertburger/robotkernel/${{ matrix.os }}/${{ matrix.version }} ../${FILENAME} \
160-
--republish \
161-
--api-key "$CLOUDSMITH_API_KEY"
180+
echo "Release upload URL: $upload_url"
181+
182+
if [ -d "./artifacts" ]; then
183+
for file in ./artifacts/*; do
184+
filename=$(basename "$file")
185+
echo "Uploading $file as $filename"
186+
curl --fail -X POST \
187+
-H "Authorization: token $GITHUB_TOKEN" \
188+
-H "Content-Type: application/octet-stream" \
189+
--data-binary @"$file" \
190+
"$upload_url?name=$filename"
191+
done
192+
else
193+
echo "Artifacts directory not found, skipping upload."
194+
fi

debian/changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module-posix-timer (6.0.0~pre1) unstable; urgency=low
22

33
* prep: 6.0.0
4+
* update: debian docs
45

56
-- Robert Burger <[email protected]> Wed, 22 Jan 2025 10:29:08 +0100
67

debian/rules

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/make -f
22
# See debhelper(7) (uncomment to enable)
33
# output every command that modifies files on the build system.
4-
#export DH_VERBOSE = 1
5-
4+
# export DH_VERBOSE = 1
65

76
# see FEATURE AREAS in dpkg-buildflags(1)
87
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
@@ -12,11 +11,12 @@
1211
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
1312
# package maintainers to append LDFLAGS
1413
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
15-
16-
14+
1715
%:
1816
dh $@
1917

18+
override_dh_builddeb:
19+
dh_builddeb -- -Zgzip
2020

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

0 commit comments

Comments
 (0)