Skip to content

Commit 833624c

Browse files
authored
CI: multi-series builds, SFTP upload, automatic changelog versioning (#233)
* Build for multiple versions of ubuntu * Use SFTP to upload to PPA * Build config changelog automation * stop daily prerelease
1 parent 43217dd commit 833624c

4 files changed

Lines changed: 109 additions & 14 deletions

File tree

‎.github/workflows/test.yaml‎

Lines changed: 81 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ jobs:
100100
needs: [dist, test-dist]
101101
runs-on: ubuntu-latest
102102
if: startsWith(github.ref, 'refs/tags/v')
103+
strategy:
104+
fail-fast: true
105+
matrix:
106+
series: [focal, jammy, noble]
103107

104108
steps:
105109
- name: Install dependencies
@@ -118,6 +122,8 @@ jobs:
118122
name: packaging-assets
119123

120124
- name: Assemble Debian source tree
125+
env:
126+
SERIES: ${{ matrix.series }}
121127
run: |
122128
tar xzf try-*.tgz
123129
srcdir=$(echo try-*/)
@@ -130,10 +136,30 @@ jobs:
130136
cp -R packaging/debian "$srcdir/debian"
131137
rm -f try-*.tgz packaging.tgz
132138
133-
revision=$(sed -n "1s/^try ([^)-]*-\([0-9]*\)).*/\1/p" "$srcdir/debian/changelog")
134-
sed -i "1s/^try ([^)]*)/try (${version}-${revision})/" "$srcdir/debian/changelog"
135-
136-
sed -i "1s/UNRELEASED/noble/" "$srcdir/debian/changelog"
139+
changelog="$srcdir/debian/changelog"
140+
committed=$(sed -n '1s/^try (\([^)]*\)).*/\1/p' "$changelog")
141+
if [ "${committed%-*}" = "$version" ]
142+
then
143+
# same upstream version: packaging-only revision, keep the committed one
144+
revision=${committed##*-}
145+
else
146+
# new upstream release: start again at revision 1
147+
revision=1
148+
maintainer=$(sed -n 's/^Maintainer: //p' "$srcdir/debian/control")
149+
{
150+
echo "try (${version}-1) UNRELEASED; urgency=medium"
151+
echo
152+
echo " * New upstream release ${version}."
153+
echo
154+
echo " -- ${maintainer} $(date -R)"
155+
echo
156+
cat "$changelog"
157+
} > "$changelog.new"
158+
mv "$changelog.new" "$changelog"
159+
fi
160+
sed -i "1s/^try ([^)]*)/try (${version}-${revision}~${SERIES}1)/" "$changelog"
161+
162+
sed -i "1s/UNRELEASED/${SERIES}/" "$changelog"
137163
echo "SRCDIR=$srcdir" >> "$GITHUB_ENV"
138164
139165
- name: Build the Debian source package
@@ -148,7 +174,7 @@ jobs:
148174
- name: Upload Debian source package
149175
uses: actions/upload-artifact@v7
150176
with:
151-
name: try-ppa-source
177+
name: try-ppa-source-${{ matrix.series }}
152178
path: |
153179
try_*.dsc
154180
try_*.orig.tar.gz
@@ -446,12 +472,13 @@ jobs:
446472
- name: Install dependencies
447473
run: |
448474
sudo apt-get update
449-
sudo apt-get install -y devscripts dput gnupg
475+
sudo apt-get install -y devscripts dput gnupg openssh-client python3-paramiko
450476
451-
- name: Download the Debian source package
477+
- name: Download the Debian source packages
452478
uses: actions/download-artifact@v8
453479
with:
454-
name: try-ppa-source
480+
pattern: try-ppa-source-*
481+
merge-multiple: true
455482

456483
- name: Import GPG signing key
457484
env:
@@ -460,14 +487,57 @@ jobs:
460487
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
461488
echo "KEYID=$(gpg --list-secret-keys --with-colons | awk -F: '/^sec/ {print $5; exit}')" >> "$GITHUB_ENV"
462489
490+
- name: Configure SFTP upload to Launchpad
491+
env:
492+
SSH_KEY: ${{ secrets.PPA_SSH_KEY }}
493+
PPA_TARGET: ${{ vars.PPA_TARGET }}
494+
PPA_LOGIN: ${{ vars.PPA_LOGIN }}
495+
run: |
496+
mkdir -p ~/.ssh
497+
chmod 700 ~/.ssh
498+
echo "$SSH_KEY" > ~/.ssh/id_ed25519
499+
chmod 600 ~/.ssh/id_ed25519
500+
ssh-keyscan ppa.launchpad.net >> ~/.ssh/known_hosts
501+
ssh-keygen -lf ~/.ssh/known_hosts
502+
503+
ppa=${PPA_TARGET#ppa:}
504+
owner=${ppa%%/*}
505+
name=${ppa#*/}
506+
cat > ~/.dput.cf <<EOF
507+
[ppa-sftp]
508+
fqdn = ppa.launchpad.net
509+
method = sftp
510+
incoming = ~${owner}/ubuntu/${name}/
511+
login = ${PPA_LOGIN:-$owner}
512+
allow_unsigned_uploads = 0
513+
EOF
514+
463515
- name: Sign and upload to the PPA
464516
env:
465517
GPG_PASSPHRASE: ${{ secrets.PPA_GPG_PASSPHRASE }}
466518
run: |
467519
echo "$GPG_PASSPHRASE" > /tmp/gpg-passphrase
468-
debsign -k"$KEYID" -p"gpg --batch --yes --pinentry-mode loopback --passphrase-file /tmp/gpg-passphrase" try_*_source.changes
520+
failed=""
521+
for changes in try_*_source.changes
522+
do
523+
debsign -k"$KEYID" -p"gpg --batch --yes --pinentry-mode loopback --passphrase-file /tmp/gpg-passphrase" "$changes"
524+
uploaded=""
525+
for attempt in 1 2 3 4 5
526+
do
527+
if dput ppa-sftp "$changes"
528+
then
529+
uploaded=yes
530+
break
531+
fi
532+
echo "upload of $changes failed (attempt $attempt); retrying in 60s"
533+
sleep 60
534+
done
535+
[ -n "$uploaded" ] || failed="$failed $changes"
536+
# give Launchpad's upload server time to finish the previous upload
537+
sleep 30
538+
done
469539
rm -f /tmp/gpg-passphrase
470-
dput "${{ vars.PPA_TARGET }}" try_*_source.changes
540+
[ -z "$failed" ] || { echo "failed uploads:$failed"; exit 1; }
471541
472542
prerelease:
473543
needs:
@@ -479,7 +549,7 @@ jobs:
479549
- trycase-check
480550
- package
481551
runs-on: ubuntu-latest
482-
if: ${{ github.ref == 'refs/heads/main' }}
552+
if: ${{ github.ref == 'refs/heads/main' && github.event_name != 'schedule' }}
483553

484554
steps:
485555
- name: Download dist tarball

‎packaging/debian/README‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,31 @@ builds a source package. CI (`ppa-source-check` in
1616
result with `lintian`; `publish-ppa` signs and uploads it to the configured
1717
PPA via `dput`.
1818

19+
# Versioning
20+
21+
You don't edit `debian/changelog` for a normal release. CI takes the
22+
upstream version from the release tarball and compares it with the top
23+
entry of the committed changelog:
24+
25+
* Different (a new upstream release): CI starts at revision 1 and adds a
26+
"New upstream release" entry itself.
27+
* Same (a packaging-only fix, e.g. a `debian/control` change): CI keeps the
28+
committed revision, so bump it by hand (`0.2.1-1` to `0.2.1-2`) in the PR
29+
that makes the fix.
30+
31+
# Supported Ubuntu series
32+
33+
CI builds and uploads one source package per Ubuntu series, listed in the
34+
`matrix.series` of `ppa-source-check` in `.github/workflows/test.yaml`
35+
(currently `focal`, `jammy`, `noble`). Each upload gets its own version
36+
(`<version>-<revision>~<series>1`, e.g. `0.2.1-1~focal1`), because a PPA
37+
won't accept the same version twice; the `.orig.tar.gz` is shared and
38+
byte-identical across them.
39+
40+
`debian/control` uses `debhelper-compat (= 12)` rather than 13 because
41+
focal (20.04) ships debhelper 12.10, which can't satisfy 13. Raise it only
42+
if focal is dropped.
43+
1944
# Testing that a published PPA package actually installs and works
2045

2146
Once a build succeeds on Launchpad, verify it installs cleanly in an

‎packaging/debian/changelog‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
try (0.2.1-1) UNRELEASED; urgency=medium
1+
try (0.2.1-2) UNRELEASED; urgency=medium
22

33
* Add PPA release workflow: Debian source packaging (debian/) built,
44
linted, signed, and published to a Launchpad PPA by CI on version
5-
tag pushes.
5+
tag pushes, for Ubuntu 20.04 (focal), 22.04 (jammy) and 24.04 (noble).
66

77
-- try maintainers <try@binpa.sh> Tue, 15 Sep 2026 14:32:00 -0400

‎packaging/debian/control‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Source: try
22
Section: utils
33
Priority: optional
44
Maintainer: try maintainers <try@binpa.sh>
5-
Build-Depends: debhelper-compat (= 13), autoconf, pandoc, attr
5+
Build-Depends: debhelper-compat (= 12), autoconf, pandoc, attr
66
Standards-Version: 4.6.2
77
Homepage: https://github.com/binpash/try
88
Rules-Requires-Root: no

0 commit comments

Comments
 (0)