-
-
Notifications
You must be signed in to change notification settings - Fork 19
479 lines (435 loc) · 21.1 KB
/
publish-pg_analytics.yml
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# workflows/publish-pg_analytics.yml
#
# Publish pg_analytics
# Build and publish the pg_analytics extension as .deb and .rpm to GitHub Releases.
name: Publish pg_analytics
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "The version to set for the pg_analytics release. This publishes the latest commit of the chosen branch and uploads it to the pre-existing GitHub Release of the provided version."
required: true
default: ""
concurrency:
group: publish-pg_analytics-${{ github.head_ref || github.ref }}
cancel-in-progress: true
# Used by actions/attest-build-provenance to sign the builds
permissions:
id-token: write
attestations: write
jobs:
publish-pg_analytics:
name: Publish pg_analytics for PostgreSQL ${{ matrix.pg_version }} on ${{ matrix.image }} ${{ matrix.arch }}
runs-on: ${{ matrix.runner }}
container:
image: ${{ matrix.image }}
strategy:
matrix:
include:
# Ubuntu 22.04
- runner: ubicloud-standard-8
image: ubuntu:22.04
pg_version: 14
arch: amd64
- runner: ubicloud-standard-4-arm
image: ubuntu:22.04
pg_version: 14
arch: arm64
- runner: ubicloud-standard-8
image: ubuntu:22.04
pg_version: 15
arch: amd64
- runner: ubicloud-standard-4-arm
image: ubuntu:22.04
pg_version: 15
arch: arm64
- runner: ubicloud-standard-8
image: ubuntu:22.04
pg_version: 16
arch: amd64
- runner: ubicloud-standard-4-arm
image: ubuntu:22.04
pg_version: 16
arch: arm64
- runner: ubicloud-standard-8
image: ubuntu:22.04
pg_version: 17
arch: amd64
- runner: ubicloud-standard-4-arm
image: ubuntu:22.04
pg_version: 17
arch: arm64
# Ubuntu 24.04
- runner: ubicloud-standard-8
image: ubuntu:24.04
pg_version: 14
arch: amd64
- runner: ubicloud-standard-4-arm
image: ubuntu:24.04
pg_version: 14
arch: arm64
- runner: ubicloud-standard-8
image: ubuntu:24.04
pg_version: 15
arch: amd64
- runner: ubicloud-standard-4-arm
image: ubuntu:24.04
pg_version: 15
arch: arm64
- runner: ubicloud-standard-8
image: ubuntu:24.04
pg_version: 16
arch: amd64
- runner: ubicloud-standard-4-arm
image: ubuntu:24.04
pg_version: 16
arch: arm64
- runner: ubicloud-standard-8
image: ubuntu:24.04
pg_version: 17
arch: amd64
- runner: ubicloud-standard-4-arm
image: ubuntu:24.04
pg_version: 17
arch: arm64
# Debian 12
- runner: ubicloud-standard-8
image: debian:12-slim
pg_version: 14
arch: amd64
- runner: ubicloud-standard-4-arm
image: debian:12-slim
pg_version: 14
arch: arm64
- runner: ubicloud-standard-8
image: debian:12-slim
pg_version: 15
arch: amd64
- runner: ubicloud-standard-4-arm
image: debian:12-slim
pg_version: 15
arch: arm64
- runner: ubicloud-standard-8
image: debian:12-slim
pg_version: 16
arch: amd64
- runner: ubicloud-standard-4-arm
image: debian:12-slim
pg_version: 16
arch: arm64
- runner: ubicloud-standard-8
image: debian:12-slim
pg_version: 17
arch: amd64
- runner: ubicloud-standard-4-arm
image: debian:12-slim
pg_version: 17
arch: arm64
# Red Hat Enterprise Linux 8
- runner: ubicloud-standard-8
image: redhat/ubi8:latest
pg_version: 14
arch: amd64
- runner: ubicloud-standard-4-arm
image: redhat/ubi8:latest
pg_version: 14
arch: arm64
- runner: ubicloud-standard-8
image: redhat/ubi8:latest
pg_version: 15
arch: amd64
- runner: ubicloud-standard-4-arm
image: redhat/ubi8:latest
pg_version: 15
arch: arm64
- runner: ubicloud-standard-8
image: redhat/ubi8:latest
pg_version: 16
arch: amd64
- runner: ubicloud-standard-4-arm
image: redhat/ubi8:latest
pg_version: 16
arch: arm64
- runner: ubicloud-standard-8
image: redhat/ubi8:latest
pg_version: 17
arch: amd64
- runner: ubicloud-standard-4-arm
image: redhat/ubi8:latest
pg_version: 17
arch: arm64
# Red Hat Enterprise Linux 9
- runner: ubicloud-standard-8
image: redhat/ubi9:latest
pg_version: 14
arch: amd64
- runner: ubicloud-standard-4-arm
image: redhat/ubi9:latest
pg_version: 14
arch: arm64
- runner: ubicloud-standard-8
image: redhat/ubi9:latest
pg_version: 15
arch: amd64
- runner: ubicloud-standard-4-arm
image: redhat/ubi9:latest
pg_version: 15
arch: arm64
- runner: ubicloud-standard-8
image: redhat/ubi9:latest
pg_version: 16
arch: amd64
- runner: ubicloud-standard-4-arm
image: redhat/ubi9:latest
pg_version: 16
arch: arm64
- runner: ubicloud-standard-8
image: redhat/ubi9:latest
pg_version: 17
arch: amd64
- runner: ubicloud-standard-4-arm
image: redhat/ubi9:latest
pg_version: 17
arch: arm64
steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
- name: Install Debian Dependencies
if: ${{ matrix.image == 'debian:11-slim' || matrix.image == 'debian:12-slim' || matrix.image == 'ubuntu:22.04' || matrix.image == 'ubuntu:24.04' }}
run: DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y sudo wget curl gnupg lsb-release pkg-config libssl-dev jq
- name: Install RHEL Dependencies
if: ${{ matrix.image == 'redhat/ubi8:latest' || matrix.image == 'redhat/ubi9:latest' }}
run: |
# Determine RHEL version to retrieve the correct repositories
if [ "${{ matrix.image }}" == "redhat/ubi8:latest" ]; then
RHEL_VERSION=8
elif [ "${{ matrix.image }}" == "redhat/ubi9:latest" ]; then
RHEL_VERSION=9
else
echo "Unsupported RHEL version"
exit 1
fi
# Install dependencies
dnf install -y sudo wget gcc llvm-toolset pkgconf-pkg-config openssl-devel jq rpm-build
# Add Oracle Linux ${RHEL_VERSION} repositories to enable epel-release
sudo tee /etc/yum.repos.d/oracle-linux-ol${RHEL_VERSION}.repo > /dev/null <<EOF
[ol${RHEL_VERSION}_baseos_latest]
name=Oracle Linux ${RHEL_VERSION} BaseOS Latest (\$basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL${RHEL_VERSION}/baseos/latest/\$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
[ol${RHEL_VERSION}_appstream]
name=Oracle Linux ${RHEL_VERSION} Application Stream (\$basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL${RHEL_VERSION}/appstream/\$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
[ol${RHEL_VERSION}_codeready_builder]
name=Oracle Linux ${RHEL_VERSION} CodeReady Builder (\$basearch) - Unsupported
baseurl=https://yum.oracle.com/repo/OracleLinux/OL${RHEL_VERSION}/codeready/builder/\$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
EOF
# Install epel-release, which is required by PostgreSQL via Perl-IPC-Run
wget https://yum.oracle.com/RPM-GPG-KEY-oracle-ol${RHEL_VERSION} -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
sudo dnf install -y epel-release
# This package requires epel-release, which is why we install it last. It is required to
# configure the build environment for creating the RPM package via rpmbuild
sudo dnf install -y rpmdevtools
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
# Note: We need to specify bash as the shell to ensure that it doesn't default to /bin/sh on Debian, which doesn't support the `[[` syntax
- name: Retrieve OS & GitHub Tag Versions
id: version
shell: bash
run: |
if [ -z "${{ github.event.inputs.version }}" ]; then
if [[ $GITHUB_REF == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
else
# If there is no tag and no provided version, it's a test run and we set a default version
VERSION="0.0.0"
fi
else
VERSION=${{ github.event.inputs.version }}
fi
echo "GitHub Tag Version: $VERSION"
echo "tag_version=$VERSION" >> $GITHUB_OUTPUT
if [ -x "$(command -v lsb_release)" ]; then
DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
RELEASE=$(lsb_release -cs)
else
DISTRO=$(cat /etc/os-release | grep ^ID= | cut -d= -f2 | tr -d '"')
RELEASE=$(cat /etc/os-release | grep ^VERSION_ID= | cut -d= -f2 | tr -d '"' | cut -d. -f1)
fi
if [ "$DISTRO" = "ubuntu" ]; then
OS_VERSION="$RELEASE"
elif [ "$DISTRO" = "debian" ]; then
OS_VERSION="$RELEASE"
elif [ "$DISTRO" = "rhel" ]; then
OS_VERSION="el$RELEASE"
else
OS_VERSION="$DISTRO-$RELEASE"
fi
echo "OS Version: $OS_VERSION"
echo "os_version=$OS_VERSION" >> $GITHUB_OUTPUT
# RHEL uses different architecture and OS naming conventions when packaging via rpmbuid. We need to
# retrieve those as well to programmatically retrieve and upload the correct RPM package
if [[ "${{ matrix.image }}" == "redhat/ubi8:latest" || "${{ matrix.image }}" == "redhat/ubi9:latest" ]]; then
if [ "${{ matrix.arch }}" == "amd64" ]; then
ARCH=x86_64
else
ARCH=aarch64
fi
echo "RPM Arch: $ARCH"
echo "rpm_arch=$ARCH" >> $GITHUB_OUTPUT
fi
- name: Install & Configure Supported PostgreSQL Version on Debian
if: ${{ matrix.image == 'debian:11-slim' || matrix.image == 'debian:12-slim' || matrix.image == 'ubuntu:22.04' || matrix.image == 'ubuntu:24.04' }}
run: |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo DEBIAN_FRONTEND=noninteractive apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql-${{ matrix.pg_version }} postgresql-server-dev-${{ matrix.pg_version }} debhelper devscripts dput gnupg
sudo chown -R $(whoami) /usr/share/postgresql/${{ matrix.pg_version }}/ /usr/lib/postgresql/${{ matrix.pg_version }}/ /var/lib/postgresql/${{ matrix.pg_version }}/
echo "/usr/lib/postgresql/${{ matrix.pg_version }}/bin" >> $GITHUB_PATH
- name: Install & Configure Supported PostgreSQL Version on RHEL
if: ${{ matrix.image == 'redhat/ubi8:latest' || matrix.image == 'redhat/ubi9:latest' }}
run: |
# Determine RHEL version to retrieve the correct repositories
if [ "${{ matrix.image }}" == "redhat/ubi8:latest" ]; then
RHEL_VERSION=8
elif [ "${{ matrix.image }}" == "redhat/ubi9:latest" ]; then
RHEL_VERSION=9
else
echo "Unsupported RHEL version"
exit 1
fi
# Install the repository RPM:
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-${RHEL_VERSION}-${{ steps.version.outputs.rpm_arch }}/pgdg-redhat-repo-latest.noarch.rpm
# Disable the built-in PostgreSQL module:
sudo dnf -qy module disable postgresql
# Install PostgreSQL:
sudo dnf install -y postgresql${{ matrix.pg_version }} postgresql${{ matrix.pg_version }}-server postgresql${{ matrix.pg_version }}-devel
- name: Extract pgrx Version
id: pgrx
run: echo version=$(cargo tree --depth 1 -i pgrx -p pg_analytics | head -n 1 | cut -f2 -dv) >> $GITHUB_OUTPUT
- name: Install pgrx
run: cargo install -j $(nproc) --locked cargo-pgrx --version ${{ steps.pgrx.outputs.version }} --debug
# Note: We need to specify bash as the shell to ensure that it doesn't default to /bin/sh on Debian, which doesn't support the `[[` syntax
- name: Initialize pgrx for Current PostgreSQL Version
shell: bash
run: |
if [[ "${{ matrix.image }}" == "redhat/ubi8:latest" || "${{ matrix.image }}" == "redhat/ubi9:latest" ]]; then
PG_CONFIG_PATH="/usr/pgsql-${{ matrix.pg_version }}/bin/pg_config"
else
PG_CONFIG_PATH="/usr/lib/postgresql/${{ matrix.pg_version }}/bin/pg_config"
fi
cargo pgrx init --pg${{ matrix.pg_version }}=$PG_CONFIG_PATH
- name: Package pg_analytics Extension with pgrx
run: |
if [[ "${{ matrix.image }}" == "redhat/ubi8:latest" || "${{ matrix.image }}" == "redhat/ubi9:latest" ]]; then
PG_CONFIG_PATH="/usr/pgsql-${{ matrix.pg_version }}/bin/pg_config"
else
PG_CONFIG_PATH="/usr/lib/postgresql/${{ matrix.pg_version }}/bin/pg_config"
fi
cargo pgrx package --pg-config $PG_CONFIG_PATH
- name: Create .deb Package
if: ${{ matrix.image == 'debian:11-slim' || matrix.image == 'debian:12-slim' || matrix.image == 'ubuntu:22.04' || matrix.image == 'ubuntu:24.04' }}
run: |
# Create installable package
mkdir archive
cp `find target/release -type f -name "pg_analytics*"` archive
package_dir=pg_analytics-${{ steps.version.outputs.tag_version }}-${{ steps.version.outputs.os_version }}-${{ matrix.arch }}-pg${{ matrix.pg_version }}
# Copy files into directory structure
mkdir -p ${package_dir}/usr/lib/postgresql/${{ matrix.pg_version }}/lib
mkdir -p ${package_dir}/usr/share/postgresql/${{ matrix.pg_version}}/extension
cp archive/*.so ${package_dir}/usr/lib/postgresql/${{ matrix.pg_version }}/lib
cp archive/*.control ${package_dir}/usr/share/postgresql/${{ matrix.pg_version }}/extension
cp archive/*.sql ${package_dir}/usr/share/postgresql/${{ matrix.pg_version }}/extension
# Create control file (package name cannot have underscore)
mkdir -p ${package_dir}/DEBIAN
touch ${package_dir}/DEBIAN/control
deb_version=${{ steps.version.outputs.tag_version }}
CONTROL_FILE="${package_dir}/DEBIAN/control"
echo 'Package: postgresql-${{ matrix.pg_version }}-pg-analytics' >> $CONTROL_FILE
echo 'Version:' ${deb_version} >> $CONTROL_FILE
echo 'Section: database' >> $CONTROL_FILE
echo 'Priority: optional' >> $CONTROL_FILE
echo 'Architecture: ${{ matrix.arch }}' >> $CONTROL_FILE
echo 'Depends: postgresql-${{ matrix.pg_version }}' >> $CONTROL_FILE
echo 'Maintainer: ParadeDB <[email protected]>' >> $CONTROL_FILE
echo 'Description: DuckDB-powered analytics for Postgres' >> $CONTROL_FILE
# Create .deb package
sudo chown -R root:root ${package_dir}
sudo chmod -R 755 ${package_dir}
sudo dpkg-deb -Zxz --build --root-owner-group ${package_dir}
- name: Create .rpm Package
if: ${{ matrix.image == 'redhat/ubi8:latest' || matrix.image == 'redhat/ubi9:latest' }}
run: |
echo "Configuring RPM build environment..."
rpmdev-setuptree
echo "Creating RPM SPEC file..."
spec_file=~/rpmbuild/SPECS/pg_analytics.spec
cat <<EOF > $spec_file
Name: pg_analytics_${{ matrix.pg_version }}
Version: ${{ steps.version.outputs.tag_version }}
Release: 1%{?dist}
Summary: DuckDB-powered analytics for Postgres
License: GNU Affero General Public License v3.0
URL: https://github.com/paradedb/pg_analytics
BuildRequires: postgresql${{ matrix.pg_version }}-devel
Requires: postgresql${{ matrix.pg_version }}-server
%description
pg_analytics is a Postgres extension that enables fast analytics over
data lakes from Postgres. It is built on top of DuckDB, using pgrx.
%install
%{__rm} -rf %{buildroot}
install -d %{buildroot}/usr/pgsql-${{ matrix.pg_version }}/lib/
install -d %{buildroot}/usr/pgsql-${{ matrix.pg_version }}/share/extension/
install -m 755 %{_sourcedir}/pg_analytics_${{ matrix.pg_version }}/usr/pgsql-${{ matrix.pg_version }}/lib/pg_analytics.so %{buildroot}/usr/pgsql-${{ matrix.pg_version }}/lib/
install -m 644 %{_sourcedir}/pg_analytics_${{ matrix.pg_version }}/usr/pgsql-${{ matrix.pg_version }}/share/extension/pg_analytics*.sql %{buildroot}/usr/pgsql-${{ matrix.pg_version }}/share/extension/
install -m 644 %{_sourcedir}/pg_analytics_${{ matrix.pg_version }}/usr/pgsql-${{ matrix.pg_version }}/share/extension/pg_analytics.control %{buildroot}/usr/pgsql-${{ matrix.pg_version }}/share/extension/
%files
/usr/pgsql-${{ matrix.pg_version }}/lib/pg_analytics.so
/usr/pgsql-${{ matrix.pg_version }}/share/extension/pg_analytics.control
/usr/pgsql-${{ matrix.pg_version }}/share/extension/pg_analytics*sql
%changelog
* Thu Jun 6 2024 ParadeDB <[email protected]> - ${{ steps.version.outputs.tag_version }}
- Initial RPM Release
EOF
echo "Copying pg_analytics binaries to RPM build directory..."
cp -r target/release/pg_analytics-pg${{ matrix.pg_version }}/ ~/rpmbuild/SOURCES/pg_analytics_${{ matrix.pg_version }}
echo "Building RPM package..."
rpmbuild --without debuginfo -ba ~/rpmbuild/SPECS/pg_analytics.spec
- name: Sign and Attest Build Provenance
uses: actions/attest-build-provenance@v1
with:
subject-path: |
./pg_analytics-${{ steps.version.outputs.tag_version }}-${{ steps.version.outputs.os_version }}-${{ matrix.arch }}-pg${{ matrix.pg_version }}.deb
~/rpmbuild/RPMS/${{ steps.version.outputs.rpm_arch }}/pg_analytics_${{ matrix.pg_version }}-${{ steps.version.outputs.tag_version }}-1.${{ steps.version.outputs.os_version }}.${{ steps.version.outputs.rpm_arch }}.rpm
- name: Retrieve GitHub Release Upload URL
id: upload_url
run: echo UPLOAD_URL=$(curl --silent https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ steps.version.outputs.tag_version }} | jq .upload_url --raw-output) >> $GITHUB_OUTPUT
- name: Upload pg_analytics .deb to GitHub Release
if: ${{ matrix.image == 'debian:11-slim' || matrix.image == 'debian:12-slim' || matrix.image == 'ubuntu:22.04' || matrix.image == 'ubuntu:24.04' }}
uses: shogo82148/actions-upload-release-asset@v1
with:
github_token: ${{ secrets.GHA_CREATE_RELEASE_PAT }}
upload_url: ${{ steps.upload_url.outputs.upload_url }}
asset_path: ./pg_analytics-${{ steps.version.outputs.tag_version }}-${{ steps.version.outputs.os_version }}-${{ matrix.arch }}-pg${{ matrix.pg_version }}.deb
asset_name: postgresql-${{ matrix.pg_version }}-pg-analytics_${{ steps.version.outputs.tag_version }}-1PARADEDB-${{ steps.version.outputs.os_version }}_${{ matrix.arch }}.deb
overwrite: true
- name: Upload pg_analytics .rpm to GitHub Release
if: ${{ matrix.image == 'redhat/ubi8:latest' || matrix.image == 'redhat/ubi9:latest' }}
uses: shogo82148/actions-upload-release-asset@v1
with:
github_token: ${{ secrets.GHA_CREATE_RELEASE_PAT }}
upload_url: ${{ steps.upload_url.outputs.upload_url }}
asset_path: ~/rpmbuild/RPMS/${{ steps.version.outputs.rpm_arch }}/pg_analytics_${{ matrix.pg_version }}-${{ steps.version.outputs.tag_version }}-1.${{ steps.version.outputs.os_version }}.${{ steps.version.outputs.rpm_arch }}.rpm
asset_name: pg_analytics_${{ matrix.pg_version }}-${{ steps.version.outputs.tag_version }}-1PARADEDB.${{ steps.version.outputs.os_version }}.${{ steps.version.outputs.rpm_arch }}.rpm
overwrite: true