diff --git a/.github/workflows/publish-deb-package.yml b/.github/workflows/publish-deb-package.yml new file mode 100644 index 00000000..b46b37da --- /dev/null +++ b/.github/workflows/publish-deb-package.yml @@ -0,0 +1,48 @@ +name: pgcat package (deb) + +on: + workflow_dispatch: + inputs: + packageVersion: + default: "1.1.1" +jobs: + build: + strategy: + max-parallel: 1 + fail-fast: false # Let the other job finish, or they can lock each other out + matrix: + os: ["buildjet-4vcpu-ubuntu-2204", "buildjet-4vcpu-ubuntu-2204-arm"] + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - name: Install dependencies + env: + DEBIAN_FRONTEND: noninteractive + TZ: Etc/UTC + run: | + curl -sLO https://github.com/deb-s3/deb-s3/releases/download/0.11.4/deb-s3-0.11.4.gem + sudo gem install deb-s3-0.11.4.gem + dpkg-deb --version + - name: Build and release package + env: + AWS_ACCESS_KEY_ID: ${{ vars.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }} + run: | + if [[ $(arch) == "x86_64" ]]; then + export ARCH=amd64 + else + export ARCH=arm64 + fi + + bash utilities/deb.sh ${{ inputs.packageVersion }} + + deb-s3 upload \ + --lock \ + --bucket apt.postgresml.org \ + pgcat-${{ inputs.packageVersion }}-ubuntu22.04-${ARCH}.deb \ + --codename $(lsb_release -cs) diff --git a/control b/control new file mode 100644 index 00000000..f7e5b50e --- /dev/null +++ b/control @@ -0,0 +1,9 @@ +Package: pgcat +Version: ${PACKAGE_VERSION} +Section: database +Priority: optional +Architecture: ${ARCH} +Maintainer: PostgresML +Homepage: https://postgresml.org +Description: PgCat - NextGen PostgreSQL Pooler + PostgreSQL pooler and proxy (like PgBouncer) with support for sharding, load balancing, failover and mirroring. diff --git a/utilities/deb.sh b/utilities/deb.sh new file mode 100644 index 00000000..a194d803 --- /dev/null +++ b/utilities/deb.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Build an Ubuntu deb. +# +script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +deb_dir="/tmp/pgcat-build" +export PACKAGE_VERSION=${1:-"1.1.1"} +if [[ $(arch) == "x86_64" ]]; then + export ARCH=amd64 +else + export ARCH=arm64 +fi + +cd "$script_dir/.." +cargo build --release + +rm -rf "$deb_dir" +mkdir -p "$deb_dir/DEBIAN" +mkdir -p "$deb_dir/usr/bin" +mkdir -p "$deb_dir/etc" + +cp target/release/pgcat "$deb_dir/usr/bin/pgcat" +chmod +x "$deb_dir/usr/bin/pgcat" + +cp pgcat.toml "$deb_dir/etc/pgcat.toml" + +(cat control | envsubst) > "$deb_dir/DEBIAN/control" + +dpkg-deb \ + --root-owner-group \ + -z1 \ + --build "$deb_dir" \ + pgcat-${PACKAGE_VERSION}-ubuntu22.04-${ARCH}.deb