Skip to content

Commit cc7791d

Browse files
authored
Add scripts for building RPMs and creating release draft (#277)
1 parent ad9368b commit cc7791d

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed

.github/workflows/Dockerfile

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
ARG RHEL_VERSION
2+
FROM rockylinux:${RHEL_VERSION}
3+
4+
ARG RHEL_VERSION
5+
ARG PG_VERSION
6+
ARG PG_RMAN_VERSION
7+
8+
ENV PATH /usr/pgsql-${PG_VERSION}/bin:$PATH
9+
ENV PGDATA /var/lib/pgsql/${PG_VERSION}/data
10+
11+
12+
################################################################################
13+
#
14+
# Prerequisite
15+
#
16+
################################################################################
17+
18+
# Install packages for build
19+
RUN dnf update -y
20+
RUN dnf install -y \
21+
clang gcc git krb5-devel libselinux-devel libzstd-devel lz4-devel make \
22+
openssl-devel pam-devel readline-devel rpmdevtools which zlib-devel
23+
24+
# Install PostgreSQL
25+
RUN if [ "${RHEL_VERSION}" = "8" ]; then \
26+
dnf install -y --enablerepo=powertools perl-IPC-Run; \
27+
else \
28+
dnf install -y --enablerepo=crb perl-IPC-Run; \
29+
fi
30+
RUN dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-${RHEL_VERSION}-x86_64/pgdg-redhat-repo-latest.noarch.rpm
31+
RUN dnf -qy module disable postgresql
32+
RUN dnf install -y postgresql${PG_VERSION}-server postgresql${PG_VERSION}-devel
33+
34+
35+
################################################################################
36+
#
37+
# Build RPMs
38+
#
39+
################################################################################
40+
41+
# Build by postgres user
42+
USER postgres
43+
WORKDIR /var/lib/pgsql/
44+
45+
# Deploy the files required for the build
46+
RUN rpmdev-setuptree
47+
RUN git clone -b REL_${PG_VERSION}_STABLE https://github.com/ossc-db/pg_rman.git
48+
RUN cp -a pg_rman/SPECS/pg_rman${PG_VERSION}.spec rpmbuild/SPECS
49+
RUN cd pg_rman && \
50+
git archive HEAD \
51+
--format=tar.gz \
52+
--prefix=pg_rman-${PG_RMAN_VERSION}-pg${PG_VERSION}/ \
53+
--output=../rpmbuild/SOURCES/pg_rman-${PG_RMAN_VERSION}-pg${PG_VERSION}.tar.gz
54+
55+
# Build RPMs
56+
RUN rpmbuild rpmbuild/SPECS/pg_rman${PG_VERSION}.spec \
57+
-bb --define="dist .pg${PG_VERSION}.rhel${RHEL_VERSION}"
58+
59+
60+
################################################################################
61+
#
62+
# Run regression tests
63+
#
64+
################################################################################
65+
66+
USER root
67+
RUN rpm -ivh /var/lib/pgsql/rpmbuild/RPMS/x86_64/*
68+
69+
USER postgres
70+
RUN initdb --no-locale -E UTF8 && \
71+
pg_ctl -w start
72+
RUN make -C pg_rman installcheck; exit 0
73+
RUN cat /var/lib/pgsql/pg_rman/regression.out

.github/workflows/release.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build RPMs and upload its to release draft
2+
3+
on:
4+
push:
5+
tags:
6+
- 'V*'
7+
8+
jobs:
9+
build_rpms:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
strategy:
14+
matrix:
15+
RHEL_VERSION: ["8", "9"]
16+
PG_VERSION: ["13", "14", "15", "16", "17"]
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
ref: REL_${{ matrix.PG_VERSION }}_STABLE
22+
23+
- name: Build PostgreSQL ${{ matrix.PG_VERSION }} RPMs for RHEL ${{ matrix.RHEL_VERSION }}
24+
run: |
25+
export PG_RMAN_VERSION=${GITHUB_REF_NAME#V}
26+
docker build .github/workflows/ -t pg_rman \
27+
--build-arg RHEL_VERSION=${{ matrix.RHEL_VERSION }} \
28+
--build-arg PG_VERSION=${{ matrix.PG_VERSION }} \
29+
--build-arg PG_RMAN_VERSION=${PG_RMAN_VERSION}
30+
container_id=$(docker create pg_rman)
31+
docker cp $container_id:/var/lib/pgsql/rpmbuild/RPMS/x86_64 ./RPMS
32+
33+
- name: Create release draft and upload the RPMs
34+
uses: softprops/action-gh-release@v2
35+
with:
36+
name: Release draft
37+
draft: true
38+
files: ./RPMS/*.rpm

0 commit comments

Comments
 (0)