Skip to content

Commit eb79e32

Browse files
authored
Merge branch 'develop' into bo/chore/wrappers-0.5.1
2 parents d916dd4 + 7dc3610 commit eb79e32

File tree

7 files changed

+154
-110
lines changed

7 files changed

+154
-110
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Release Single AMI Nix
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
postgres_version:
7+
description: 'PostgreSQL major version to build (e.g. 15)'
8+
required: true
9+
type: string
10+
branch:
11+
description: 'Branch to run the workflow from'
12+
required: true
13+
type: string
14+
default: 'main'
15+
16+
permissions:
17+
contents: write
18+
id-token: write
19+
20+
jobs:
21+
build:
22+
runs-on: arm-runner
23+
timeout-minutes: 150
24+
25+
steps:
26+
- name: Checkout Repo
27+
uses: actions/checkout@v3
28+
with:
29+
ref: ${{ github.event.inputs.branch }}
30+
31+
- name: Get current branch SHA
32+
id: get_sha
33+
run: |
34+
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
35+
36+
- uses: DeterminateSystems/nix-installer-action@main
37+
38+
- name: Set PostgreSQL version environment variable
39+
run: echo "POSTGRES_MAJOR_VERSION=${{ github.event.inputs.postgres_version }}" >> $GITHUB_ENV
40+
41+
- name: Generate common-nix.vars.pkr.hcl
42+
run: |
43+
PG_VERSION=$(sudo nix run nixpkgs#yq -- '.postgres_release["postgres'${{ env.POSTGRES_MAJOR_VERSION }}'"]' ansible/vars.yml)
44+
PG_VERSION=$(echo "$PG_VERSION" | tr -d '"') # Remove any surrounding quotes
45+
echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl
46+
# Ensure there's a newline at the end of the file
47+
echo "" >> common-nix.vars.pkr.hcl
48+
49+
- name: Build AMI stage 1
50+
env:
51+
POSTGRES_MAJOR_VERSION: ${{ env.POSTGRES_MAJOR_VERSION }}
52+
run: |
53+
packer init amazon-arm64-nix.pkr.hcl
54+
GIT_SHA=${{ steps.get_sha.outputs.sha }}
55+
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" -var "ansible_arguments=-e postgresql_major=${POSTGRES_MAJOR_VERSION}" amazon-arm64-nix.pkr.hcl
56+
57+
- name: Build AMI stage 2
58+
env:
59+
POSTGRES_MAJOR_VERSION: ${{ env.POSTGRES_MAJOR_VERSION }}
60+
run: |
61+
packer init stage2-nix-psql.pkr.hcl
62+
GIT_SHA=${{ steps.get_sha.outputs.sha }}
63+
POSTGRES_MAJOR_VERSION=${{ env.POSTGRES_MAJOR_VERSION }}
64+
packer build -var "git_sha=${GIT_SHA}" -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var "postgres_major_version=${POSTGRES_MAJOR_VERSION}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" stage2-nix-psql.pkr.hcl
65+
66+
- name: Grab release version
67+
id: process_release_version
68+
run: |
69+
VERSION=$(cat common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
70+
echo "version=$VERSION" >> $GITHUB_OUTPUT
71+
72+
- name: Create nix flake revision tarball
73+
run: |
74+
GIT_SHA=${{ steps.get_sha.outputs.sha }}
75+
MAJOR_VERSION=${{ env.POSTGRES_MAJOR_VERSION }}
76+
77+
mkdir -p "/tmp/pg_upgrade_bin/${MAJOR_VERSION}"
78+
echo "$GIT_SHA" >> "/tmp/pg_upgrade_bin/${MAJOR_VERSION}/nix_flake_version"
79+
tar -czf "/tmp/pg_binaries.tar.gz" -C "/tmp/pg_upgrade_bin" .
80+
81+
- name: configure aws credentials - staging
82+
uses: aws-actions/configure-aws-credentials@v4
83+
with:
84+
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
85+
aws-region: "us-east-1"
86+
87+
- name: Upload software manifest to s3 staging
88+
run: |
89+
cd ansible
90+
ansible-playbook -i localhost \
91+
-e "ami_release_version=${{ steps.process_release_version.outputs.version }}" \
92+
-e "internal_artifacts_bucket=${{ secrets.ARTIFACTS_BUCKET }}" \
93+
-e "postgres_major_version=${{ env.POSTGRES_MAJOR_VERSION }}" \
94+
manifest-playbook.yml
95+
96+
- name: Upload nix flake revision to s3 staging
97+
run: |
98+
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz
99+
100+
- name: configure aws credentials - prod
101+
uses: aws-actions/configure-aws-credentials@v4
102+
with:
103+
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
104+
aws-region: "us-east-1"
105+
106+
- name: Upload software manifest to s3 prod
107+
run: |
108+
cd ansible
109+
ansible-playbook -i localhost \
110+
-e "ami_release_version=${{ steps.process_release_version.outputs.version }}" \
111+
-e "internal_artifacts_bucket=${{ secrets.PROD_ARTIFACTS_BUCKET }}" \
112+
-e "postgres_major_version=${{ env.POSTGRES_MAJOR_VERSION }}" \
113+
manifest-playbook.yml
114+
115+
- name: Upload nix flake revision to s3 prod
116+
run: |
117+
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz
118+
119+
- name: Create release
120+
uses: softprops/action-gh-release@v2
121+
with:
122+
name: ${{ steps.process_release_version.outputs.version }}
123+
tag_name: ${{ steps.process_release_version.outputs.version }}
124+
target_commitish: ${{ steps.get_sha.outputs.sha }}
125+
126+
- name: Slack Notification on Failure
127+
if: ${{ failure() }}
128+
uses: rtCamp/action-slack-notify@v2
129+
env:
130+
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
131+
SLACK_USERNAME: 'gha-failures-notifier'
132+
SLACK_COLOR: 'danger'
133+
SLACK_MESSAGE: 'Building Postgres AMI failed'
134+
SLACK_FOOTER: ''
135+
136+
- name: Cleanup resources after build
137+
if: ${{ always() }}
138+
run: |
139+
aws ec2 describe-instances --filters "Name=tag:packerExecutionId,Values=${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --instance-ids
140+
141+
- name: Cleanup resources on build cancellation
142+
if: ${{ cancelled() }}
143+
run: |
144+
aws ec2 describe-instances --filters "Name=tag:packerExecutionId,Values=${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --instance-ids
145+

.github/workflows/qemu-image-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Set PostgreSQL versions - only builds pg17 atm
3131
id: set-versions
3232
run: |
33-
VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[2]' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c 'split("\n")[:-1]')
33+
VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[1,2]' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c 'split("\n")[:-1]')
3434
echo "postgres_versions=$VERSIONS" >> $GITHUB_OUTPUT
3535
3636
build:

Dockerfile-15

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,6 @@ RUN sed -i \
181181
echo "pgsodium.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
182182
echo "vault.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
183183
echo 'auto_explain.log_min_duration = 10s' >> /etc/postgresql/postgresql.conf && \
184-
# Remove supabase_admin line from pg_hba.conf
185-
sed -i '/local all supabase_admin scram-sha-256/d' /etc/postgresql/pg_hba.conf && \
186-
# Add supabase_admin mappings block to pg_ident.conf before supabase-specific users
187-
sed -i '/# supabase-specific users/i\# supabase_admin user mappings\nsupabase_map postgres supabase_admin\nsupabase_map root supabase_admin\nsupabase_map ubuntu supabase_admin\n' /etc/postgresql/pg_ident.conf && \
188184
usermod -aG postgres wal-g && \
189185
mkdir -p /etc/postgresql-custom && \
190186
chown postgres:postgres /etc/postgresql-custom
@@ -198,9 +194,7 @@ COPY ansible/files/stat_extension.sql /docker-entrypoint-initdb.d/migrations/00-
198194
COPY --from=gosu /usr/local/bin/gosu /usr/local/bin/gosu
199195
ADD --chmod=0755 \
200196
https://github.com/docker-library/postgres/raw/master/15/bullseye/docker-entrypoint.sh \
201-
/usr/local/bin/upstream-docker-entrypoint.sh
202-
# # Add custom entrypoint script
203-
COPY --chmod=0755 docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
197+
/usr/local/bin/docker-entrypoint.sh
204198

205199
RUN mkdir -p /var/run/postgresql && chown postgres:postgres /var/run/postgresql
206200

Dockerfile-17

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,6 @@ RUN sed -i \
181181
echo "pgsodium.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
182182
echo "vault.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
183183
echo 'auto_explain.log_min_duration = 10s' >> /etc/postgresql/postgresql.conf && \
184-
# Remove supabase_admin line from pg_hba.conf
185-
sed -i '/local all supabase_admin scram-sha-256/d' /etc/postgresql/pg_hba.conf && \
186-
# Add supabase_admin mappings block to pg_ident.conf before supabase-specific users
187-
sed -i '/# supabase-specific users/i\# supabase_admin user mappings\nsupabase_map postgres supabase_admin\nsupabase_map root supabase_admin\nsupabase_map ubuntu supabase_admin\n' /etc/postgresql/pg_ident.conf && \
188184
usermod -aG postgres wal-g && \
189185
mkdir -p /etc/postgresql-custom && \
190186
chown postgres:postgres /etc/postgresql-custom
@@ -206,9 +202,7 @@ COPY ansible/files/stat_extension.sql /docker-entrypoint-initdb.d/migrations/00-
206202
COPY --from=gosu /usr/local/bin/gosu /usr/local/bin/gosu
207203
ADD --chmod=0755 \
208204
https://github.com/docker-library/postgres/raw/master/17/bullseye/docker-entrypoint.sh \
209-
/usr/local/bin/upstream-docker-entrypoint.sh
210-
# # Add custom entrypoint script
211-
COPY --chmod=0755 docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
205+
/usr/local/bin/docker-entrypoint.sh
212206

213207
RUN mkdir -p /var/run/postgresql && chown postgres:postgres /var/run/postgresql
214208

Dockerfile-orioledb-17

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,6 @@ RUN sed -i \
181181
echo "pgsodium.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
182182
echo "vault.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
183183
echo 'auto_explain.log_min_duration = 10s' >> /etc/postgresql/postgresql.conf && \
184-
# Remove supabase_admin line from pg_hba.conf
185-
sed -i '/local all supabase_admin scram-sha-256/d' /etc/postgresql/pg_hba.conf && \
186-
# Add supabase_admin mappings block to pg_ident.conf before supabase-specific users
187-
sed -i '/# supabase-specific users/i\# supabase_admin user mappings\nsupabase_map postgres supabase_admin\nsupabase_map root supabase_admin\nsupabase_map ubuntu supabase_admin\n' /etc/postgresql/pg_ident.conf && \
188184
usermod -aG postgres wal-g && \
189185
mkdir -p /etc/postgresql-custom && \
190186
chown postgres:postgres /etc/postgresql-custom
@@ -211,9 +207,7 @@ RUN echo "CREATE EXTENSION orioledb;" > /docker-entrypoint-initdb.d/init-scripts
211207
COPY --from=gosu /usr/local/bin/gosu /usr/local/bin/gosu
212208
ADD --chmod=0755 \
213209
https://github.com/docker-library/postgres/raw/master/17/bullseye/docker-entrypoint.sh \
214-
/usr/local/bin/upstream-docker-entrypoint.sh
215-
# # Add custom entrypoint script
216-
COPY --chmod=0755 docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
210+
/usr/local/bin/docker-entrypoint.sh
217211

218212
RUN mkdir -p /var/run/postgresql && chown postgres:postgres /var/run/postgresql
219213

ansible/vars.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ postgres_major:
99

1010
# Full version strings for each major version
1111
postgres_release:
12-
postgresorioledb-17: "17.0.1.087-orioledb"
13-
postgres17: "17.4.1.037"
14-
postgres15: "15.8.1.094"
12+
postgresorioledb-17: "17.0.1.089-orioledb"
13+
postgres17: "17.4.1.039"
14+
postgres15: "15.8.1.096"
1515

1616
# Non Postgres Extensions
1717
pgbouncer_release: "1.19.0"
@@ -24,8 +24,8 @@ postgrest_release: "12.2.3"
2424
postgrest_arm_release_checksum: sha1:fbfd6613d711ce1afa25c42d5df8f1b017f396f9
2525
postgrest_x86_release_checksum: sha1:61c513f91a8931be4062587b9d4a18b42acf5c05
2626

27-
gotrue_release: 2.173.0
28-
gotrue_release_checksum: sha1:8ec5e9396f3b30cb867d32bdbe39fcfdd78f1f59
27+
gotrue_release: 2.174.0
28+
gotrue_release_checksum: sha1:d9ac9bb209a5e0b383ab96e05d05409eaebdbaac
2929

3030
aws_cli_release: "2.23.11"
3131

docker/docker-entrypoint.sh

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)