@@ -17,14 +17,20 @@ permissions:
17
17
18
18
jobs :
19
19
prepare :
20
- runs-on : ubuntu-latest
20
+ runs-on : blacksmith-4vcpu- ubuntu-2404
21
21
outputs :
22
22
postgres_versions : ${{ steps.set-versions.outputs.postgres_versions }}
23
23
steps :
24
24
- name : Checkout Repo
25
- uses : actions/checkout@v3
26
-
27
- - uses : DeterminateSystems/nix-installer-action@main
25
+ uses : supabase/postgres/.github/actions/shared-checkout@HEAD
26
+
27
+ - name : Install nix
28
+ uses : cachix/install-nix-action@v27
29
+ with :
30
+ install_url : https://releases.nixos.org/nix/nix-2.29.1/install
31
+ extra_nix_config : |
32
+ substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
33
+ trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
28
34
29
35
- name : Set PostgreSQL versions
30
36
id : set-versions
@@ -38,35 +44,46 @@ jobs:
38
44
matrix :
39
45
postgres_version : ${{ fromJson(needs.prepare.outputs.postgres_versions) }}
40
46
include :
41
- - runner : arm-runner
42
- arch : arm64
43
- ubuntu_release : focal
44
- ubuntu_version : 20.04
45
- mcpu : neoverse-n1
47
+ - runner : blacksmith-2vcpu-ubuntu-2404-arm
46
48
runs-on : ${{ matrix.runner }}
47
49
timeout-minutes : 150
48
50
49
51
steps :
50
52
- name : Checkout Repo
51
- uses : actions/checkout@v3
53
+ uses : supabase/postgres/.github/actions/shared-checkout@HEAD
54
+ - name : aws-creds
55
+ uses : aws-actions/configure-aws-credentials@v4
56
+ with :
57
+ role-to-assume : ${{ secrets.DEV_AWS_ROLE }}
58
+ aws-region : " us-east-1"
59
+ output-credentials : true
60
+ role-duration-seconds : 7200
52
61
53
- - uses : DeterminateSystems/nix-installer-action@main
62
+ - name : Install nix
63
+ uses : cachix/install-nix-action@v27
64
+ with :
65
+ install_url : https://releases.nixos.org/nix/nix-2.29.1/install
66
+ extra_nix_config : |
67
+ substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
68
+ trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
54
69
55
70
- name : Run checks if triggered manually
56
71
if : ${{ github.event_name == 'workflow_dispatch' }}
57
72
run : |
58
- SUFFIX=$(sudo nix run nixpkgs#yq -- ".postgres_release[\"postgres${{ matrix.postgres_version }}\"]" ansible/vars.yml | sed -E 's/[0-9\.]+(.*)$/\1/')
73
+ SUFFIX=$(nix run nixpkgs#yq -- ".postgres_release[\"postgres${{ matrix.postgres_version }}\"]" ansible/vars.yml | sed -E 's/[0-9\.]+(.*)$/\1/')
59
74
if [[ -z "$SUFFIX" ]] ; then
60
75
echo "Version must include non-numeric characters if built manually."
61
76
exit 1
62
77
fi
63
78
64
79
- name : Set PostgreSQL version environment variable
65
- run : echo "POSTGRES_MAJOR_VERSION=${{ matrix.postgres_version }}" >> $GITHUB_ENV
80
+ run : |
81
+ echo "POSTGRES_MAJOR_VERSION=${{ matrix.postgres_version }}" >> $GITHUB_ENV
82
+ echo "EXECUTION_ID=${{ github.run_id }}-${{ matrix.postgres_version }}" >> $GITHUB_ENV
66
83
67
84
- name : Generate common-nix.vars.pkr.hcl
68
85
run : |
69
- PG_VERSION=$(sudo nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
86
+ PG_VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
70
87
PG_VERSION=$(echo "$PG_VERSION" | tr -d '"') # Remove any surrounding quotes
71
88
echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl
72
89
# Ensure there's a newline at the end of the file
@@ -76,19 +93,19 @@ jobs:
76
93
env :
77
94
POSTGRES_MAJOR_VERSION : ${{ env.POSTGRES_MAJOR_VERSION }}
78
95
run : |
79
- packer init amazon-arm64-nix.pkr.hcl
80
96
GIT_SHA=${{github.sha}}
97
+ nix run github:supabase/postgres/${GIT_SHA}#packer -- init amazon-arm64-nix.pkr.hcl
81
98
# why is postgresql_major defined here instead of where the _three_ other postgresql_* variables are defined?
82
- 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
99
+ 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
83
100
84
101
- name : Build AMI stage 2
85
102
env :
86
103
POSTGRES_MAJOR_VERSION : ${{ env.POSTGRES_MAJOR_VERSION }}
87
104
run : |
88
- packer init stage2-nix-psql.pkr.hcl
89
105
GIT_SHA=${{github.sha}}
106
+ nix run github:supabase/postgres/${GIT_SHA}#packer -- init stage2-nix-psql.pkr.hcl
90
107
POSTGRES_MAJOR_VERSION=${{ env.POSTGRES_MAJOR_VERSION }}
91
- 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
108
+ 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-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" stage2-nix-psql.pkr.hcl
92
109
93
110
- name : Grab release version
94
111
id : process_release_version
@@ -123,6 +140,8 @@ jobs:
123
140
- name : Upload nix flake revision to s3 staging
124
141
run : |
125
142
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
143
+ aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/24.04.tar.gz
144
+ aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/upgrade_bundle.tar.gz
126
145
127
146
- name : configure aws credentials - prod
128
147
uses : aws-actions/configure-aws-credentials@v4
@@ -142,6 +161,8 @@ jobs:
142
161
- name : Upload nix flake revision to s3 prod
143
162
run : |
144
163
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
164
+ 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
165
+ 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
145
166
146
167
- name : Create release
147
168
uses : softprops/action-gh-release@v2
@@ -163,9 +184,9 @@ jobs:
163
184
- name : Cleanup resources after build
164
185
if : ${{ always() }}
165
186
run : |
166
- 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
187
+ aws ec2 describe-instances --filters "Name=tag:packerExecutionId,Values=${EXECUTION_ID }" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --instance-ids
167
188
168
189
- name : Cleanup resources on build cancellation
169
190
if : ${{ cancelled() }}
170
191
run : |
171
- 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
192
+ aws ec2 describe-instances --filters "Name=tag:packerExecutionId,Values=${EXECUTION_ID }" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --instance-ids
0 commit comments