Skip to content

Commit ed5e9b0

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

File tree

6 files changed

+291
-4
lines changed

6 files changed

+291
-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: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
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+
publish-to-launchpad:
56+
name: Publish to Launchpad PPA
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 --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
102+
echo -e "5\ny\n" | gpg --command-fd 0 --expert --edit-key $GPG_KEY_ID trust
103+
104+
- name: Create vendor tarball
105+
run: |
106+
cargo vendor
107+
tar czf vendor.tar.gz vendor/
108+
109+
- name: Build source packages for each Ubuntu version
110+
env:
111+
VERSION: ${{ needs.verify-version.outputs.version }}
112+
run: |
113+
set -e
114+
115+
# Verify all required tools are installed
116+
echo "Verifying required tools..."
117+
for tool in dput debuild gpg tar; do
118+
if ! command -v $tool &> /dev/null; then
119+
echo "Error: Required tool '$tool' is not installed"
120+
exit 1
121+
fi
122+
echo " $tool: $(command -v $tool)"
123+
done
124+
echo "All required tools are available"
125+
126+
# Create output directory for all packages
127+
mkdir -p /tmp/packages
128+
129+
for DISTRO in $UBUNTU_VERSIONS; do
130+
echo "=========================================="
131+
echo "Building for Ubuntu $DISTRO"
132+
echo "=========================================="
133+
134+
# Create a clean working directory
135+
WORK_DIR=$(mktemp -d)
136+
cp -r . "$WORK_DIR/pg-doorman-${VERSION}"
137+
cd "$WORK_DIR/pg-doorman-${VERSION}"
138+
139+
# Remove .git directory to reduce size
140+
rm -rf .git
141+
142+
# Include vendor directory for offline build
143+
tar xzf vendor.tar.gz
144+
145+
# Generate changelog for this distribution
146+
cat > debian/changelog << EOF
147+
pg-doorman (${VERSION}~${DISTRO}) ${DISTRO}; urgency=medium
148+
149+
* Release version ${VERSION}
150+
* PostgreSQL connection pooler and proxy
151+
* Includes pg_doorman and patroni_proxy binaries
152+
153+
-- pg-doorman maintainers <pg-doorman@launchpad.net> $(date -R)
154+
EOF
155+
156+
# Create the source package
157+
cd "$WORK_DIR"
158+
tar czf "pg-doorman_${VERSION}~${DISTRO}.orig.tar.gz" "pg-doorman-${VERSION}"
159+
cd "pg-doorman-${VERSION}"
160+
161+
# Build source package (signed)
162+
debuild -S -sa -k${{ env.GPG_KEY_ID }}
163+
164+
# Copy built packages to output directory
165+
cp "$WORK_DIR"/pg-doorman_${VERSION}~${DISTRO}* /tmp/packages/
166+
167+
# Cleanup working directory
168+
cd /
169+
rm -rf "$WORK_DIR"
170+
171+
echo "Successfully built package for Ubuntu $DISTRO"
172+
done
173+
174+
echo "=========================================="
175+
echo "All packages built successfully"
176+
echo "=========================================="
177+
ls -la /tmp/packages/
178+
179+
- name: Upload source packages to Launchpad PPA
180+
if: github.event_name == 'release'
181+
env:
182+
VERSION: ${{ needs.verify-version.outputs.version }}
183+
run: |
184+
set -e
185+
186+
cd /tmp/packages
187+
188+
for DISTRO in $UBUNTU_VERSIONS; do
189+
echo "=========================================="
190+
echo "Uploading package for Ubuntu $DISTRO"
191+
echo "=========================================="
192+
193+
dput ${{ env.PPA_NAME }} "pg-doorman_${VERSION}~${DISTRO}_source.changes"
194+
195+
echo "Successfully uploaded package for Ubuntu $DISTRO"
196+
done
197+
198+
echo "=========================================="
199+
echo "All packages uploaded to Launchpad PPA"
200+
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/pg-doorman/pg_doorman
13+
Vcs-Git: https://github.com/pg-doorman/pg_doorman.git
14+
Vcs-Browser: https://github.com/pg-doorman/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

debian/copyright

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2+
Upstream-Name: pg-doorman
3+
Upstream-Contact: pg-doorman maintainers <pg-doorman@launchpad.net>
4+
Source: https://github.com/ozontech/pg_doorman
5+
6+
Files: *
7+
Copyright: 2024-2026 pg-doorman contributors
8+
License: MIT
9+
10+
License: MIT
11+
Permission is hereby granted, free of charge, to any person obtaining a copy
12+
of this software and associated documentation files (the "Software"), to deal
13+
in the Software without restriction, including without limitation the rights
14+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
copies of the Software, and to permit persons to whom the Software is
16+
furnished to do so, subject to the following conditions:
17+
.
18+
The above copyright notice and this permission notice shall be included in all
19+
copies or substantial portions of the Software.
20+
.
21+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27+
SOFTWARE.

debian/rules

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/make -f
2+
3+
export DH_VERBOSE = 1
4+
export JEMALLOC_SYS_WITH_MALLOC_CONF = dirty_decay_ms:30000,muzzy_decay_ms:30000,background_thread:true,metadata_thp:auto
5+
6+
%:
7+
dh $@
8+
9+
override_dh_auto_build:
10+
# Rust is installed by the build script, use vendored dependencies
11+
if [ -d vendor ]; then \
12+
mkdir -p .cargo && \
13+
echo '[source.crates-io]' > .cargo/config.toml && \
14+
echo 'replace-with = "vendored-sources"' >> .cargo/config.toml && \
15+
echo '[source.vendored-sources]' >> .cargo/config.toml && \
16+
echo 'directory = "vendor"' >> .cargo/config.toml; \
17+
fi
18+
cargo build --release
19+
20+
override_dh_auto_install:
21+
install -D -m 755 target/release/pg_doorman debian/pg-doorman/usr/bin/pg_doorman
22+
install -D -m 755 target/release/patroni_proxy debian/pg-doorman/usr/bin/patroni_proxy
23+
24+
override_dh_auto_test:
25+
# Skip tests during package build
26+
true
27+
28+
override_dh_shlibdeps:
29+
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
30+
31+
override_dh_strip:
32+
# Keep binaries as-is (already optimized with LTO)
33+
true

debian/source/format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0 (native)

0 commit comments

Comments
 (0)