Skip to content

Commit 2224f02

Browse files
cursoragentlovasoa
andcommitted
feat: Add DEB and RPM packaging for SQLPage
This commit introduces comprehensive packaging for SQLPage, including: - DEB and RPM package creation scripts. - CI/CD integration for automated building and testing. - Documentation for building, installing, and managing packages. - Support for Debian, Ubuntu, Fedora, and RHEL-based distributions. Co-authored-by: contact <[email protected]>
1 parent 361d42e commit 2224f02

23 files changed

+2755
-12
lines changed

.github/workflows/packages.yml

Lines changed: 330 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,330 @@
1+
name: Build and Test Packages
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
branches:
8+
- "main"
9+
- "release-test"
10+
pull_request:
11+
branches:
12+
- "main"
13+
paths:
14+
- "debian/**"
15+
- "rpm/**"
16+
- "scripts/build-*.sh"
17+
- ".github/workflows/packages.yml"
18+
workflow_dispatch:
19+
workflow_call:
20+
21+
permissions:
22+
contents: write
23+
actions: read
24+
25+
jobs:
26+
build-deb:
27+
name: Build Debian Package
28+
runs-on: ubuntu-22.04
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Install build dependencies
35+
run: |
36+
sudo apt-get update
37+
sudo apt-get install -y \
38+
debhelper \
39+
dh-make \
40+
devscripts \
41+
lintian \
42+
dpkg-dev \
43+
build-essential \
44+
unixodbc-dev \
45+
freetds-dev \
46+
libssl-dev \
47+
pkg-config
48+
49+
- name: Install Rust toolchain
50+
uses: dtolnay/rust-toolchain@stable
51+
with:
52+
targets: x86_64-unknown-linux-gnu
53+
54+
- name: Set up cargo cache
55+
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
56+
57+
- name: Build Debian package
58+
run: |
59+
# Update changelog with current version
60+
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
61+
sed -i "1s/.*/sqlpage ($VERSION-1) unstable; urgency=medium/" debian/changelog
62+
63+
# Build package
64+
dpkg-buildpackage -us -uc -b
65+
66+
- name: Run lintian checks
67+
run: |
68+
lintian --no-tag-display-limit ../*.deb || true
69+
70+
- name: List package contents
71+
run: |
72+
dpkg-deb --contents ../*.deb
73+
dpkg-deb --info ../*.deb
74+
75+
- name: Upload DEB package
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: debian-package
79+
path: ../*.deb
80+
if-no-files-found: error
81+
82+
- name: Upload DEB changes
83+
uses: actions/upload-artifact@v4
84+
with:
85+
name: debian-changes
86+
path: ../*.changes
87+
if-no-files-found: warn
88+
89+
build-rpm:
90+
name: Build RPM Package
91+
runs-on: ubuntu-latest
92+
container: fedora:latest
93+
steps:
94+
- uses: actions/checkout@v4
95+
with:
96+
fetch-depth: 0
97+
98+
- name: Install build dependencies
99+
run: |
100+
dnf install -y \
101+
rpm-build \
102+
rpmdevtools \
103+
rpmlint \
104+
rust \
105+
cargo \
106+
openssl-devel \
107+
systemd-rpm-macros \
108+
unixODBC-devel \
109+
freetds-devel \
110+
git
111+
112+
- name: Set up RPM build tree
113+
run: rpmdev-setuptree
114+
115+
- name: Update spec file version
116+
run: |
117+
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
118+
sed -i "s/^Version:.*/Version: ${VERSION}/" rpm/sqlpage.spec
119+
cp rpm/sqlpage.spec ~/rpmbuild/SPECS/
120+
121+
- name: Create source tarball
122+
run: |
123+
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
124+
git config --global --add safe.directory /__w/SQLPage/SQLPage
125+
git archive --format=tar.gz --prefix="SQLPage-${VERSION}/" \
126+
-o ~/rpmbuild/SOURCES/sqlpage-${VERSION}.tar.gz HEAD
127+
128+
- name: Build RPM package
129+
run: |
130+
rpmbuild -ba ~/rpmbuild/SPECS/sqlpage.spec
131+
132+
- name: Run rpmlint checks
133+
run: |
134+
rpmlint ~/rpmbuild/RPMS/*/sqlpage*.rpm || true
135+
rpmlint ~/rpmbuild/SRPMS/sqlpage*.rpm || true
136+
137+
- name: List package contents
138+
run: |
139+
rpm -qilp ~/rpmbuild/RPMS/*/sqlpage*.rpm
140+
141+
- name: Upload RPM package
142+
uses: actions/upload-artifact@v4
143+
with:
144+
name: rpm-package
145+
path: ~/rpmbuild/RPMS/*/sqlpage*.rpm
146+
if-no-files-found: error
147+
148+
- name: Upload SRPM package
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: srpm-package
152+
path: ~/rpmbuild/SRPMS/sqlpage*.rpm
153+
if-no-files-found: error
154+
155+
test-deb-debian:
156+
name: Test DEB on Debian ${{ matrix.version }}
157+
needs: build-deb
158+
runs-on: ubuntu-latest
159+
strategy:
160+
matrix:
161+
version: ["bookworm", "bullseye"]
162+
container: debian:${{ matrix.version }}
163+
steps:
164+
- name: Download DEB package
165+
uses: actions/download-artifact@v4
166+
with:
167+
name: debian-package
168+
169+
- name: Install package
170+
run: |
171+
apt-get update
172+
apt-get install -y ./sqlpage*.deb
173+
174+
- name: Verify installation
175+
run: |
176+
sqlpage --version
177+
which sqlpage
178+
dpkg -l | grep sqlpage
179+
test -f /usr/bin/sqlpage
180+
test -d /etc/sqlpage
181+
test -f /etc/sqlpage/sqlpage.json
182+
test -d /etc/sqlpage/templates
183+
test -f /lib/systemd/system/sqlpage.service
184+
185+
- name: Test service file
186+
run: |
187+
systemctl cat sqlpage.service || cat /lib/systemd/system/sqlpage.service
188+
189+
- name: Verify user creation
190+
run: |
191+
id sqlpage
192+
getent passwd sqlpage
193+
194+
test-deb-ubuntu:
195+
name: Test DEB on Ubuntu ${{ matrix.version }}
196+
needs: build-deb
197+
runs-on: ubuntu-latest
198+
strategy:
199+
matrix:
200+
version: ["24.04", "22.04", "20.04"]
201+
container: ubuntu:${{ matrix.version }}
202+
steps:
203+
- name: Download DEB package
204+
uses: actions/download-artifact@v4
205+
with:
206+
name: debian-package
207+
208+
- name: Install package
209+
run: |
210+
apt-get update
211+
apt-get install -y ./sqlpage*.deb
212+
213+
- name: Verify installation
214+
run: |
215+
sqlpage --version
216+
which sqlpage
217+
dpkg -l | grep sqlpage
218+
test -f /usr/bin/sqlpage
219+
test -d /etc/sqlpage
220+
test -f /etc/sqlpage/sqlpage.json
221+
222+
- name: Test service file
223+
run: |
224+
systemctl cat sqlpage.service || cat /lib/systemd/system/sqlpage.service
225+
226+
test-rpm-fedora:
227+
name: Test RPM on Fedora ${{ matrix.version }}
228+
needs: build-rpm
229+
runs-on: ubuntu-latest
230+
strategy:
231+
matrix:
232+
version: ["latest", "39", "40"]
233+
container: fedora:${{ matrix.version }}
234+
steps:
235+
- name: Download RPM package
236+
uses: actions/download-artifact@v4
237+
with:
238+
name: rpm-package
239+
240+
- name: Install package
241+
run: |
242+
dnf install -y ./sqlpage*.rpm
243+
244+
- name: Verify installation
245+
run: |
246+
sqlpage --version
247+
which sqlpage
248+
rpm -q sqlpage
249+
test -f /usr/bin/sqlpage
250+
test -d /etc/sqlpage
251+
test -f /etc/sqlpage/sqlpage.json
252+
test -d /etc/sqlpage/templates
253+
test -f /usr/lib/systemd/system/sqlpage.service
254+
255+
- name: Test service file
256+
run: |
257+
systemctl cat sqlpage.service || cat /usr/lib/systemd/system/sqlpage.service
258+
259+
- name: Verify user creation
260+
run: |
261+
id sqlpage
262+
getent passwd sqlpage
263+
264+
test-rpm-rhel:
265+
name: Test RPM on RHEL-based ${{ matrix.distro }}:${{ matrix.version }}
266+
needs: build-rpm
267+
runs-on: ubuntu-latest
268+
strategy:
269+
matrix:
270+
include:
271+
- distro: rockylinux
272+
version: "9"
273+
- distro: rockylinux
274+
version: "8"
275+
- distro: almalinux
276+
version: "9"
277+
- distro: almalinux
278+
version: "8"
279+
container: ${{ matrix.distro }}:${{ matrix.version }}
280+
steps:
281+
- name: Download RPM package
282+
uses: actions/download-artifact@v4
283+
with:
284+
name: rpm-package
285+
286+
- name: Install package
287+
run: |
288+
yum install -y ./sqlpage*.rpm
289+
290+
- name: Verify installation
291+
run: |
292+
sqlpage --version
293+
which sqlpage
294+
rpm -q sqlpage
295+
test -f /usr/bin/sqlpage
296+
test -d /etc/sqlpage
297+
298+
publish-packages:
299+
name: Publish Packages to GitHub Release
300+
needs: [test-deb-debian, test-deb-ubuntu, test-rpm-fedora, test-rpm-rhel]
301+
runs-on: ubuntu-latest
302+
if: startsWith(github.ref, 'refs/tags/')
303+
steps:
304+
- uses: actions/checkout@v4
305+
306+
- name: Download all artifacts
307+
uses: actions/download-artifact@v4
308+
309+
- name: Prepare release assets
310+
run: |
311+
mkdir -p release-assets
312+
cp debian-package/*.deb release-assets/
313+
cp rpm-package/*.rpm release-assets/
314+
cp srpm-package/*.rpm release-assets/
315+
ls -lh release-assets/
316+
317+
- name: Generate package checksums
318+
run: |
319+
cd release-assets
320+
sha256sum * > SHA256SUMS
321+
cat SHA256SUMS
322+
323+
- name: Upload to GitHub Release
324+
uses: softprops/action-gh-release@v2
325+
with:
326+
files: |
327+
release-assets/*.deb
328+
release-assets/*.rpm
329+
release-assets/SHA256SUMS
330+
fail_on_unmatched_files: true

.github/workflows/release.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,14 @@ jobs:
113113
name: sqlpage aws lambda serverless image
114114
path: sqlpage-aws-lambda.zip
115115

116+
build-packages:
117+
name: Build DEB and RPM packages
118+
uses: ./.github/workflows/packages.yml
119+
secrets: inherit
120+
116121
create_release:
117122
name: Create Github Release
118-
needs: [build-macos-windows, build-linux, build-aws]
123+
needs: [build-macos-windows, build-linux, build-aws, build-packages]
119124
runs-on: ubuntu-latest
120125
if: startsWith(github.ref, 'refs/tags/')
121126
steps:
@@ -143,6 +148,9 @@ jobs:
143148
sqlpage-linux.tgz
144149
sqlpage-macos.tgz
145150
sqlpage aws lambda serverless image/sqlpage-aws-lambda.zip
151+
debian-package/*.deb
152+
rpm-package/*.rpm
153+
srpm-package/*.rpm
146154
147155
cargo_publish:
148156
name: Publish to crates.io

.gitignore

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
1+
# Existing ignores (if any)
12
/target
2-
sqlpage.db
3-
.idea/
4-
*.mm_profdata
5-
docs/presentation-pgconf.html
6-
examples/inrap_badass/
7-
sqlpage/https/*
8-
x.sql
9-
xbed.sql
10-
**/sqlpage.bin
11-
node_modules/
12-
sqlpage/sqlpage.db
3+
Cargo.lock
4+
*.swp
5+
*.swo
6+
*~
7+
.DS_Store
8+
9+
# Debian packaging
10+
debian/.debhelper/
11+
debian/sqlpage/
12+
debian/cargo_home/
13+
debian/files
14+
debian/*.substvars
15+
debian/*.log
16+
debian/*.debhelper
17+
../*.deb
18+
../*.changes
19+
../*.buildinfo
20+
21+
# RPM packaging
22+
*.rpm
23+
*.src.rpm
24+
25+
# Build artifacts
26+
*.tar.gz
27+
*.zip
28+
sqlpage.bin

0 commit comments

Comments
 (0)