Skip to content

Build PPG Packages

Build PPG Packages #82

Workflow file for this run

name: Build PPG Packages
on:
workflow_dispatch:
inputs:
packages:
description: Server-Dependent packages to build (comma separated)
required: true
default: "pg_cron,patroni,pg_gather,pg_repack,pgaudit,pgaudit_set_user,pgbackrest,pgpool2,pgvector,postgis,postgres-common,ppg-server,ppg-server-ha,wal2json,pg_tde,pg_oidc"
packaging-repo:
description: packaging repo to be used
default: percona/postgres-packaging
required: true
packaging-branch:
description: packaging branch (use pg major.minor version in the dev branch name.)
required: true
default: "18.4"
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_MAJOR: ${{ steps.set-pgMajor.outputs.pg_major }}
PKG_MATRIX: ${{ steps.set-pkg-matrix.outputs.pkg_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_MAJOR
id: set-pgMajor
run: |
pg_major=$(echo "${{ inputs.packaging-branch }}" | grep -oE '[0-9]+\.' | head -1 | tr -d '.')
echo "PG_MAJOR=$pg_major" >> "$GITHUB_ENV"
echo "pg_major=$pg_major" >> "$GITHUB_OUTPUT"
- name: Set Package Matrix
id: set-pkg-matrix
run: |
PKGS=$(echo "${{ inputs.packages }}" | tr -d ' ' | tr ',' '\n')
if [ "${{ env.PG_MAJOR }}" -lt 18 ]; then
PKGS=$(echo "$PKGS" | grep -v '^pg_oidc$')
fi
if [ "${{ env.PG_MAJOR }}" -lt 17 ]; then
PKGS=$(echo "$PKGS" | grep -v '^pg_tde$')
fi
PKG_MATRIX=$(echo "$PKGS" | jq -R -s -c 'split("\n")[:-1] | {pkgs: .}')
echo "pkg_matrix=$PKG_MATRIX" >> $GITHUB_OUTPUT
- name: Set source rpm/deb matrix
id: set-source-matrix
run: |
PKG='${{ steps.set-pkg-matrix.outputs.pkg_matrix }}'
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 pkgs "$(echo "$PKG" | jq '.pkgs')" \
--argjson platform "$PLATFORM" \
'{pkgs:$pkgs, platform:$platform}')
echo "source_matrix=$SOURCE_MATRIX" >> $GITHUB_OUTPUT
- name: Set rpm/deb build matrix
id: set-build-matrix
run: |
ARCH='["amd64","arm64"]'
PKG='${{ steps.set-pkg-matrix.outputs.pkg_matrix }}'
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 pkgs "$(echo "$PKG" | jq '.pkgs')" \
--argjson platform "$PLATFORM" \
--argjson arch "$ARCH" \
'{pkgs:$pkgs, platform:$platform, arch:$arch}')
echo "build_matrix=$BUILD_MATRIX" >> $GITHUB_OUTPUT
pull-build-files:
runs-on: ubuntu-latest
needs: [prepare-matrix]
steps:
- name: Checkout packaging repo
uses: actions/checkout@v5
with:
fetch-depth: 0
repository: ${{ inputs.packaging-repo }}
ref: ${{ inputs.packaging-branch }}
path: src
- name: Create build files directory
run: mkdir pkg
- name: Collect common files
run: |
cp src/common-functions.sh pkg/
cp src/install-deps.sh pkg/
cp src/versions.sh pkg/
for pkg in $(echo '${{ needs.prepare-matrix.outputs.PKG_MATRIX }}' | jq -r '.pkgs[]'); do
echo "Processing $pkg"
cp src/${pkg}/*builder.sh pkg/${pkg}-builder.sh
done
shell: bash
- name: Upload build files as artifact
uses: actions/upload-artifact@v5
with:
name: build-files
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.PKG_MATRIX) }}
steps:
- name: Get build-files from artifact
uses: actions/download-artifact@v5
with:
name: build-files
path: ./
- name: Update permissions of the build scripts
run: |
chmod 755 *.sh
shell: bash
- name: Build Sources
run: |
mkdir test
sudo -E bash ./${{ matrix.pkgs }}-builder.sh --builddir=$(pwd)/test --get_sources=1 --pg_major=${{ needs.prepare-matrix.outputs.PG_MAJOR }}
shell: bash
- name: Upload source tarballs as artifact
uses: actions/upload-artifact@v5
with:
name: ${{ matrix.pkgs }}-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
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: ${{ matrix.pkgs }}-source_tarball
path: test/source_tarball/
- name: Install dependencies
run: |
sudo bash ./${{ matrix.pkgs }}-builder.sh --builddir=$(pwd)/test --install_deps=1 --pg_major=${{ needs.prepare-matrix.outputs.PG_MAJOR }} --repo_component=${{ inputs.ppg-repo-type }}
shell: bash
- name: Build Source RPM/DEB
run: |
if [[ "${{ matrix.platform }}" == *"linux"* ]]; then
sudo bash ./${{ matrix.pkgs }}-builder.sh --builddir=$(pwd)/test --build_src_rpm=1 --pg_major=${{ needs.prepare-matrix.outputs.PG_MAJOR }} --repo_component=${{ inputs.ppg-repo-type }}
else
sudo bash ./${{ matrix.pkgs }}-builder.sh --builddir=$(pwd)/test --build_src_deb=1 --pg_major=${{ needs.prepare-matrix.outputs.PG_MAJOR }} --repo_component=${{ inputs.ppg-repo-type }}
fi
shell: bash
- name: Upload source rpm as artifact
if: ${{ contains(matrix.platform, 'linux') }}
uses: actions/upload-artifact@v5
with:
name: ${{ matrix.pkgs }}-srpm
path: srpm
- name: Upload source deb as artifact
if: ${{ !contains(matrix.platform, 'linux') }}
uses: actions/upload-artifact@v5
with:
name: ${{ matrix.pkgs }}-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 from artifact
uses: actions/download-artifact@v5
with:
name: build-files
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: ${{ matrix.pkgs }}-srpm
path: test/srpm/
- name: Get source deb from artifact
if: ${{ !contains(matrix.platform, 'linux') }}
uses: actions/download-artifact@v5
with:
name: ${{ matrix.pkgs }}-source_deb
path: test/source_deb/
- name: Install dependencies
run: |
sudo bash ./${{ matrix.pkgs }}-builder.sh --builddir=$(pwd)/test --install_deps=1 --pg_major=${{ needs.prepare-matrix.outputs.PG_MAJOR }} --repo_component=${{ inputs.ppg-repo-type }}
shell: bash
- name: Build RPM/DEB
continue-on-error: true
run: |
if [[ "${{ matrix.platform }}" == *"linux"* ]]; then
sudo bash ./${{ matrix.pkgs }}-builder.sh --builddir=$(pwd)/test --build_rpm=1 --pg_major=${{ needs.prepare-matrix.outputs.PG_MAJOR }} --repo_component=${{ inputs.ppg-repo-type }}
else
sudo bash ./${{ matrix.pkgs }}-builder.sh --builddir=$(pwd)/test --build_deb=1 --pg_major=${{ needs.prepare-matrix.outputs.PG_MAJOR }} --repo_component=${{ inputs.ppg-repo-type }}
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@v5
with:
name: ${{ matrix.pkgs }}-${{ env.PLATFORM_LABEL }}-${{ matrix.arch }}
path: rpm
- name: Upload debs as artifact
if: ${{ !contains(matrix.platform, 'linux') }}
uses: actions/upload-artifact@v5
with:
name: ${{ matrix.pkgs }}-${{ 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]
steps:
- name: Get all the artifacts
uses: actions/download-artifact@v5
with:
path: artifacts
- name: Remove build-files artifacts
run: rm -rf artifacts/build-files*
- name: Set upload path
run: |
BUILD_ID="${{ needs.prepare-matrix.outputs.BUILD_ID }}"
echo "BUILD_ID=$BUILD_ID" >> "$GITHUB_ENV"
PG_MAJOR="${{ needs.prepare-matrix.outputs.PG_MAJOR }}"
echo "PG_MAJOR=$PG_MAJOR" >> "$GITHUB_ENV"
echo "UPLOAD_PATH=PG$PG_MAJOR/${{ inputs.packaging-branch }}/$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: Copy all the artifacts to required location
run: |
cp -n artifacts/*-source_tarball/* "${{ env.UPLOAD_PATH }}/source_tarball/"
if [ "${{ inputs.distro }}" = "rpm" ] || [ "${{ inputs.distro }}" = "rpm-and-deb" ]; then
cp -n artifacts/*-srpm/* "${{ env.UPLOAD_PATH }}/srpm/"
cp -n artifacts/*-ol8-*/* "${{ env.UPLOAD_PATH }}/rpm/"
cp -n artifacts/*-ol9-*/* "${{ env.UPLOAD_PATH }}/rpm/"
cp -n artifacts/*-ol10-*/* "${{ env.UPLOAD_PATH }}/rpm/"
fi
if [ "${{ inputs.distro }}" = "deb" ] || [ "${{ inputs.distro }}" = "rpm-and-deb" ]; then
cp -n artifacts/*-source_deb/* "${{ env.UPLOAD_PATH }}/source_deb/"
cp -n artifacts/*-bookworm-*/* "${{ env.UPLOAD_PATH }}/deb/"
cp -n artifacts/*-bullseye-*/* "${{ env.UPLOAD_PATH }}/deb/"
cp -n artifacts/*-jammy-*/* "${{ env.UPLOAD_PATH }}/deb/"
cp -n artifacts/*-noble-*/* "${{ env.UPLOAD_PATH }}/deb/"
cp -n artifacts/*-trixie-*/* "${{ env.UPLOAD_PATH }}/deb/"
cp -n artifacts/*-resolute-*/* "${{ env.UPLOAD_PATH }}/deb/"
fi
- name: Archive final artifact
run: tar -czf PG${{ inputs.packaging-branch }}.tar.gz PG$PG_MAJOR
- name: Upload final artifact as release artifact
uses: softprops/action-gh-release@v2
with:
draft: true
tag_name: build_id-${{ github.run_number }}-PG${{ inputs.packaging-branch }}-${{ inputs.distro }}
name: build_id-${{ github.run_number }}-PG${{ inputs.packaging-branch }}-${{ inputs.distro }} (${{ inputs.packages }})
files: PG${{ inputs.packaging-branch }}.tar.gz
- name: enable tmate debugging
if: inputs.debugging && failure()
uses: mxschmitt/action-tmate@v3
timeout-minutes: 60