Skip to content

Commit d95f2c4

Browse files
committed
change: unified deb build action
1 parent 9706e36 commit d95f2c4

15 files changed

Lines changed: 101 additions & 796 deletions

.github/workflows/build-deb.yaml

Lines changed: 93 additions & 64 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-ethercat"
3031
strategy:
3132
matrix:
3233
distro: [debian-12, debian-11, ubuntu-24.04, ubuntu-22.04]
@@ -52,13 +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 \
58-
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
5964
60-
curl -1sLf 'https://dl.cloudsmith.io/basic/robertburger/common/setup.deb.sh' | bash
61-
curl -1sLf 'https://dl.cloudsmith.io/basic/robertburger/robotkernel/setup.deb.sh' | bash
6265
apt-get update
6366
apt-get install -y libethercat-dev libosal-dev robotkernel-service-helper robotkernel-dev \
6467
service-provider-canopen-protocol-dev \
@@ -78,11 +81,8 @@ jobs:
7881

7982
- name: update branch name and version
8083
run: |
81-
safe_branch=$(echo "${GITHUB_REF_NAME}" | tr '/' '-')
8284
VERSION=$(dpkg-parsechangelog | sed -n 's/^Version: //p')
8385
sed "s|PACKAGE_VERSION|$VERSION|" configure.ac.in > configure.ac
84-
env:
85-
GITHUB_REF_NAME: ${{ github.ref_name }}
8686
8787
- name: Build .deb package
8888
shell: bash
@@ -91,79 +91,108 @@ jobs:
9191
CODENAME=$(lsb_release -sc)
9292
DEBEMAIL="robert.burger@dlr.de"
9393
DEBFULLNAME="Robert Burger"
94-
95-
if ! dpkg-parsechangelog | grep -q "~${CODENAME}"; then
96-
dch --local ~${CODENAME} "Build for ${CODENAME}";
94+
VERSION=$(dpkg-parsechangelog --show-field Version)
95+
96+
# Check if version already contains codename suffix
97+
if [[ "$VERSION" == *"~${CODENAME}"* || "$VERSION" == *"+${CODENAME}"* ]]; then
98+
echo "Version already contains codename suffix, skipping dch."
99+
else
100+
# If there's already a ~ in version (like ~pre1), add +codename
101+
if [[ "$VERSION" == *"~"* ]]; then
102+
dch --local +${CODENAME} --distribution ${CODENAME} "Build for ${CODENAME}"
103+
else
104+
dch --local ~${CODENAME} --distribution ${CODENAME} "Build for ${CODENAME}"
105+
fi
97106
fi
98107
99-
dpkg-buildpackage -us -uc -S
100-
dpkg-buildpackage -us -uc -d
108+
dpkg-buildpackage -us -uc -sa
101109
102-
- name: Collect .deb artifact
110+
- name: Debug artifact files
103111
run: |
104-
mkdir -p artifacts/${{ matrix.os }}/${{ matrix.version }}
105-
mv ../module-ethercat*.deb artifacts/${{ matrix.os }}/${{ matrix.version }}
106-
112+
ls -l ../
113+
107114
- name: Set sanitized image name
108115
id: sanitize
109116
run: |
110117
version=$(dpkg-parsechangelog | sed -n 's/^Version: //p')
111-
echo "sanitized_image=$(echo "${version}_amd64" | tr '/:' '--')" >> $GITHUB_OUTPUT
118+
echo "sanitized_image=$(echo "${version}" | tr '/:' '--')" >> $GITHUB_OUTPUT
119+
120+
- name: Upload to APT repository
121+
env:
122+
DEPLOY_TOKEN: ${{ secrets.BS_UPLOAD_KEY }}
123+
shell: bash
124+
run: |
125+
DISTRO="${{ matrix.distro }}"
126+
SANITIZED_IMAGE="${{ steps.sanitize.outputs.sanitized_image }}"
127+
128+
if [[ "$DISTRO" == "ubuntu-24.04" || "$DISTRO" == "ubuntu-22.04" ]]; then
129+
OLD_EXT=".ddeb"
130+
NEW_EXT=".deb"
131+
132+
OLD_FILE="${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64${OLD_EXT}"
133+
NEW_FILE="${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64${NEW_EXT}"
134+
CHANGES_FILE="${PKGNAME}_${SANITIZED_IMAGE}_amd64.changes"
135+
136+
mv "../$OLD_FILE" "../$NEW_FILE"
137+
sed -i "s/${OLD_FILE}/${NEW_FILE}/g" "../$CHANGES_FILE"
138+
fi
139+
140+
DBG_FILE="../${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64.deb"
141+
DEB_FILE="../${PKGNAME}_${SANITIZED_IMAGE}_amd64.deb"
142+
CHANGES_FILE="../${PKGNAME}_${SANITIZED_IMAGE}_amd64.changes"
143+
BUILDINFO_FILE="../${PKGNAME}_${SANITIZED_IMAGE}_amd64.buildinfo"
144+
DSC_FILE="../${PKGNAME}_${SANITIZED_IMAGE}.dsc"
145+
TAR_FILE="../${PKGNAME}_${SANITIZED_IMAGE}.tar.gz"
146+
147+
for f in "$DEB_FILE" "$DBG_FILE" "$CHANGES_FILE" "$BUILDINFO_FILE" "$DSC_FILE" "$TAR_FILE"; do
148+
[[ -f "$f" ]] || { echo "Missing file: $f"; exit 1; }
149+
done
150+
151+
curl -X POST https://deb.burger-system.de/upload \
152+
-H "Authorization: Bearer $DEPLOY_TOKEN" \
153+
-F "deb=@$DEB_FILE" \
154+
-F "dbgsym=@$DBG_FILE" \
155+
-F "changes=@$CHANGES_FILE" \
156+
-F "buildinfo=@$BUILDINFO_FILE" \
157+
-F "dsc=@$DSC_FILE" \
158+
-F "source=@$TAR_FILE"
159+
160+
- name: Collect .deb artifact
161+
run: |
162+
mkdir -p artifacts/
163+
rsync -av --exclude=${PKGNAME} ../ artifacts/
112164
113165
- name: Upload .deb package artifact
114166
uses: actions/upload-artifact@v4
115167
with:
116-
name: module-ethercat-${{ steps.sanitize.outputs.sanitized_image }}
117-
path: artifacts/${{ matrix.os }}/${{ matrix.version }}/
118-
119-
- name: Debug artifact files
120-
run: |
121-
ls -l ./artifacts/${{ matrix.os }}/${{ matrix.version }}/
168+
name: ${{ env.PKGNAME }}-artifacts-${{ steps.sanitize.outputs.sanitized_image }}
169+
path: artifacts/
122170

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

debian/control

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ Package: module-ethercat
1313
Architecture: any
1414
Multi-Arch: same
1515
Depends: robotkernel, libosal, libethercat, ${misc:Depends}
16-
Description: TODO
16+
Description: Robotkernel module for EtherCAT communication.
17+
module_ethercat implements an own developed EtherCAT-master stack (libethercat).
18+
.
19+
It's main benefit is an more deterministic frame scheduling and an improved
20+
distributed clock support with clock drift compensation.

debian/manpage.1.ex

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)