Skip to content

Commit 9f554e4

Browse files
committed
ci: add Launchpad PPA publish workflow
1 parent 8cf83c2 commit 9f554e4

2 files changed

Lines changed: 138 additions & 3 deletions

File tree

.github/workflows/ppa-publish.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Publish to Launchpad PPA
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: "Version to publish (e.g. 0.1.6). Defaults to the tag."
10+
required: false
11+
series:
12+
description: "Comma-separated Ubuntu series (e.g. noble,jammy). Default: noble"
13+
required: false
14+
default: "noble"
15+
16+
jobs:
17+
resolve:
18+
runs-on: ubuntu-24.04
19+
outputs:
20+
version: ${{ steps.v.outputs.version }}
21+
series_matrix: ${{ steps.v.outputs.series_matrix }}
22+
env:
23+
INPUT_VERSION: ${{ inputs.version }}
24+
INPUT_SERIES: ${{ inputs.series }}
25+
REF_NAME: ${{ github.ref_name }}
26+
steps:
27+
- id: v
28+
run: |
29+
set -eu
30+
if [ -n "${INPUT_VERSION:-}" ]; then
31+
VERSION="$INPUT_VERSION"
32+
else
33+
VERSION="${REF_NAME#v}"
34+
fi
35+
# Strict version sanity check: digits and dots only, plus optional suffix.
36+
if ! printf '%s' "$VERSION" | grep -Eq '^[0-9]+(\.[0-9]+){0,3}([a-zA-Z0-9.+~-]*)$'; then
37+
echo "Refusing unsafe version string: $VERSION" >&2
38+
exit 1
39+
fi
40+
SERIES="${INPUT_SERIES:-noble}"
41+
# Whitelist series names (alnum only) before passing them downstream.
42+
MATRIX=$(printf '%s' "$SERIES" \
43+
| tr ',' '\n' \
44+
| sed 's/^ *//; s/ *$//' \
45+
| grep -E '^[a-z][a-z0-9]+$' \
46+
| jq -R . | jq -sc .)
47+
if [ "$MATRIX" = "[]" ]; then
48+
echo "No valid series after whitelist filter: $SERIES" >&2
49+
exit 1
50+
fi
51+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
52+
echo "series_matrix=$MATRIX" >> "$GITHUB_OUTPUT"
53+
echo "Publishing version=$VERSION to series=$MATRIX"
54+
55+
publish:
56+
needs: resolve
57+
runs-on: ubuntu-24.04
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
series: ${{ fromJSON(needs.resolve.outputs.series_matrix) }}
62+
env:
63+
VERSION: ${{ needs.resolve.outputs.version }}
64+
SERIES: ${{ matrix.series }}
65+
DEBEMAIL: spiderpower02@gmail.com
66+
DEBFULLNAME: Chang Ning Tsai
67+
PPA: ppa:crazyguitar/rdmatop
68+
KEY_ID: ${{ secrets.LAUNCHPAD_GPG_KEY_ID }}
69+
steps:
70+
- uses: actions/checkout@v4
71+
72+
- name: Install build tooling
73+
run: |
74+
sudo apt-get update -qq
75+
sudo apt-get install -y -qq --no-install-recommends \
76+
devscripts debhelper dput build-essential cargo rustc gnupg jq
77+
78+
- name: Import GPG signing key
79+
env:
80+
LAUNCHPAD_GPG_PRIVATE_KEY: ${{ secrets.LAUNCHPAD_GPG_PRIVATE_KEY }}
81+
run: |
82+
set -eu
83+
mkdir -p ~/.gnupg && chmod 700 ~/.gnupg
84+
printf '%s' "$LAUNCHPAD_GPG_PRIVATE_KEY" | gpg --batch --import
85+
gpg --list-secret-keys --keyid-format=long
86+
# Trust the imported key so debuild can use it non-interactively.
87+
printf '5\ny\n' | gpg --batch --command-fd 0 --expert --edit-key "$KEY_ID" trust quit || true
88+
89+
- name: Vendor Rust dependencies
90+
run: |
91+
set -eu
92+
cargo vendor vendor/ > /dev/null
93+
mkdir -p .cargo
94+
cat > .cargo/config.toml <<'EOF'
95+
[source.crates-io]
96+
replace-with = "vendored-sources"
97+
98+
[source.vendored-sources]
99+
directory = "vendor"
100+
EOF
101+
102+
- name: Regenerate debian/changelog
103+
run: |
104+
set -eu
105+
rm -f debian/changelog
106+
dch --create --package rdmatop \
107+
--newversion "${VERSION}-1ppa1~${SERIES}1" \
108+
--distribution "$SERIES" \
109+
"Release ${VERSION} for ${SERIES}."
110+
head -n 5 debian/changelog
111+
112+
- name: Build signed source package
113+
run: |
114+
set -eu
115+
debuild -S -sa --no-lintian -k"$KEY_ID"
116+
ls -la ../
117+
118+
- name: Upload to Launchpad PPA
119+
run: |
120+
set -eu
121+
dput "$PPA" "../rdmatop_${VERSION}-1ppa1~${SERIES}1_source.changes"
122+
123+
- name: Stash source artifacts
124+
if: always()
125+
uses: actions/upload-artifact@v4
126+
with:
127+
name: ppa-source-${{ matrix.series }}
128+
path: |
129+
../rdmatop_*.dsc
130+
../rdmatop_*.tar.*
131+
../rdmatop_*.changes
132+
../rdmatop_*.buildinfo
133+
if-no-files-found: warn

debian/changelog

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
rdmatop (0.1.6-1ppa1~noble1) noble; urgency=medium
1+
rdmatop (0.0.0-placeholder) UNRELEASED; urgency=medium
22

3-
* Initial PPA release.
3+
* This file is regenerated by .github/workflows/ppa-publish.yml on every
4+
release. The entry below is a placeholder so dpkg-parsechangelog has
5+
something to read for local debugging; do not bump it by hand.
46

5-
-- Chang Ning Tsai <spiderpower02@gmail.com> Fri, 24 Apr 2026 14:40:00 +0000
7+
-- Chang Ning Tsai <spiderpower02@gmail.com> Fri, 24 Apr 2026 00:00:00 +0000

0 commit comments

Comments
 (0)