Skip to content

Commit 73c1922

Browse files
samrosetomashley
andauthored
feat: publish and use nix-catalog (#1995)
* feat: publish and use nix-catalog * fix: catalog entries hash plus version * chore: use OIDC to auth shared services bucket (#1997) * fix: use aws cli to access catalog * chore: bump to release --------- Co-authored-by: Tom Ashley <tom.ashley@gmail.com>
1 parent 6e05c98 commit 73c1922

File tree

3 files changed

+88
-5
lines changed

3 files changed

+88
-5
lines changed

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,52 @@ jobs:
138138
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/24.04.tar.gz
139139
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/upgrade_bundle.tar.gz
140140
141+
- name: GitHub OIDC Auth
142+
uses: aws-actions/configure-aws-credentials@v4.1.0
143+
with:
144+
aws-region: ap-southeast-1
145+
role-to-assume: arn:aws:iam::279559813984:role/supabase-github-oidc-role
146+
role-session-name: shared-services-jump
147+
148+
- name: Assume destination role
149+
uses: aws-actions/configure-aws-credentials@v4.1.0
150+
with:
151+
aws-region: ap-southeast-1
152+
role-to-assume: arn:aws:iam::279559813984:role/supabase-nix-catalog-artifacts-role-6387512
153+
role-skip-session-tagging: true
154+
role-session-name: upload-assets
155+
role-chaining: true
156+
157+
- name: Update nix store path catalog
158+
run: |
159+
VERSION="${{ steps.process_release_version.outputs.version }}"
160+
GIT_SHA="${{ github.sha }}"
161+
PG_VERSION="${{ matrix.postgres_version }}"
162+
SYSTEM="aarch64-linux"
163+
164+
# Get store path for this build
165+
STORE_PATH=$(nix eval --raw ".#psql_${PG_VERSION}/bin.outPath")
166+
167+
# Each postgres version gets its own catalog file (no race conditions)
168+
CATALOG_S3="s3://${{ secrets.SHARED_AWS_ARTIFACTS_BUCKET }}/nix-catalog/${GIT_SHA}-psql_${PG_VERSION}.json"
169+
170+
# Create catalog JSON for this version
171+
jq -n \
172+
--arg ver "$VERSION" \
173+
--arg sha "$GIT_SHA" \
174+
--arg sys "$SYSTEM" \
175+
--arg path "$STORE_PATH" \
176+
'{version: $ver, git_sha: $sha, ($sys): $path}' > /tmp/catalog.json
177+
178+
echo "Catalog for psql_${PG_VERSION}:"
179+
cat /tmp/catalog.json
180+
181+
# Upload catalog
182+
aws s3 cp /tmp/catalog.json "$CATALOG_S3" \
183+
--content-type "application/json"
184+
185+
echo "Catalog uploaded to ${CATALOG_S3}"
186+
141187
- name: Create release
142188
uses: softprops/action-gh-release@v2
143189
with:

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,48 @@ EXTRA_NIX_CONF
301301
fi
302302
fi
303303

304-
echo "1.2. Installing flake revision: $NIX_FLAKE_VERSION"
304+
echo "1.2. Fetching store path for flake revision: $NIX_FLAKE_VERSION"
305305
# shellcheck disable=SC1091
306306
source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
307307
nix-collect-garbage -d > /tmp/pg_upgrade-nix-gc.log 2>&1 || true
308-
PG_UPGRADE_BIN_DIR=$(nix build "github:supabase/postgres/${NIX_FLAKE_VERSION}#psql_${PGVERSION}/bin" --no-link --print-out-paths --extra-experimental-features nix-command --extra-experimental-features flakes)
308+
309+
# Determine system architecture
310+
ARCH=$(uname -m)
311+
if [ "$ARCH" = "aarch64" ]; then
312+
SYSTEM="aarch64-linux"
313+
elif [ "$ARCH" = "x86_64" ]; then
314+
SYSTEM="x86_64-linux"
315+
else
316+
echo "ERROR: Unsupported architecture: $ARCH"
317+
exit 1
318+
fi
319+
320+
# Fetch store path from catalog (avoids expensive nix eval - prevents OOM on small instances)
321+
# Each postgres version has its own catalog file: {git_sha}-psql_{version}.json
322+
CATALOG_S3="s3://supabase-internal-artifacts/nix-catalog/${NIX_FLAKE_VERSION}-psql_${PGVERSION}.json"
323+
CATALOG_LOCAL="/tmp/nix-catalog-${NIX_FLAKE_VERSION}-psql_${PGVERSION}.json"
324+
echo "Fetching catalog from: $CATALOG_S3"
325+
326+
if ! aws s3 cp "$CATALOG_S3" "$CATALOG_LOCAL" --region ap-southeast-1; then
327+
echo "ERROR: Failed to fetch catalog from $CATALOG_S3"
328+
exit 1
329+
fi
330+
331+
STORE_PATH=$(jq -r ".\"${SYSTEM}\"" "$CATALOG_LOCAL")
332+
333+
if [ -z "$STORE_PATH" ] || [ "$STORE_PATH" = "null" ]; then
334+
echo "ERROR: Could not find store path in catalog for ${SYSTEM}"
335+
echo "Catalog contents:"
336+
jq . "$CATALOG_LOCAL"
337+
exit 1
338+
fi
339+
340+
echo "Store path: $STORE_PATH"
341+
342+
# Realize from binary cache (no nix evaluation needed!)
343+
nix-store -r "$STORE_PATH"
344+
345+
PG_UPGRADE_BIN_DIR="$STORE_PATH"
309346
PGSHARENEW="$PG_UPGRADE_BIN_DIR/share/postgresql"
310347
fi
311348

ansible/vars.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ postgres_major:
1010

1111
# Full version strings for each major version
1212
postgres_release:
13-
postgresorioledb-17: "17.6.0.027-orioledb"
14-
postgres17: "17.6.1.070"
15-
postgres15: "15.14.1.070"
13+
postgresorioledb-17: "17.6.0.028-orioledb"
14+
postgres17: "17.6.1.071"
15+
postgres15: "15.14.1.071"
1616

1717
# Non Postgres Extensions
1818
pgbouncer_release: 1.19.0

0 commit comments

Comments
 (0)