Skip to content

Commit 2edcf2d

Browse files
authored
chore: package nix flake revision in pg_upgrade binaries tarball when building the nix AMI (#1058)
1 parent 16cd5c9 commit 2edcf2d

File tree

2 files changed

+110
-2
lines changed

2 files changed

+110
-2
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ jobs:
6161
VERSION=$(sed -e 's/postgres-version = "\(.*\)"/\1/g' common-nix.vars.pkr.hcl)
6262
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
6363
64+
- name: Create nix flake revision tarball
65+
run: |
66+
GIT_SHA=${{github.sha}}
67+
MAJOR_VERSION=$(echo "${{ steps.process_release_version.outputs.version }}" | cut -d. -f1)
68+
69+
mkdir -p "/tmp/pg_upgrade_bin/${MAJOR_VERSION}"
70+
echo "$GIT_SHA" >> "/tmp/pg_upgrade_bin/${MAJOR_VERSION}/nix_flake_version"
71+
tar -czf "/tmp/pg_binaries.tar.gz" -C "/tmp/pg_upgrade_bin" .
72+
6473
- name: configure aws credentials - staging
6574
uses: aws-actions/configure-aws-credentials@v4
6675
with:
@@ -75,6 +84,9 @@ jobs:
7584
-e "internal_artifacts_bucket=${{ secrets.ARTIFACTS_BUCKET }}" \
7685
manifest-playbook.yml
7786
87+
- name: Upload nix flake revision to s3 staging
88+
run: |
89+
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
7890
7991
#Our self hosted github runner already has permissions to publish images
8092
#but they're limited to only that;
@@ -95,8 +107,10 @@ jobs:
95107
-e "internal_artifacts_bucket=${{ secrets.PROD_ARTIFACTS_BUCKET }}" \
96108
manifest-playbook.yml
97109
98-
99-
110+
- name: Upload nix flake revision to s3 prod
111+
run: |
112+
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
113+
100114
- name: Create release
101115
uses: softprops/action-gh-release@v1
102116
with:
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Publish pg_upgrade_scripts
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- sam/nix-and-conventional-ami
8+
paths:
9+
- '.github/workflows/publish-pgupgrade-scripts.yml'
10+
- 'common-nix.vars.pkr.hcl'
11+
workflow_dispatch:
12+
13+
permissions:
14+
id-token: write
15+
16+
jobs:
17+
publish-staging:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout Repo
22+
uses: actions/checkout@v3
23+
24+
- name: Grab release version
25+
id: process_release_version
26+
run: |
27+
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
28+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
29+
30+
- name: Create a tarball containing pg_upgrade scripts
31+
run: |
32+
mkdir -p /tmp/pg_upgrade_scripts
33+
cp -r ansible/files/admin_api_scripts/pg_upgrade_scripts/* /tmp/pg_upgrade_scripts
34+
tar -czvf /tmp/pg_upgrade_scripts.tar.gz -C /tmp/ pg_upgrade_scripts
35+
36+
- name: configure aws credentials - staging
37+
uses: aws-actions/configure-aws-credentials@v1
38+
with:
39+
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
40+
aws-region: "us-east-1"
41+
42+
- name: Upload pg_upgrade scripts to s3 staging
43+
run: |
44+
aws s3 cp /tmp/pg_upgrade_scripts.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/pg_upgrade_scripts.tar.gz
45+
46+
- name: Slack Notification on Failure
47+
if: ${{ failure() }}
48+
uses: rtCamp/action-slack-notify@v2
49+
env:
50+
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
51+
SLACK_USERNAME: 'gha-failures-notifier'
52+
SLACK_COLOR: 'danger'
53+
SLACK_MESSAGE: 'Publishing pg_upgrade scripts failed'
54+
SLACK_FOOTER: ''
55+
56+
publish-prod:
57+
runs-on: ubuntu-latest
58+
if: github.ref_name == 'develop'
59+
60+
steps:
61+
- name: Checkout Repo
62+
uses: actions/checkout@v3
63+
64+
- name: Grab release version
65+
id: process_release_version
66+
run: |
67+
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
68+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
69+
70+
- name: Create a tarball containing pg_upgrade scripts
71+
run: |
72+
mkdir -p /tmp/pg_upgrade_scripts
73+
cp -r ansible/files/admin_api_scripts/pg_upgrade_scripts/* /tmp/pg_upgrade_scripts
74+
tar -czvf /tmp/pg_upgrade_scripts.tar.gz -C /tmp/ pg_upgrade_scripts
75+
76+
- name: configure aws credentials - prod
77+
uses: aws-actions/configure-aws-credentials@v1
78+
with:
79+
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
80+
aws-region: "us-east-1"
81+
82+
- name: Upload pg_upgrade scripts to s3 prod
83+
run: |
84+
aws s3 cp /tmp/pg_upgrade_scripts.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/pg_upgrade_scripts.tar.gz
85+
86+
- name: Slack Notification on Failure
87+
if: ${{ failure() }}
88+
uses: rtCamp/action-slack-notify@v2
89+
env:
90+
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
91+
SLACK_USERNAME: 'gha-failures-notifier'
92+
SLACK_COLOR: 'danger'
93+
SLACK_MESSAGE: 'Publishing pg_upgrade scripts failed'
94+
SLACK_FOOTER: ''

0 commit comments

Comments
 (0)