Skip to content
14 changes: 3 additions & 11 deletions .github/workflows/ami-release-nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,7 @@ jobs:
- name: Generate common-nix.vars.pkr.hcl
run: |
PG_VERSION="$(nix run nixpkgs#yq -- -r '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)"
BRANCH_NAME="$(echo "${{ github.ref }}" | sed 's|refs/heads/||')"
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "$BRANCH_NAME" != "develop" && "$BRANCH_NAME" != release/* ]]; then
SUFFIX="${BRANCH_NAME//[^a-zA-Z0-9._-]/-}-${{ github.run_id }}"
PG_VERSION="${PG_VERSION}-${SUFFIX}"
echo "Added branch suffix to version: $SUFFIX"
fi
echo "postgres-version = \"$PG_VERSION\"" > common-nix.vars.pkr.hcl
# Ensure there's a newline at the end of the file
echo "" >> common-nix.vars.pkr.hcl

- name: Build AMI stage 1
env:
Expand All @@ -89,13 +81,13 @@ jobs:
GIT_SHA=${{github.sha}}
nix run github:supabase/postgres/${GIT_SHA}#packer -- init amazon-arm64-nix.pkr.hcl
# why is postgresql_major defined here instead of where the _three_ other postgresql_* variables are defined?
nix run github:supabase/postgres/${GIT_SHA}#packer -- build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${EXECUTION_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" -var "ansible_arguments=-e postgresql_major=${POSTGRES_MAJOR_VERSION}" amazon-arm64-nix.pkr.hcl
nix run github:supabase/postgres/${GIT_SHA}#packer -- build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${EXECUTION_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" -var "ansible_arguments=-e postgresql_major=${POSTGRES_MAJOR_VERSION}" -var "region=us-east-1" -var 'ami_regions=["us-east-1"]' amazon-arm64-nix.pkr.hcl

- name: Find stage 1 AMI
run: |
GIT_SHA=${{github.sha}}
PG_VERSION=$(sed -n 's/postgres-version = "\(.*\)"/\1/p' common-nix.vars.pkr.hcl)
REGION=$(grep '^region=' development-arm.vars.pkr.hcl | cut -d'=' -f2 | tr -d ' "')
REGION="us-east-1"

echo "Looking for stage 1 AMI with postgresVersion=${PG_VERSION}-stage1 and sourceSha=${GIT_SHA} in region ${REGION}"

Expand Down Expand Up @@ -124,7 +116,7 @@ jobs:
GIT_SHA=${{github.sha}}
nix run github:supabase/postgres/${GIT_SHA}#packer -- init stage2-nix-psql.pkr.hcl
POSTGRES_MAJOR_VERSION=${{ env.POSTGRES_MAJOR_VERSION }}
nix run github:supabase/postgres/${GIT_SHA}#packer -- build -var "git_sha=${GIT_SHA}" -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${EXECUTION_ID}" -var "postgres_major_version=${POSTGRES_MAJOR_VERSION}" -var "source_ami=${STAGE1_AMI_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" stage2-nix-psql.pkr.hcl
nix run github:supabase/postgres/${GIT_SHA}#packer -- build -var "git_sha=${GIT_SHA}" -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${EXECUTION_ID}" -var "postgres_major_version=${POSTGRES_MAJOR_VERSION}" -var "source_ami=${STAGE1_AMI_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" -var "region=us-east-1" stage2-nix-psql.pkr.hcl

- name: Grab release version
id: process_release_version
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/nix-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ permissions:
contents: write
packages: write

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
nix-eval:
uses: ./.github/workflows/nix-eval.yml
Expand Down
21 changes: 4 additions & 17 deletions .github/workflows/publish-nix-pgupgrade-bin-flake-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ jobs:
- name: Set PostgreSQL versions
id: set-versions
run: |
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
MAJOR_VERSION=$(echo "${{ inputs.postgresVersion }}" | cut -d'.' -f1)
VERSIONS="[\"$MAJOR_VERSION\"]"
else
VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[]' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c 'split("\n")[:-1]')
fi
VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[]' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c 'split("\n")[:-1]')
echo "postgres_versions=$VERSIONS" >> $GITHUB_OUTPUT

publish-staging:
Expand All @@ -48,11 +43,7 @@ jobs:
- name: Grab release version
id: process_release_version
run: |
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
VERSION="${{ inputs.postgresVersion }}"
else
VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
fi
VERSION=$(nix run nixpkgs#yq -- -r '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT"

Expand Down Expand Up @@ -87,7 +78,7 @@ jobs:

publish-prod:
runs-on: large-linux-x86
if: github.ref_name == 'develop' || contains( github.ref, 'release' )
if: github.ref_name == 'develop' || startsWith(github.ref_name, 'release/')
needs: prepare
strategy:
matrix:
Expand All @@ -100,11 +91,7 @@ jobs:
- name: Grab release version
id: process_release_version
run: |
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
VERSION="${{ inputs.postgresVersion }}"
else
VERSION=$(nix run nixpkgs#yq -- -r '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
fi
VERSION=$(nix run nixpkgs#yq -- -r '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT"

Expand Down
21 changes: 4 additions & 17 deletions .github/workflows/publish-nix-pgupgrade-scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ jobs:
- name: Set PostgreSQL versions
id: set-versions
run: |
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
MAJOR_VERSION=$(echo "${{ inputs.postgresVersion }}" | cut -d'.' -f1)
VERSIONS="[\"$MAJOR_VERSION\"]"
else
VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[]' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c 'split("\n")[:-1]')
fi
VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[]' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c 'split("\n")[:-1]')
echo "postgres_versions=$VERSIONS" >> $GITHUB_OUTPUT

publish-staging:
Expand All @@ -53,11 +48,7 @@ jobs:
- name: Grab release version
id: process_release_version
run: |
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
VERSION="${{ inputs.postgresVersion }}"
else
VERSION=$(nix run nixpkgs#yq -- -r '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
fi
VERSION=$(nix run nixpkgs#yq -- -r '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: Create a tarball containing pg_upgrade scripts
Expand Down Expand Up @@ -88,7 +79,7 @@ jobs:
publish-prod:
needs: prepare
runs-on: large-linux-x86
if: github.ref_name == 'develop' || contains( github.ref, 'release' )
if: github.ref_name == 'develop' || startsWith(github.ref_name, 'release/')

strategy:
matrix:
Expand All @@ -104,11 +95,7 @@ jobs:
- name: Grab release version
id: process_release_version
run: |
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
VERSION="${{ inputs.postgresVersion }}"
else
VERSION=$(nix run nixpkgs#yq -- -r '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
fi
VERSION=$(nix run nixpkgs#yq -- -r '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: Create a tarball containing pg_upgrade scripts
Expand Down
13 changes: 12 additions & 1 deletion ansible/tasks/setup-supabase-internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,20 @@
ansible.builtin.command:
cmd: aws configure set default.s3.use_dualstack_endpoint true

- name: download Vector package
ansible.builtin.get_url:
url: "{{ vector_x86_deb if platform == 'amd64' else vector_arm_deb }}"
dest: /tmp/vector.deb
timeout: 120
become: true
retries: 3
delay: 10
register: vector_download
until: vector_download is success

- name: install Vector for logging
apt:
deb: "{{ vector_x86_deb if platform == 'amd64' else vector_arm_deb }}"
deb: /tmp/vector.deb
become: true

- name: add Vector to postgres group
Expand Down
8 changes: 4 additions & 4 deletions ansible/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ postgres_major:

# Full version strings for each major version
postgres_release:
postgresorioledb-17: "17.6.0.037-orioledb"
postgres17: "17.6.1.080"
postgres15: "15.14.1.080"
postgresorioledb-17: "17.6.0.038-orioledb"
postgres17: "17.6.1.081"
postgres15: "15.14.1.081"

# Non Postgres Extensions
pgbouncer_release: 1.25.1
pgbouncer_release_checksum: sha256:6e566ae92fe3ef7f6a1b9e26d6049f7d7ca39c40e29e7b38f6d5500ae15d8465

# The checksum can be found under "Assets", in the GitHub release page for each version.
# The checksum can be found under "Assets", in the GitHub release page for each version.
# The binaries used are: ubuntu-aarch64 and linux-static.
# https://github.com/PostgREST/postgrest/releases
postgrest_release: 14.1
Expand Down
Loading