-
Notifications
You must be signed in to change notification settings - Fork 15
387 lines (331 loc) · 13 KB
/
Copy pathppg-postgres-packaging.yml
File metadata and controls
387 lines (331 loc) · 13 KB
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
name: Build PostgreSQL (14~18)
on:
workflow_dispatch:
inputs:
pg_versions:
description: PostgreSQL versions to build (comma separated)
required: true
default: "14.24,15.19,16.15,17.11,18.5"
packaging-repo:
description: packaging repo to be used
default: percona/postgres-packaging
required: true
distro:
description: RPM/Deb
required: true
default: both
type: choice
options:
- "rpm-and-deb"
- "rpm"
- "deb"
ppg-repo-type:
description: ppg repo type
required: true
default: experimental
type: choice
options:
- experimental
- testing
debugging:
description: tmate session required
default: false
type: boolean
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
prepare-matrix:
runs-on: ubuntu-latest
outputs:
BUILD_ID: ${{ steps.set-buildID.outputs.build_id }}
PG_MATRIX: ${{ steps.set-pg-matrix.outputs.pg_matrix }}
SOURCE_MATRIX: ${{ steps.set-source-matrix.outputs.source_matrix }}
BUILD_MATRIX: ${{ steps.set-build-matrix.outputs.build_matrix }}
steps:
- name: Set timestamp
run: echo "TIMESTAMP=$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_ENV
- name: Set Build ID
id: set-buildID
run: echo "build_id=${{ env.TIMESTAMP }}/${GITHUB_RUN_NUMBER}" >> "$GITHUB_OUTPUT"
- name: Set PG Matrix
id: set-pg-matrix
run: |
PG_MATRIX=$(echo "${{ inputs.pg_versions }}" | tr -d ' ' | jq -c -R 'split(",") | {pg_version: .}')
echo "pg_matrix=$PG_MATRIX" >> $GITHUB_OUTPUT
- name: Set source rpm/deb matrix
id: set-source-matrix
run: |
PG_VERSION=$(echo "${{ inputs.pg_versions }}" | tr -d ' ' | jq -c -R 'split(",")')
if [ "${{ inputs.distro }}" = "rpm" ]; then
PLATFORM='["oraclelinux:8"]'
elif [ "${{ inputs.distro }}" = "deb" ]; then
PLATFORM='["ubuntu:noble"]'
else
PLATFORM='["oraclelinux:8","ubuntu:noble"]'
fi
SOURCE_MATRIX=$(jq -c -n \
--argjson pg_version "$PG_VERSION" \
--argjson platform "$PLATFORM" \
'{pg_version:$pg_version, platform:$platform}')
echo "source_matrix=$SOURCE_MATRIX" >> $GITHUB_OUTPUT
- name: Set rpm/deb build matrix
id: set-build-matrix
run: |
ARCH='["amd64","arm64"]'
PG_VERSION=$(echo "${{ inputs.pg_versions }}" | tr -d ' ' | jq -c -R 'split(",")')
if [ "${{ inputs.distro }}" = "rpm" ]; then
PLATFORM='["oraclelinux:8","oraclelinux:9","oraclelinux:10"]'
elif [ "${{ inputs.distro }}" = "deb" ]; then
PLATFORM='["ubuntu:noble","ubuntu:jammy","ubuntu:resolute","debian:bookworm","debian:bullseye","debian:trixie"]'
else
PLATFORM='["oraclelinux:8","oraclelinux:9","oraclelinux:10","ubuntu:noble","ubuntu:jammy","ubuntu:resolute","debian:bookworm","debian:bullseye","debian:trixie"]'
fi
BUILD_MATRIX=$(jq -c -n \
--argjson pg_version "$PG_VERSION" \
--argjson platform "$PLATFORM" \
--argjson arch "$ARCH" \
'{pg_version:$pg_version, platform:$platform, arch:$arch}')
echo "build_matrix=$BUILD_MATRIX" >> $GITHUB_OUTPUT
pull-build-files:
runs-on: ubuntu-latest
needs: [prepare-matrix]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare-matrix.outputs.PG_MATRIX) }}
steps:
- name: Checkout packaging repo
uses: actions/checkout@v5
with:
fetch-depth: 0
repository: ${{ inputs.packaging-repo }}
ref: ${{ matrix.pg_version }}
path: src
- name: Create build files directory
run: mkdir pkg
- name: Collect PG packaging files
run: |
cp src/common-functions.sh pkg/
cp src/install-deps.sh pkg/
cp src/versions.sh pkg/
cp src/postgres/ppg_builder.sh pkg/
shell: bash
- name: Upload build files as artifact
uses: actions/upload-artifact@v4
with:
name: build-files-${{ matrix.pg_version }}
path: pkg/
build-source-tarball:
runs-on: ubuntu-latest
needs: [prepare-matrix, pull-build-files]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare-matrix.outputs.PG_MATRIX) }}
steps:
- name: Get build script artifact
uses: actions/download-artifact@v5
with:
name: build-files-${{ matrix.pg_version }}
path: ./
- name: Update permissions of the build scripts
run: |
chmod 755 *.sh
shell: bash
- name: Build Sources
run: |
mkdir test
sudo -E ./ppg_builder.sh --builddir=$(pwd)/test --get_sources=1 --repo_component=${{ inputs.ppg-repo-type }}
shell: bash
- name: Upload source tarballs as artifact
uses: actions/upload-artifact@v4
with:
name: PG${{ matrix.pg_version }}-source_tarball
path: source_tarball
build-srpm-sdeb:
runs-on: ubuntu-latest
needs: [prepare-matrix, pull-build-files, build-source-tarball]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare-matrix.outputs.SOURCE_MATRIX) }}
container:
image: ${{ matrix.platform }}
steps:
- name: Check OS
run: cat /etc/os-release
- name: Install build tools
run: |
if [[ "${{ matrix.platform }}" == *"linux"* ]]; then
yum install -y gcc make tar rpm-build rpmdevtools git sudo
else
apt-get update
apt-get install -y wget curl gcc tar git build-essential devscripts debhelper fakeroot lintian sudo
fi
echo "Ready to build!"
- name: Get build files from artifact
uses: actions/download-artifact@v5
with:
name: build-files-${{ matrix.pg_version }}
path: ./
- name: Update permissions of the build scripts
run: |
chmod 755 *.sh
shell: bash
- name: Get source tarball from artifact
uses: actions/download-artifact@v5
with:
name: PG${{ matrix.pg_version }}-source_tarball
path: test/source_tarball/
- name: Install dependencies
run: |
sudo ./ppg_builder.sh --builddir=$(pwd)/test --install_deps=1 --repo_component=${{ inputs.ppg-repo-type }}
shell: bash
- name: Build Source RPM/DEB
run: |
if [[ "${{ matrix.platform }}" == *"linux"* ]]; then
sudo ./ppg_builder.sh --builddir=$(pwd)/test --build_src_rpm=1 --repo_component=${{ inputs.ppg-repo-type }}
else
sudo ./ppg_builder.sh --builddir=$(pwd)/test --build_src_deb=1 --repo_component=${{ inputs.ppg-repo-type }}
fi
shell: bash
- name: Upload source rpm as artifact
if: ${{ contains(matrix.platform, 'linux') }}
uses: actions/upload-artifact@v4
with:
name: PG${{ matrix.pg_version }}-srpm
path: srpm
- name: Upload source deb as artifact
if: ${{ !contains(matrix.platform, 'linux') }}
uses: actions/upload-artifact@v4
with:
name: PG${{ matrix.pg_version }}-source_deb
path: source_deb
build-rpm-deb:
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
needs: [prepare-matrix, pull-build-files, build-source-tarball, build-srpm-sdeb]
strategy:
fail-fast: false
max-parallel: 16
matrix: ${{ fromJson(needs.prepare-matrix.outputs.BUILD_MATRIX) }}
container:
image: ${{ matrix.platform }}
steps:
- name: Check OS
run: cat /etc/os-release
- name: Install build tools
run: |
if [[ "${{ matrix.platform }}" == *"linux"* ]]; then
yum install -y gcc make tar rpm-build rpmdevtools git sudo
else
apt-get update
apt-get install -y wget curl gcc tar git build-essential devscripts debhelper fakeroot lintian sudo
fi
echo "Ready to build!"
- name: Get build files artifact
uses: actions/download-artifact@v5
with:
name: build-files-${{ matrix.pg_version }}
path: ./
- name: Update permissions of the build scripts
run: |
chmod 755 *.sh
shell: bash
- name: Get source rpm from artifact
if: ${{ contains(matrix.platform, 'linux') }}
uses: actions/download-artifact@v5
with:
name: PG${{ matrix.pg_version }}-srpm
path: test/srpm/
- name: Get source deb from artifact
if: ${{ !contains(matrix.platform, 'linux') }}
uses: actions/download-artifact@v5
with:
name: PG${{ matrix.pg_version }}-source_deb
path: test/source_deb/
- name: Install dependencies
run: |
set -xe
sudo ./ppg_builder.sh --builddir=$(pwd)/test --install_deps=1 --repo_component=${{ inputs.ppg-repo-type }}
shell: bash
- name: Build RPM/DEB
run: |
if [[ "${{ matrix.platform }}" == *"linux"* ]]; then
sudo ./ppg_builder.sh --builddir=$(pwd)/test --build_rpm=1
else
sudo ./ppg_builder.sh --builddir=$(pwd)/test --build_deb=1
fi
shell: bash
- name: Compute platform label
run: |
PLATFORM="${{ matrix.platform }}"
if [[ "$PLATFORM" == *linux* ]]; then
echo "PLATFORM_LABEL=ol${PLATFORM##*:}" >> "$GITHUB_ENV"
else
echo "PLATFORM_LABEL=${PLATFORM##*:}" >> "$GITHUB_ENV"
fi
shell: bash
- name: Upload rpms as artifact
if: ${{ contains(matrix.platform, 'linux') }}
uses: actions/upload-artifact@v4
with:
name: PG${{ matrix.pg_version }}-${{ env.PLATFORM_LABEL }}-${{ matrix.arch }}
path: rpm
- name: Upload debs as artifact
if: ${{ !contains(matrix.platform, 'linux') }}
uses: actions/upload-artifact@v4
with:
name: PG${{ matrix.pg_version }}-${{ env.PLATFORM_LABEL }}-${{ matrix.arch }}
path: deb
upload-draft-release:
runs-on: ubuntu-latest
needs: [prepare-matrix, pull-build-files, build-source-tarball, build-srpm-sdeb, build-rpm-deb]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare-matrix.outputs.PG_MATRIX) }}
steps:
- name: Get package full name and upload path
run: |
pkg_name="PG${{ matrix.pg_version }}"
echo "pkg_name=$pkg_name" >> "$GITHUB_ENV"
echo "UPLOAD_PATH="postgresql/$pkg_name/${{ needs.prepare-matrix.outputs.BUILD_ID }}"" >> "$GITHUB_ENV"
- name: Create final artifact structure
run: |
mkdir -p ${{ env.UPLOAD_PATH }}/source_tarball
mkdir -p ${{ env.UPLOAD_PATH }}/srpm
mkdir -p ${{ env.UPLOAD_PATH }}/source_deb
mkdir -p ${{ env.UPLOAD_PATH }}/rpm
mkdir -p ${{ env.UPLOAD_PATH }}/deb
- name: Get all the artifacts
uses: actions/download-artifact@v5
with:
pattern: PG${{ matrix.pg_version }}-*
path: artifacts
- name: Copy all the artifacts to required location
run: |
cp -n artifacts/PG*-source_tarball/* "${{ env.UPLOAD_PATH }}/source_tarball/"
if [ "${{ inputs.distro }}" = "rpm" ] || [ "${{ inputs.distro }}" = "rpm-and-deb" ]; then
cp -n artifacts/PG*-srpm/* "${{ env.UPLOAD_PATH }}/srpm/"
cp -n artifacts/PG*-ol8-*/* "${{ env.UPLOAD_PATH }}/rpm/"
cp -n artifacts/PG*-ol9-*/* "${{ env.UPLOAD_PATH }}/rpm/"
cp -n artifacts/PG*-ol10-*/* "${{ env.UPLOAD_PATH }}/rpm/"
fi
if [ "${{ inputs.distro }}" = "deb" ] || [ "${{ inputs.distro }}" = "rpm-and-deb" ]; then
cp -n artifacts/PG*-source_deb/* "${{ env.UPLOAD_PATH }}/source_deb/"
cp -n artifacts/PG*-bookworm-*/* "${{ env.UPLOAD_PATH }}/deb/"
cp -n artifacts/PG*-bullseye-*/* "${{ env.UPLOAD_PATH }}/deb/"
cp -n artifacts/PG*-jammy-*/* "${{ env.UPLOAD_PATH }}/deb/"
cp -n artifacts/PG*-noble-*/* "${{ env.UPLOAD_PATH }}/deb/"
cp -n artifacts/PG*-trixie-*/* "${{ env.UPLOAD_PATH }}/deb/"
cp -n artifacts/PG*-resolute-*/* "${{ env.UPLOAD_PATH }}/deb/"
fi
- name: Archive final artifact
run: tar -czf ${{ env.pkg_name }}.tar.gz postgresql
- name: Upload final artifact as release artifact
uses: softprops/action-gh-release@v2
with:
draft: true
tag_name: postgresql-${{ matrix.pg_version }}-${{ inputs.distro }} build_id-${{ github.run_number }}
name: postgresql-${{ matrix.pg_version }}-${{ inputs.distro }} build_id-${{ github.run_number }}
files: ${{ env.pkg_name }}.tar.gz
- name: enable tmate debugging
if: inputs.debugging && failure()
uses: mxschmitt/action-tmate@v3
timeout-minutes: 60