-
-
Notifications
You must be signed in to change notification settings - Fork 20
316 lines (277 loc) · 13.1 KB
/
publish-pg_analytics-rhel.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
# workflows/publish-pg_analytics-rhel.yml
#
# Publish pg_analytics (Red Hat)
# Build and publish the pg_analytics extension as .rpm to GitHub Releases.
name: Publish pg_analytics (Red Hat)
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-rhel-${{ 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.arch }}
runs-on: ${{ matrix.runner }}
container:
image: ${{ matrix.image }}
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
strategy:
matrix:
include:
# Red Hat Enterprise Linux 8
- name: Red Hat Enterprise Linux 8
runner: ubicloud-standard-8
image: redhat/ubi8:latest
pg_version: 14
arch: x86_64
- name: Red Hat Enterprise Linux 8
runner: ubicloud-standard-4-arm
image: redhat/ubi8:latest
pg_version: 14
arch: aarch64
- name: Red Hat Enterprise Linux 8
runner: ubicloud-standard-8
image: redhat/ubi8:latest
pg_version: 15
arch: x86_64
- name: Red Hat Enterprise Linux 8
runner: ubicloud-standard-4-arm
image: redhat/ubi8:latest
pg_version: 15
arch: aarch64
- name: Red Hat Enterprise Linux 8
runner: ubicloud-standard-8
image: redhat/ubi8:latest
pg_version: 16
arch: x86_64
- name: Red Hat Enterprise Linux 8
runner: ubicloud-standard-4-arm
image: redhat/ubi8:latest
pg_version: 16
arch: aarch64
- name: Red Hat Enterprise Linux 8
runner: ubicloud-standard-8
image: redhat/ubi8:latest
pg_version: 17
arch: x86_64
- name: Red Hat Enterprise Linux 8
runner: ubicloud-standard-4-arm
image: redhat/ubi8:latest
pg_version: 17
arch: aarch64
# Red Hat Enterprise Linux 9
- name: Red Hat Enterprise Linux 9
runner: ubicloud-standard-8
image: redhat/ubi9:latest
pg_version: 14
arch: x86_64
- name: Red Hat Enterprise Linux 9
runner: ubicloud-standard-4-arm
image: redhat/ubi9:latest
pg_version: 14
arch: aarch64
- name: Red Hat Enterprise Linux 9
runner: ubicloud-standard-8
image: redhat/ubi9:latest
pg_version: 15
arch: x86_64
- name: Red Hat Enterprise Linux 9
runner: ubicloud-standard-4-arm
image: redhat/ubi9:latest
pg_version: 15
arch: aarch64
- name: Red Hat Enterprise Linux 9
runner: ubicloud-standard-8
image: redhat/ubi9:latest
pg_version: 16
arch: x86_64
- name: Red Hat Enterprise Linux 9
runner: ubicloud-standard-4-arm
image: redhat/ubi9:latest
pg_version: 16
arch: aarch64
- name: Red Hat Enterprise Linux 9
runner: ubicloud-standard-8
image: redhat/ubi9:latest
pg_version: 17
arch: x86_64
- name: Red Hat Enterprise Linux 9
runner: ubicloud-standard-4-arm
image: redhat/ubi9:latest
pg_version: 17
arch: aarch64
steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
- name: Install Dependencies
run: |
# Extract RHEL version from the image name
RHEL_VERSION=$(echo "${{ matrix.image }}" | awk -F'ubi|:' '{print $2}')
# 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
# Used to upload the release to GitHub Releases
- name: Install GitHub CLI
run: |
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install -y gh
gh --version
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Retrieve OS & GitHub Tag Versions
id: version
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
echo "commit_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
OS_VERSION="el$(cat /etc/os-release | grep ^VERSION_ID= | cut -d= -f2 | tr -d '"' | cut -d. -f1)"
echo "OS Version: $OS_VERSION"
echo "os_version=$OS_VERSION" >> $GITHUB_OUTPUT
# Retrieve the current date for the changelog
CURRENT_DATE=$(LC_TIME=C date +"%a %b %d %Y")
echo "Current Date: $CURRENT_DATE"
echo "current_date=$CURRENT_DATE" >> $GITHUB_OUTPUT
- name: Install & Configure Supported PostgreSQL Version on RHEL
run: |
# Extract RHEL version from the image name
RHEL_VERSION=$(echo "${{ matrix.image }}" | awk -F'ubi|:' '{print $2}')
# Install the repository RPM:
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-${RHEL_VERSION}-${{ matrix.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 --locked cargo-pgrx --version ${{ steps.pgrx.outputs.version }} --debug
- name: Initialize pgrx for Current PostgreSQL Version
run: |
PG_CONFIG_PATH="/usr/pgsql-${{ matrix.pg_version }}/bin/pg_config"
cargo pgrx init --pg${{ matrix.pg_version }}=$PG_CONFIG_PATH
- name: Package pg_analytics Extension with pgrx
run: |
PG_CONFIG_PATH="/usr/pgsql-${{ matrix.pg_version }}/bin/pg_config"
cargo pgrx package --pg-config $PG_CONFIG_PATH
env:
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }}
COMMIT_SHA: ${{ steps.version.outputs.commit_sha }}
PARADEDB_VERSION: ${{ steps.version.outputs.tag_version }}
PARADEDB_TELEMETRY: true
- name: Create .rpm Package
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 data lake analytics from PostgreSQL
License: PostgreSQL License
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. It is built on top of DuckDB, the fast in-process analytical database
system, 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
* ${{ steps.version.outputs.current_date }} ParadeDB <[email protected]> - ${{ steps.version.outputs.tag_version }}
- Latest RPM Release
* Sat Jun 22 2024 ParadeDB <[email protected]> - 0.7.6
- 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@v2
with:
subject-path: |
~/rpmbuild/RPMS/${{ matrix.arch }}/pg_analytics_${{ matrix.pg_version }}-${{ steps.version.outputs.tag_version }}-1.${{ steps.version.outputs.os_version }}.${{ matrix.arch }}.rpm
- name: Retrieve GitHub Release Upload URL
id: upload_url
env:
GH_TOKEN: ${{ secrets.GHA_CREATE_RELEASE_PAT }}
run: |
RESPONSE=$(gh api \
-H "Authorization: token $GH_TOKEN" \
/repos/paradedb/pg_analytics/releases/tags/v${{ steps.version.outputs.tag_version }})
echo "REST API Response: $RESPONSE"
UPLOAD_URL=$(echo "$RESPONSE" | jq -r '.upload_url' | sed 's/{.*}//')
echo "GitHub Release Upload URL is: $UPLOAD_URL"
echo "upload_url=$UPLOAD_URL" >> $GITHUB_OUTPUT
- name: Upload pg_analytics .rpm to GitHub Release
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/${{ matrix.arch }}/pg_analytics_${{ matrix.pg_version }}-${{ steps.version.outputs.tag_version }}-1.${{ steps.version.outputs.os_version }}.${{ matrix.arch }}.rpm
asset_name: pg_analytics_${{ matrix.pg_version }}-${{ steps.version.outputs.tag_version }}-1PARADEDB.${{ steps.version.outputs.os_version }}.${{ matrix.arch }}.rpm
overwrite: true