Skip to content

Commit a01d0b7

Browse files
author
dmitrivasilyev
committed
add launchpad publish rule
1 parent c45d671 commit a01d0b7

File tree

8 files changed

+453
-4
lines changed

8 files changed

+453
-4
lines changed

.github/workflows/build-packages.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ jobs:
7878
- name: Build binaries in release mode
7979
run: JEMALLOC_SYS_WITH_MALLOC_CONF="dirty_decay_ms:30000,muzzy_decay_ms:30000,background_thread:true,metadata_thp:auto" cargo build --release
8080
- name: Prepare output dir
81-
run: mkdir -p ./build_package/usr/bin && install ./target/release/pg_doorman ./build_package/usr/bin && mkdir -p ./out/
81+
run: mkdir -p ./build_package/usr/bin && install ./target/release/pg_doorman ./build_package/usr/bin && install ./target/release/patroni_proxy ./build_package/usr/bin && mkdir -p ./out/
8282
- name: Check versions
83-
run: ./build_package/usr/bin/pg_doorman --version && cat /etc/debian_version
83+
run: ./build_package/usr/bin/pg_doorman --version && ./build_package/usr/bin/patroni_proxy --version && cat /etc/debian_version
8484
- name: Fix package name
8585
run: |
8686
export PACKAGE_NAME=pg_doorman-${{ matrix.image }}.deb &&
@@ -122,9 +122,9 @@ jobs:
122122
- name: Build binaries in release mode
123123
run: JEMALLOC_SYS_WITH_MALLOC_CONF="dirty_decay_ms:30000,muzzy_decay_ms:30000,background_thread:true,metadata_thp:auto" cargo build --release
124124
- name: Prepare output dir
125-
run: mkdir -p ./build_package/usr/bin && install ./target/release/pg_doorman ./build_package/usr/bin && mkdir -p ./out/
125+
run: mkdir -p ./build_package/usr/bin && install ./target/release/pg_doorman ./build_package/usr/bin && install ./target/release/patroni_proxy ./build_package/usr/bin && mkdir -p ./out/
126126
- name: Check versions
127-
run: ./build_package/usr/bin/pg_doorman --version && cat /etc/system-release
127+
run: ./build_package/usr/bin/pg_doorman --version && ./build_package/usr/bin/patroni_proxy --version && cat /etc/system-release
128128
- name: Fix package name
129129
run: |
130130
export PACKAGE_NAME=pg_doorman-${{ matrix.image }}.rpm &&
Lines changed: 325 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,325 @@
1+
name: Publish to Launchpad PPA
2+
3+
on:
4+
pull_request:
5+
release:
6+
types: [published]
7+
8+
permissions:
9+
contents: read
10+
11+
env:
12+
# Last 4 Ubuntu LTS/stable versions
13+
UBUNTU_VERSIONS: "jammy noble oracular plucky"
14+
# jammy = 22.04 LTS
15+
# noble = 24.04 LTS
16+
# oracular = 24.10
17+
# plucky = 25.04
18+
PPA_NAME: "ppa:pg-doorman/pg-doorman"
19+
RUST_VERSION: "1.87.0"
20+
21+
jobs:
22+
verify-version:
23+
name: Verify tag version matches Cargo.toml
24+
runs-on: ubuntu-latest
25+
outputs:
26+
version: ${{ steps.get_version.outputs.version }}
27+
steps:
28+
- name: Checkout Repository
29+
uses: actions/checkout@v4
30+
31+
- name: Get and verify version
32+
id: get_version
33+
run: |
34+
# Extract version from Cargo.toml
35+
CARGO_VERSION=$(grep '^version =' Cargo.toml | head -1 | cut -d '"' -f2)
36+
echo "Cargo.toml version: $CARGO_VERSION"
37+
38+
# For release events, verify tag matches Cargo.toml version
39+
if [ "${{ github.event_name }}" = "release" ]; then
40+
# Extract version from git tag (remove 'v' prefix)
41+
TAG_VERSION=${GITHUB_REF_NAME#v}
42+
echo "Git tag version: $TAG_VERSION"
43+
44+
# Compare versions
45+
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
46+
echo "Error: Version mismatch between Cargo.toml ($CARGO_VERSION) and git tag ($TAG_VERSION)"
47+
exit 1
48+
fi
49+
else
50+
echo "Pull request build - skipping tag verification"
51+
fi
52+
53+
echo "version=$CARGO_VERSION" >> $GITHUB_OUTPUT
54+
55+
prepare-source-packages:
56+
name: Prepare source packages for Launchpad
57+
needs: [verify-version]
58+
runs-on: ubuntu-latest
59+
container:
60+
image: ubuntu:24.04
61+
env:
62+
DEBIAN_FRONTEND: noninteractive
63+
64+
steps:
65+
- name: Checkout Repository
66+
uses: actions/checkout@v4
67+
with:
68+
fetch-depth: 0
69+
70+
- name: Install build dependencies
71+
run: |
72+
apt-get update
73+
apt-get install -y \
74+
git \
75+
devscripts \
76+
debhelper \
77+
dput \
78+
gnupg \
79+
wget \
80+
build-essential \
81+
pkg-config \
82+
libssl-dev \
83+
cmake \
84+
clang \
85+
g++ \
86+
ca-certificates
87+
88+
- name: Install Rust
89+
run: |
90+
wget -q https://static.rust-lang.org/dist/rust-${{ env.RUST_VERSION }}-x86_64-unknown-linux-gnu.tar.gz -O /tmp/rust.tar.gz
91+
cd /tmp && tar xf rust.tar.gz && ./rust-*-x86_64-unknown-linux-gnu/install.sh
92+
93+
- name: Import GPG key
94+
env:
95+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
96+
run: |
97+
echo "$GPG_PRIVATE_KEY" | gpg --batch --no-tty --import
98+
# Get the key ID
99+
GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep sec | head -1 | awk '{print $2}' | cut -d'/' -f2)
100+
echo "GPG_KEY_ID=$GPG_KEY_ID" >> $GITHUB_ENV
101+
# Trust the key automatically without TTY
102+
echo -e "5\ny\n" | gpg --batch --no-tty --command-fd 0 --expert --edit-key $GPG_KEY_ID trust
103+
# Configure GPG for non-interactive use (fix "Inappropriate ioctl for device" error)
104+
mkdir -p ~/.gnupg
105+
echo "use-agent" >> ~/.gnupg/gpg.conf
106+
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
107+
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
108+
echo "RELOADAGENT" | gpg-connect-agent || true
109+
110+
- name: Create vendor tarball
111+
run: |
112+
cargo vendor
113+
tar czf vendor.tar.gz vendor/
114+
115+
- name: Build source packages for each Ubuntu version
116+
env:
117+
VERSION: ${{ needs.verify-version.outputs.version }}
118+
run: |
119+
set -e
120+
121+
# Verify all required tools are installed
122+
echo "Verifying required tools..."
123+
for tool in dput debuild gpg tar; do
124+
if ! which $tool > /dev/null 2>&1; then
125+
echo "Error: Required tool '$tool' is not installed"
126+
exit 1
127+
fi
128+
echo " $tool: $(which $tool)"
129+
done
130+
echo "All required tools are available"
131+
132+
# Create output directory for all packages
133+
mkdir -p /tmp/packages
134+
135+
for DISTRO in $UBUNTU_VERSIONS; do
136+
echo "=========================================="
137+
echo "Building for Ubuntu $DISTRO"
138+
echo "=========================================="
139+
140+
# Create a clean working directory
141+
WORK_DIR=$(mktemp -d)
142+
cp -r . "$WORK_DIR/pg-doorman-${VERSION}"
143+
cd "$WORK_DIR/pg-doorman-${VERSION}"
144+
145+
# Remove .git directory to reduce size
146+
rm -rf .git
147+
148+
# Include vendor directory for offline build
149+
tar xzf vendor.tar.gz
150+
151+
# Generate changelog for this distribution
152+
cat > debian/changelog << EOF
153+
pg-doorman (${VERSION}~${DISTRO}) ${DISTRO}; urgency=medium
154+
155+
* Release version ${VERSION}
156+
* PostgreSQL connection pooler and proxy
157+
* Includes pg_doorman and patroni_proxy binaries
158+
159+
-- pg-doorman maintainers <pg-doorman@launchpad.net> $(date -R)
160+
EOF
161+
162+
# Create the source package
163+
cd "$WORK_DIR"
164+
tar czf "pg-doorman_${VERSION}~${DISTRO}.orig.tar.gz" "pg-doorman-${VERSION}"
165+
cd "pg-doorman-${VERSION}"
166+
167+
# Build source package (signed)
168+
debuild -S -sa -k${{ env.GPG_KEY_ID }}
169+
170+
# Copy built packages to output directory
171+
cp "$WORK_DIR"/pg-doorman_${VERSION}~${DISTRO}* /tmp/packages/
172+
173+
# Cleanup working directory
174+
cd /
175+
rm -rf "$WORK_DIR"
176+
177+
echo "Successfully built package for Ubuntu $DISTRO"
178+
done
179+
180+
echo "=========================================="
181+
echo "All packages built successfully"
182+
echo "=========================================="
183+
ls -la /tmp/packages/
184+
185+
- name: Upload source packages artifact
186+
uses: actions/upload-artifact@v4
187+
with:
188+
name: launchpad-source-packages
189+
path: /tmp/packages/
190+
191+
test-package-installation:
192+
name: Test package installation (${{ matrix.distro }})
193+
needs: [verify-version, prepare-source-packages]
194+
runs-on: ubuntu-latest
195+
strategy:
196+
matrix:
197+
include:
198+
- distro: jammy
199+
image: ubuntu:22.04
200+
- distro: noble
201+
image: ubuntu:24.04
202+
- distro: oracular
203+
image: ubuntu:24.10
204+
- distro: plucky
205+
image: ubuntu:25.04
206+
container:
207+
image: ${{ matrix.image }}
208+
env:
209+
DEBIAN_FRONTEND: noninteractive
210+
211+
steps:
212+
- name: Download source packages
213+
uses: actions/download-artifact@v4
214+
with:
215+
name: launchpad-source-packages
216+
path: /tmp/packages
217+
218+
- name: Install build dependencies
219+
run: |
220+
apt-get update
221+
apt-get install -y \
222+
build-essential \
223+
devscripts \
224+
debhelper \
225+
pkg-config \
226+
libssl-dev \
227+
cmake \
228+
clang \
229+
g++ \
230+
wget \
231+
ca-certificates
232+
233+
- name: Install Rust
234+
run: |
235+
wget -q https://static.rust-lang.org/dist/rust-${{ env.RUST_VERSION }}-x86_64-unknown-linux-gnu.tar.gz -O /tmp/rust.tar.gz
236+
cd /tmp && tar xf rust.tar.gz && ./rust-*-x86_64-unknown-linux-gnu/install.sh
237+
238+
- name: Build and install package
239+
env:
240+
VERSION: ${{ needs.verify-version.outputs.version }}
241+
DISTRO: ${{ matrix.distro }}
242+
run: |
243+
set -e
244+
cd /tmp/packages
245+
246+
echo "=========================================="
247+
echo "Building binary package for Ubuntu $DISTRO"
248+
echo "=========================================="
249+
250+
# Extract source package
251+
dpkg-source -x pg-doorman_${VERSION}~${DISTRO}.dsc
252+
cd pg-doorman-${VERSION}~${DISTRO}
253+
254+
# Build binary package
255+
dpkg-buildpackage -us -uc -b
256+
257+
# Install the package
258+
cd ..
259+
dpkg -i pg-doorman_${VERSION}~${DISTRO}_*.deb || apt-get install -f -y
260+
261+
echo "=========================================="
262+
echo "Verifying installation"
263+
echo "=========================================="
264+
265+
# Verify binaries are installed and working
266+
which pg_doorman
267+
which patroni_proxy
268+
pg_doorman --version
269+
patroni_proxy --version
270+
271+
echo "=========================================="
272+
echo "Package installation test passed for Ubuntu $DISTRO"
273+
echo "=========================================="
274+
275+
upload-to-launchpad:
276+
name: Upload to Launchpad PPA
277+
needs: [verify-version, prepare-source-packages]
278+
if: github.event_name == 'release'
279+
runs-on: ubuntu-latest
280+
container:
281+
image: ubuntu:24.04
282+
env:
283+
DEBIAN_FRONTEND: noninteractive
284+
steps:
285+
- name: Download source packages
286+
uses: actions/download-artifact@v4
287+
with:
288+
name: launchpad-source-packages
289+
path: /tmp/packages
290+
291+
- name: Install dput
292+
run: |
293+
apt-get update
294+
apt-get install -y dput gnupg
295+
296+
- name: Import GPG key
297+
env:
298+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
299+
run: |
300+
echo "$GPG_PRIVATE_KEY" | gpg --batch --no-tty --import
301+
GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep sec | head -1 | awk '{print $2}' | cut -d'/' -f2)
302+
echo "GPG_KEY_ID=$GPG_KEY_ID" >> $GITHUB_ENV
303+
304+
- name: Upload source packages to Launchpad PPA
305+
if: github.event_name == 'release'
306+
env:
307+
VERSION: ${{ needs.verify-version.outputs.version }}
308+
run: |
309+
set -e
310+
311+
cd /tmp/packages
312+
313+
for DISTRO in $UBUNTU_VERSIONS; do
314+
echo "=========================================="
315+
echo "Uploading package for Ubuntu $DISTRO"
316+
echo "=========================================="
317+
318+
dput ${{ env.PPA_NAME }} "pg-doorman_${VERSION}~${DISTRO}_source.changes"
319+
320+
echo "Successfully uploaded package for Ubuntu $DISTRO"
321+
done
322+
323+
echo "=========================================="
324+
echo "All packages uploaded to Launchpad PPA"
325+
echo "=========================================="

debian/control

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Source: pg-doorman
2+
Section: database
3+
Priority: optional
4+
Maintainer: pg-doorman maintainers <pg-doorman@launchpad.net>
5+
Build-Depends: debhelper-compat (= 13),
6+
libssl-dev,
7+
pkg-config,
8+
cmake,
9+
clang,
10+
g++
11+
Standards-Version: 4.6.0
12+
Homepage: https://github.com/ozontech/pg_doorman
13+
Vcs-Git: https://github.com/ozontech/pg_doorman.git
14+
Vcs-Browser: https://github.com/ozontech/pg_doorman
15+
16+
Package: pg-doorman
17+
Architecture: amd64
18+
Depends: ${shlibs:Depends}, ${misc:Depends}, openssl
19+
Description: PostgreSQL connection pooler and proxy
20+
pg_doorman is a high-performance PostgreSQL connection pooler and proxy
21+
written in Rust. It provides efficient connection pooling, load balancing,
22+
and query routing capabilities for PostgreSQL databases.
23+
.
24+
This package includes:
25+
- pg_doorman: main PostgreSQL connection pooler and proxy
26+
- patroni_proxy: Patroni integration proxy for high availability setups

0 commit comments

Comments
 (0)