2626 build-deb :
2727 runs-on : ubuntu-latest
2828 env :
29- DEB_BUILD_OPTIONS : nocheck
29+ DEB_BUILD_OPTIONS : " compress=gzip nocheck"
30+ PKGNAME : " robotkernel-service-helper"
3031 strategy :
3132 matrix :
3233 distro : [debian-12, debian-11, ubuntu-24.04, ubuntu-22.04]
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 sed git tar gzip curl jq
59+ apt-get install -y build-essential devscripts debhelper autoconf-archive autotools-dev pkg-config sed git curl jq rsync
5860
5961 - name : Checkout source
6062 uses : actions/checkout@v4
6668
6769 - name : update branch name and version
6870 run : |
69- safe_branch=$(echo "${GITHUB_REF_NAME}" | tr '/' '-')
7071 VERSION=$(dpkg-parsechangelog | sed -n 's/^Version: //p')
7172 sed "s|PACKAGE_VERSION|$VERSION|" configure.ac.in > configure.ac
72- env :
73- GITHUB_REF_NAME : ${{ github.ref_name }}
7473
7574 - name : Build .deb package
7675 shell : bash
@@ -79,15 +78,23 @@ jobs:
7978 CODENAME=$(lsb_release -sc)
8079 DEBEMAIL="robert.burger@dlr.de"
8180 DEBFULLNAME="Robert Burger"
82-
83- if ! dpkg-parsechangelog | grep -q "~${CODENAME}"; then
84- dch --local ~${CODENAME} --distribution ${CODENAME} "Build for ${CODENAME}";
81+ VERSION=$(dpkg-parsechangelog --show-field Version)
82+
83+ # Check if version already contains codename suffix
84+ if [[ "$VERSION" == *"~${CODENAME}"* || "$VERSION" == *"+${CODENAME}"* ]]; then
85+ echo "Version already contains codename suffix, skipping dch."
86+ else
87+ # If there's already a ~ in version (like ~pre1), add +codename
88+ if [[ "$VERSION" == *"~"* ]]; then
89+ dch --local +${CODENAME} --distribution ${CODENAME} "Build for ${CODENAME}"
90+ else
91+ dch --local ~${CODENAME} --distribution ${CODENAME} "Build for ${CODENAME}"
92+ fi
8593 fi
8694
87- dpkg-buildpackage -us -uc -S
88- dpkg-buildpackage -us -uc -d -b
95+ dpkg-buildpackage -us -uc -sa
8996
90- - name : Debug artifact files 1
97+ - name : Debug artifact files
9198 run : |
9299 ls -l ../
93100
@@ -100,57 +107,81 @@ jobs:
100107 - name : Upload to APT repository
101108 env :
102109 DEPLOY_TOKEN : ${{ secrets.BS_UPLOAD_KEY }}
110+ shell : bash
103111 run : |
104- FILENAME="../robotkernel-service-helper_${{ steps.sanitize.outputs.sanitized_image }}"
112+ DISTRO="${{ matrix.distro }}"
113+ SANITIZED_IMAGE="${{ steps.sanitize.outputs.sanitized_image }}"
114+
115+ if [[ "$DISTRO" == "ubuntu-24.04" || "$DISTRO" == "ubuntu-22.04" ]]; then
116+ OLD_EXT=".ddeb"
117+ NEW_EXT=".deb"
118+
119+ OLD_FILE="${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64${OLD_EXT}"
120+ NEW_FILE="${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64${NEW_EXT}"
121+ CHANGES_FILE="${PKGNAME}_${SANITIZED_IMAGE}_amd64.changes"
122+
123+ mv "../$OLD_FILE" "../$NEW_FILE"
124+ sed -i "s/${OLD_FILE}/${NEW_FILE}/g" "../$CHANGES_FILE"
125+ fi
105126
127+ DBG_FILE="../${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64.deb"
128+ DEV_FILE="../${PKGNAME}-dev_${SANITIZED_IMAGE}_amd64.deb"
129+ DEB_FILE="../${PKGNAME}_${SANITIZED_IMAGE}_amd64.deb"
130+ CHANGES_FILE="../${PKGNAME}_${SANITIZED_IMAGE}_amd64.changes"
131+ BUILDINFO_FILE="../${PKGNAME}_${SANITIZED_IMAGE}_amd64.buildinfo"
132+ DSC_FILE="../${PKGNAME}_${SANITIZED_IMAGE}.dsc"
133+ TAR_FILE="../${PKGNAME}_${SANITIZED_IMAGE}.tar.gz"
134+
135+ for f in "$DEB_FILE" "$DEV_FILE" "$DBG_FILE" "$CHANGES_FILE" "$BUILDINFO_FILE" "$DSC_FILE" "$TAR_FILE"; do
136+ [[ -f "$f" ]] || { echo "Missing file: $f"; exit 1; }
137+ done
138+
106139 curl -X POST https://deb.burger-system.de/upload \
107140 -H "Authorization: Bearer $DEPLOY_TOKEN" \
108- -F "deb=@../robotkernel-service-helper_${{ steps.sanitize.outputs.sanitized_image }}_amd64.deb" \
109- -F "changes=@../robotkernel-service-helper_${{ steps.sanitize.outputs.sanitized_image }}_amd64.changes" \
110- -F "buildinfo=@../robotkernel-service-helper_${{ steps.sanitize.outputs.sanitized_image }}_amd64.buildinfo" \
111- -F "dsc=@../robotkernel-service-helper_${{ steps.sanitize.outputs.sanitized_image }}.dsc" \
112- -F "source=@../robotkernel-service-helper_${{ steps.sanitize.outputs.sanitized_image }}.tar.gz"
113-
141+ -F "deb=@$DEB_FILE" \
142+ -F "deb-dev=@$DEV_FILE" \
143+ -F "dbgsym=@$DBG_FILE" \
144+ -F "changes=@$CHANGES_FILE" \
145+ -F "buildinfo=@$BUILDINFO_FILE" \
146+ -F "dsc=@$DSC_FILE" \
147+ -F "source=@$TAR_FILE"
148+
114149 - name : Collect .deb artifact
115150 run : |
116- mkdir -p artifacts/${{ matrix.os }}/${{ matrix.version }}
117- mv ../robotkernel-service-helper*.deb artifacts/${{ matrix.os }}/${{ matrix.version }}
151+ mkdir -p artifacts/
152+ rsync -av --exclude=${PKGNAME} ../ artifacts/
118153
119154 - name : Upload .deb package artifact
120155 uses : actions/upload-artifact@v4
121156 with :
122- name : robotkernel-service-helper-${{ steps.sanitize.outputs.sanitized_image }}
123- path : artifacts/${{ matrix.os }}/${{ matrix.version }}/
124-
125- - name : Debug artifact files
126- run : |
127- ls -l ./artifacts/${{ matrix.os }}/${{ matrix.version }}/
157+ name : ${{ env.PKGNAME }}-artifacts-${{ steps.sanitize.outputs.sanitized_image }}
158+ path : artifacts/
128159
129160 # Fetch the release upload URL dynamically on tag builds
130- - name : Get Release Upload URL
161+ - name : Upload all artifacts to Release
131162 if : startsWith(github.ref, 'refs/tags/')
132- id : get_release
163+ env :
164+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
165+ GITHUB_REF_NAME : ${{ github.ref_name }}
133166 run : |
134167 release_json=$(curl -sSL \
135- -H "Authorization: token ${{ secrets. GITHUB_TOKEN }} " \
168+ -H "Authorization: token $GITHUB_TOKEN" \
136169 -H "Accept: application/vnd.github.v3+json" \
137170 "https://api.github.com/repos/${{ github.repository }}/releases/tags/${GITHUB_REF_NAME}")
171+
138172 upload_url=$(echo "$release_json" | jq -r '.upload_url' | sed -e "s/{?name,label}//")
139- echo "upload_url=$upload_url" >> $GITHUB_OUTPUT
140- env :
141- GITHUB_REF_NAME : ${{ github.ref_name }}
142-
143- - name : Upload asset manually with curl
144- if : startsWith(github.ref, 'refs/tags/')
145- env :
146- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
147- UPLOAD_URL : ${{ steps.get_release.outputs.upload_url }}
148- FILE_PATH : ./artifacts/${{ matrix.os }}/${{ matrix.version }}/robotkernel-service-helper_${{ steps.sanitize.outputs.sanitized_image }}.deb
149- FILE_NAME : robotkernel_${{ steps.sanitize.outputs.sanitized_image }}.deb
150- run : |
151- echo "Uploading $FILE_PATH to $UPLOAD_URL?name=$FILE_NAME"
152- curl --fail -X POST \
153- -H "Authorization: token $GITHUB_TOKEN" \
154- -H "Content-Type: application/vnd.debian.binary-package" \
155- --data-binary @"$FILE_PATH" \
156- "$UPLOAD_URL?name=$FILE_NAME"
173+ echo "Release upload URL : $upload_url"
174+
175+ if [ -d "./artifacts" ]; then
176+ for file in ./artifacts/*; do
177+ filename=$(basename "$file")
178+ echo "Uploading $file as $filename"
179+ curl --fail -X POST \
180+ -H "Authorization : token $GITHUB_TOKEN" \
181+ -H "Content-Type : application/octet-stream" \
182+ --data-binary @"$file" \
183+ " $upload_url?name=$filename"
184+ done
185+ else
186+ echo "Artifacts directory not found, skipping upload."
187+ fi
0 commit comments