@@ -17,14 +17,20 @@ permissions:
1717
1818jobs :
1919 prepare :
20- runs-on : ubuntu-latest
20+ runs-on : blacksmith-4vcpu- ubuntu-2404
2121 outputs :
2222 postgres_versions : ${{ steps.set-versions.outputs.postgres_versions }}
2323 steps :
2424 - 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=
2834
2935 - name : Set PostgreSQL versions
3036 id : set-versions
@@ -38,35 +44,46 @@ jobs:
3844 matrix :
3945 postgres_version : ${{ fromJson(needs.prepare.outputs.postgres_versions) }}
4046 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
4648 runs-on : ${{ matrix.runner }}
4749 timeout-minutes : 150
4850
4951 steps :
5052 - 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
5261
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=
5469
5570 - name : Run checks if triggered manually
5671 if : ${{ github.event_name == 'workflow_dispatch' }}
5772 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/')
5974 if [[ -z "$SUFFIX" ]] ; then
6075 echo "Version must include non-numeric characters if built manually."
6176 exit 1
6277 fi
6378
6479 - 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
6683
6784 - name : Generate common-nix.vars.pkr.hcl
6885 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)
7087 PG_VERSION=$(echo "$PG_VERSION" | tr -d '"') # Remove any surrounding quotes
7188 echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl
7289 # Ensure there's a newline at the end of the file
@@ -76,19 +93,19 @@ jobs:
7693 env :
7794 POSTGRES_MAJOR_VERSION : ${{ env.POSTGRES_MAJOR_VERSION }}
7895 run : |
79- packer init amazon-arm64-nix.pkr.hcl
8096 GIT_SHA=${{github.sha}}
97+ nix run github:supabase/postgres/${GIT_SHA}#packer -- init amazon-arm64-nix.pkr.hcl
8198 # 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
83100
84101 - name : Build AMI stage 2
85102 env :
86103 POSTGRES_MAJOR_VERSION : ${{ env.POSTGRES_MAJOR_VERSION }}
87104 run : |
88- packer init stage2-nix-psql.pkr.hcl
89105 GIT_SHA=${{github.sha}}
106+ nix run github:supabase/postgres/${GIT_SHA}#packer -- init stage2-nix-psql.pkr.hcl
90107 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
92109
93110 - name : Grab release version
94111 id : process_release_version
@@ -123,6 +140,8 @@ jobs:
123140 - name : Upload nix flake revision to s3 staging
124141 run : |
125142 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
126145
127146 - name : configure aws credentials - prod
128147 uses : aws-actions/configure-aws-credentials@v4
@@ -142,6 +161,8 @@ jobs:
142161 - name : Upload nix flake revision to s3 prod
143162 run : |
144163 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
145166
146167 - name : Create release
147168 uses : softprops/action-gh-release@v2
@@ -163,9 +184,9 @@ jobs:
163184 - name : Cleanup resources after build
164185 if : ${{ always() }}
165186 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
167188
168189 - name : Cleanup resources on build cancellation
169190 if : ${{ cancelled() }}
170191 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