Skip to content

Commit 3c208ac

Browse files
pcncsamrosedarora
authored
chore: consolidate release/15.6-lw12 into develop (#1142)
Co-authored-by: Paul Cioanca <[email protected]> Co-authored-by: Sam Rose <[email protected]> Co-authored-by: Div Arora <[email protected]> Co-authored-by: Div Arora <[email protected]> Co-authored-by: samrose <[email protected]>
1 parent 826897a commit 3c208ac

11 files changed

+216
-34
lines changed

.github/workflows/ami-release-nix.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- develop
7+
- release/*
78
paths:
89
- '.github/workflows/ami-release-nix.yml'
910
- 'common-nix.vars.pkr.hcl'
@@ -54,7 +55,7 @@ jobs:
5455
run: |
5556
packer init stage2-nix-psql.pkr.hcl
5657
GIT_SHA=${{github.sha}}
57-
packer build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" stage2-nix-psql.pkr.hcl
58+
packer build -var "git_sha=${GIT_SHA}" -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" stage2-nix-psql.pkr.hcl
5859
5960
- name: Grab release version
6061
id: process_release_version

.github/workflows/dockerhub-release-15-6.yml

+2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on:
44
push:
55
branches:
66
- develop
7+
- release/*
78
paths:
89
- ".github/workflows/dockerhub-release-15-6.yml"
910
- "common-nix.vars*"
11+
workflow_dispatch:
1012

1113
jobs:
1214
settings:

.github/workflows/nix-build.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ on:
44
push:
55
branches:
66
- develop
7+
- release/*
78
pull_request:
9+
workflow_dispatch:
810

911
permissions:
1012
contents: read
@@ -56,4 +58,4 @@ jobs:
5658
-e AWS_SESSION_TOKEN=${{ env.AWS_SESSION_TOKEN }} \
5759
base_nix bash -c "./workspace/docker/nix/build_nix.sh"
5860
name: build psql bundle on ${{ matrix.arch }}
59-
61+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Publish nix pg_upgrade_bin flake version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
postgresVersion:
7+
description: 'Optional. Postgres version to publish against, i.e. 15.1.1.78'
8+
required: false
9+
10+
permissions:
11+
id-token: write
12+
13+
jobs:
14+
publish-staging:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout Repo
19+
uses: actions/checkout@v3
20+
21+
- name: Grab release version
22+
id: process_release_version
23+
run: |
24+
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
25+
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
26+
VERSION=${{ inputs.postgresVersion }}
27+
fi
28+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
29+
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT"
30+
31+
- name: Create a tarball containing the latest nix flake version
32+
working-directory: /tmp/
33+
run: |
34+
mkdir -p ${{ steps.process_release_version.outputs.major_version }}
35+
echo $GITHUB_SHA > ${{ steps.process_release_version.outputs.major_version }}/nix_flake_version
36+
tar -czvf pg_upgrade_bin.tar.gz ${{ steps.process_release_version.outputs.major_version }}
37+
38+
- name: configure aws credentials - staging
39+
uses: aws-actions/configure-aws-credentials@v1
40+
with:
41+
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
42+
aws-region: "us-east-1"
43+
44+
- name: Upload pg_upgrade scripts to s3 staging
45+
run: |
46+
aws s3 cp /tmp/pg_upgrade_bin.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz
47+
48+
- name: Slack Notification on Failure
49+
if: ${{ failure() }}
50+
uses: rtCamp/action-slack-notify@v2
51+
env:
52+
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
53+
SLACK_USERNAME: 'gha-failures-notifier'
54+
SLACK_COLOR: 'danger'
55+
SLACK_MESSAGE: 'Publishing pg_upgrade binaries flake version failed'
56+
SLACK_FOOTER: ''
57+
58+
publish-prod:
59+
runs-on: ubuntu-latest
60+
if: github.ref_name == 'develop' || contains( github.ref, 'release' )
61+
62+
steps:
63+
- name: Checkout Repo
64+
uses: actions/checkout@v3
65+
66+
- name: Grab release version
67+
id: process_release_version
68+
run: |
69+
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
70+
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
71+
VERSION=${{ inputs.postgresVersion }}
72+
fi
73+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
74+
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT"
75+
76+
- name: Create a tarball containing the latest nix flake version
77+
working-directory: /tmp/
78+
run: |
79+
mkdir -p ${{ steps.process_release_version.outputs.major_version }}
80+
echo $GITHUB_SHA > ${{ steps.process_release_version.outputs.major_version }}/nix_flake_version
81+
tar -czvf pg_upgrade_bin.tar.gz ${{ steps.process_release_version.outputs.major_version }}
82+
83+
- name: configure aws credentials - prod
84+
uses: aws-actions/configure-aws-credentials@v1
85+
with:
86+
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
87+
aws-region: "us-east-1"
88+
89+
- name: Upload pg_upgrade scripts to s3 prod
90+
run: |
91+
aws s3 cp /tmp/pg_upgrade_bin.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz
92+
93+
- name: Slack Notification on Failure
94+
if: ${{ failure() }}
95+
uses: rtCamp/action-slack-notify@v2
96+
env:
97+
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
98+
SLACK_USERNAME: 'gha-failures-notifier'
99+
SLACK_COLOR: 'danger'
100+
SLACK_MESSAGE: 'Publishing pg_upgrade binaries flake version failed'
101+
SLACK_FOOTER: ''

.github/workflows/publish-nix-pgupgrade-scripts.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
push:
55
branches:
66
- develop
7-
- sam/nix-and-conventional-ami
7+
- release/*
88
paths:
9-
- '.github/workflows/publish-pgupgrade-scripts.yml'
9+
- '.github/workflows/publish-nix-pgupgrade-scripts.yml'
1010
- 'common-nix.vars.pkr.hcl'
1111
workflow_dispatch:
1212
inputs:
@@ -62,7 +62,7 @@ jobs:
6262

6363
publish-prod:
6464
runs-on: ubuntu-latest
65-
if: github.ref_name == 'develop'
65+
if: github.ref_name == 'develop' || contains( github.ref, 'release' )
6666

6767
steps:
6868
- name: Checkout Repo

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

+19-11
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ EOF
174174
function patch_wrappers {
175175
local IS_NIX_UPGRADE=$1
176176

177+
WRAPPERS_ENABLED=$(run_sql -A -t -c "SELECT EXISTS(SELECT 1 FROM pg_extension WHERE extname = 'wrappers');")
178+
if [ "$WRAPPERS_ENABLED" = "f" ]; then
179+
echo "Wrappers extension not enabled. Skipping."
180+
return
181+
fi
182+
177183
# This is a workaround for older versions of wrappers which don't have the expected
178184
# naming scheme, containing the version in their library's file name
179185
# e.g. wrappers-0.1.16.so, rather than wrappers.so
@@ -186,18 +192,20 @@ function patch_wrappers {
186192
# - new version: wrappers-0.1.18.so
187193
# - workaround to make pg_upgrade happy: copy wrappers-0.1.18.so to wrappers-0.1.16.so
188194
if [ "$IS_NIX_UPGRADE" = "true" ]; then
189-
OLD_WRAPPER_LIB_PATH=$(find "$PGLIBOLD" -name "wrappers*so" -print -quit)
190-
OLD_LIB_FILE_NAME=$(basename "$OLD_WRAPPER_LIB_PATH")
191-
192-
find /nix/store/ -name "wrappers*so" -print0 | while read -r -d $'\0' WRAPPERS_LIB_PATH; do
193-
if [ -f "$WRAPPERS_LIB_PATH" ]; then
194-
WRAPPERS_LIB_PATH_DIR=$(dirname "$WRAPPERS_LIB_PATH")
195-
if [ "$WRAPPERS_LIB_PATH" != "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}" ]; then
196-
echo "Copying $WRAPPERS_LIB_PATH to $WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
197-
cp "$WRAPPERS_LIB_PATH" "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
195+
if [ -d "$PGLIBOLD" ]; then
196+
OLD_WRAPPER_LIB_PATH=$(find "$PGLIBOLD" -name "wrappers*so" -print -quit)
197+
OLD_LIB_FILE_NAME=$(basename "$OLD_WRAPPER_LIB_PATH")
198+
199+
find /nix/store/ -name "wrappers*so" -print0 | while read -r -d $'\0' WRAPPERS_LIB_PATH; do
200+
if [ -f "$WRAPPERS_LIB_PATH" ]; then
201+
WRAPPERS_LIB_PATH_DIR=$(dirname "$WRAPPERS_LIB_PATH")
202+
if [ "$WRAPPERS_LIB_PATH" != "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}" ]; then
203+
echo "Copying $WRAPPERS_LIB_PATH to $WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
204+
cp "$WRAPPERS_LIB_PATH" "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
205+
fi
198206
fi
199-
fi
200-
done
207+
done
208+
fi
201209
else
202210
if [ -d "$PGLIBOLD" ]; then
203211
WRAPPERS_LIB_PATH=$(find "$PGLIBNEW" -name "wrappers*so" -print -quit)

ansible/tasks/setup-postgrest.yml

+25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
- name: PostgREST - system user
22
user: name=postgrest
33

4+
- name: PostgREST - add Postgres PPA gpg key
5+
apt_key:
6+
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
7+
state: present
8+
9+
- name: PostgREST - add Postgres PPA
10+
apt_repository:
11+
repo: "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg {{ postgresql_major }}"
12+
state: present
13+
14+
- name: PostgREST - update apt cache
15+
apt:
16+
update_cache: yes
17+
418
# libpq is a C library that enables user programs to communicate with
519
# the PostgreSQL database server.
620
- name: PostgREST - system dependencies
@@ -9,9 +23,20 @@
923
- libpq5
1024
- libnuma-dev
1125

26+
- name: PostgREST - remove Postgres PPA gpg key
27+
apt_key:
28+
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
29+
state: absent
30+
31+
- name: PostgREST - remove Postgres PPA
32+
apt_repository:
33+
repo: "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg {{ postgresql_major }}"
34+
state: absent
35+
1236
- name: postgis - ensure dependencies do not get autoremoved
1337
shell: |
1438
set -e
39+
apt-mark manual libpq5*
1540
apt-mark manual libnuma*
1641
apt-mark auto libnuma*-dev
1742

ansible/vars.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ postgres_exporter_release_checksum:
5050
arm64: sha256:29ba62d538b92d39952afe12ee2e1f4401250d678ff4b354ff2752f4321c87a0
5151
amd64: sha256:cb89fc5bf4485fb554e0d640d9684fae143a4b2d5fa443009bd29c59f9129e84
5252

53-
adminapi_release: 0.64.2
53+
adminapi_release: 0.66.2
5454
adminmgr_release: 0.22.1
5555

5656
# Postgres Extensions

common-nix.vars.pkr.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
postgres-version = "15.6.1.109"
1+
postgres-version = "15.6.1.115"

nix/ext/pg_jsonschema.nix

+29-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ buildPgrxExtension_0_11_3 rec {
1414

1515
nativeBuildInputs = [ cargo ];
1616
buildInputs = [ postgresql ];
17-
17+
# update the following array when the pg_jsonschema version is updated
18+
# required to ensure that extensions update scripts from previous versions are generated
19+
20+
previousVersions = ["0.3.0" "0.2.0" "0.1.4" "0.1.4" "0.1.2" "0.1.1" "0.1.0"];
1821
CARGO="${cargo}/bin/cargo";
1922
env = lib.optionalAttrs stdenv.isDarwin {
2023
POSTGRES_LIB = "${postgresql}/lib";
@@ -26,6 +29,31 @@ buildPgrxExtension_0_11_3 rec {
2629
# to fix this a bit later.
2730
doCheck = false;
2831

32+
preBuild = ''
33+
echo "Processing git tags..."
34+
echo '${builtins.concatStringsSep "," previousVersions}' | sed 's/,/\n/g' > git_tags.txt
35+
'';
36+
37+
postInstall = ''
38+
echo "Creating SQL files for previous versions..."
39+
current_version="${version}"
40+
sql_file="$out/share/postgresql/extension/pg_jsonschema--$current_version.sql"
41+
42+
if [ -f "$sql_file" ]; then
43+
while read -r previous_version; do
44+
if [ "$(printf '%s\n' "$previous_version" "$current_version" | sort -V | head -n1)" = "$previous_version" ] && [ "$previous_version" != "$current_version" ]; then
45+
new_file="$out/share/postgresql/extension/pg_jsonschema--$previous_version--$current_version.sql"
46+
echo "Creating $new_file"
47+
cp "$sql_file" "$new_file"
48+
fi
49+
done < git_tags.txt
50+
else
51+
echo "Warning: $sql_file not found"
52+
fi
53+
rm git_tags.txt
54+
'';
55+
56+
2957
meta = with lib; {
3058
description = "JSON Schema Validation for PostgreSQL";
3159
homepage = "https://github.com/supabase/${pname}";

0 commit comments

Comments
 (0)