-
Notifications
You must be signed in to change notification settings - Fork 5
173 lines (159 loc) · 5.73 KB
/
Copy pathppa-publish.yml
File metadata and controls
173 lines (159 loc) · 5.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Publish to Launchpad PPA
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 0.1.6). Defaults to the tag."
required: false
series:
description: "Comma-separated Ubuntu series (e.g. noble,jammy). Default: noble,jammy"
required: false
default: "noble,jammy"
jobs:
resolve:
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.v.outputs.version }}
series_matrix: ${{ steps.v.outputs.series_matrix }}
env:
INPUT_VERSION: ${{ inputs.version }}
INPUT_SERIES: ${{ inputs.series }}
REF_NAME: ${{ github.ref_name }}
steps:
- id: v
run: |
set -eu
if [ -n "${INPUT_VERSION:-}" ]; then
VERSION="$INPUT_VERSION"
else
VERSION="${REF_NAME#v}"
fi
# Strict version sanity check: digits and dots only, plus optional suffix.
if ! printf '%s' "$VERSION" | grep -Eq '^[0-9]+(\.[0-9]+){0,3}([a-zA-Z0-9.+~-]*)$'; then
echo "Refusing unsafe version string: $VERSION" >&2
exit 1
fi
SERIES="${INPUT_SERIES:-noble,jammy}"
# Whitelist series names (alnum only) before passing them downstream.
MATRIX=$(printf '%s' "$SERIES" \
| tr ',' '\n' \
| sed 's/^ *//; s/ *$//' \
| grep -E '^[a-z][a-z0-9]+$' \
| jq -R . | jq -sc .)
if [ "$MATRIX" = "[]" ]; then
echo "No valid series after whitelist filter: $SERIES" >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "series_matrix=$MATRIX" >> "$GITHUB_OUTPUT"
echo "Publishing version=$VERSION to series=$MATRIX"
publish:
needs: resolve
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
series: ${{ fromJSON(needs.resolve.outputs.series_matrix) }}
env:
VERSION: ${{ needs.resolve.outputs.version }}
SERIES: ${{ matrix.series }}
DEBEMAIL: spiderpower02@gmail.com
DEBFULLNAME: Chang Ning Tsai
PPA: ppa:crazyguitar/rdmatop
KEY_ID: ${{ secrets.LAUNCHPAD_GPG_KEY_ID }}
steps:
- uses: actions/checkout@v4
- name: Install build tooling
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq --no-install-recommends \
devscripts debhelper dput build-essential cargo-1.91 rustc-1.91 gnupg jq
/usr/lib/rust-1.91/bin/cargo --version
/usr/lib/rust-1.91/bin/rustc --version
- name: Import GPG signing key
env:
LAUNCHPAD_GPG_PRIVATE_KEY: ${{ secrets.LAUNCHPAD_GPG_PRIVATE_KEY }}
run: |
set -eu
mkdir -p ~/.gnupg && chmod 700 ~/.gnupg
printf '%s' "$LAUNCHPAD_GPG_PRIVATE_KEY" | gpg --batch --import
gpg --list-secret-keys --keyid-format=long
# Trust the imported key so debuild can use it non-interactively.
printf '5\ny\n' | gpg --batch --command-fd 0 --expert --edit-key "$KEY_ID" trust quit || true
- name: Vendor Rust dependencies
env:
PATH: /usr/lib/rust-1.91/bin:/usr/bin:/bin
run: |
set -eu
rm -f Cargo.lock
cargo vendor vendor/ > /dev/null
mkdir -p .cargo
cat > .cargo/config.toml <<'EOF'
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"
EOF
head -2 Cargo.lock
- name: Regenerate debian/changelog
run: |
set -eu
rm -f debian/changelog
dch --create --package rdmatop \
--newversion "${VERSION}-1ppa1~${SERIES}1" \
--distribution "$SERIES" \
"Release ${VERSION} for ${SERIES}."
head -n 5 debian/changelog
- name: Create upstream orig tarball
run: |
set -eu
# 3.0 (quilt) source format requires ../rdmatop_<upstream>.orig.tar.gz.
# We synthesise one from the current source tree (which already
# contains vendor/ and .cargo/ — Launchpad's builders need both for
# offline cargo builds). debian/ and VCS metadata are excluded.
PKG_DIR="rdmatop-${VERSION}"
mkdir -p "/tmp/${PKG_DIR}"
rsync -a \
--exclude='.git' \
--exclude='.github' \
--exclude='debian' \
--exclude='.cargo-home' \
--exclude='target' \
--exclude='out' \
./ "/tmp/${PKG_DIR}/"
tar -czf "../rdmatop_${VERSION}.orig.tar.gz" -C /tmp "${PKG_DIR}"
rm -rf "/tmp/${PKG_DIR}"
ls -la ../rdmatop_*.orig.tar.gz
- name: Build source package
run: |
set -eu
dpkg-buildpackage --build=source -sa -us -uc -ui
ls -la ../
- name: Sign source package
run: |
set -eu
debsign -k"$KEY_ID" \
"../rdmatop_${VERSION}-1ppa1~${SERIES}1_source.changes"
- name: Stage source artifacts
if: always()
run: |
set -eu
mkdir -p out
cp -v ../rdmatop_*.dsc out/ 2>/dev/null || true
cp -v ../rdmatop_*.tar.* out/ 2>/dev/null || true
cp -v ../rdmatop_*.changes out/ 2>/dev/null || true
cp -v ../rdmatop_*.buildinfo out/ 2>/dev/null || true
ls -la out/
- name: Upload to Launchpad PPA
run: |
set -eu
dput "$PPA" "out/rdmatop_${VERSION}-1ppa1~${SERIES}1_source.changes"
- name: Stash source artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: ppa-source-${{ matrix.series }}
path: out/
if-no-files-found: warn