|
| 1 | +name: Publish nix pg_upgrade_bin flake version |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + postgresVersion: |
| 7 | + description: 'Optional. Postgres version to publish against, i.e. 15.1.1.78' |
| 8 | + required: false |
| 9 | + |
| 10 | +permissions: |
| 11 | + id-token: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + publish-staging: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout Repo |
| 19 | + uses: actions/checkout@v3 |
| 20 | + |
| 21 | + - name: Grab release version |
| 22 | + id: process_release_version |
| 23 | + run: | |
| 24 | + VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g') |
| 25 | + if [[ "${{ inputs.postgresVersion }}" != "" ]]; then |
| 26 | + VERSION=${{ inputs.postgresVersion }} |
| 27 | + fi |
| 28 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 29 | + echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT" |
| 30 | +
|
| 31 | + - name: Create a tarball containing the latest nix flake version |
| 32 | + working-directory: /tmp/ |
| 33 | + run: | |
| 34 | + mkdir -p ${{ steps.process_release_version.outputs.major_version }} |
| 35 | + echo $GITHUB_SHA > ${{ steps.process_release_version.outputs.major_version }}/nix_flake_version |
| 36 | + tar -czvf pg_upgrade_bin.tar.gz ${{ steps.process_release_version.outputs.major_version }} |
| 37 | +
|
| 38 | + - name: configure aws credentials - staging |
| 39 | + uses: aws-actions/configure-aws-credentials@v1 |
| 40 | + with: |
| 41 | + role-to-assume: ${{ secrets.DEV_AWS_ROLE }} |
| 42 | + aws-region: "us-east-1" |
| 43 | + |
| 44 | + - name: Upload pg_upgrade scripts to s3 staging |
| 45 | + run: | |
| 46 | + aws s3 cp /tmp/pg_upgrade_bin.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz |
| 47 | +
|
| 48 | + - name: Slack Notification on Failure |
| 49 | + if: ${{ failure() }} |
| 50 | + uses: rtCamp/action-slack-notify@v2 |
| 51 | + env: |
| 52 | + SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }} |
| 53 | + SLACK_USERNAME: 'gha-failures-notifier' |
| 54 | + SLACK_COLOR: 'danger' |
| 55 | + SLACK_MESSAGE: 'Publishing pg_upgrade binaries flake version failed' |
| 56 | + SLACK_FOOTER: '' |
| 57 | + |
| 58 | + publish-prod: |
| 59 | + runs-on: ubuntu-latest |
| 60 | + if: github.ref_name == 'develop' || contains( github.ref, 'release' ) |
| 61 | + |
| 62 | + steps: |
| 63 | + - name: Checkout Repo |
| 64 | + uses: actions/checkout@v3 |
| 65 | + |
| 66 | + - name: Grab release version |
| 67 | + id: process_release_version |
| 68 | + run: | |
| 69 | + VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g') |
| 70 | + if [[ "${{ inputs.postgresVersion }}" != "" ]]; then |
| 71 | + VERSION=${{ inputs.postgresVersion }} |
| 72 | + fi |
| 73 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 74 | + echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT" |
| 75 | +
|
| 76 | + - name: Create a tarball containing the latest nix flake version |
| 77 | + working-directory: /tmp/ |
| 78 | + run: | |
| 79 | + mkdir -p ${{ steps.process_release_version.outputs.major_version }} |
| 80 | + echo $GITHUB_SHA > ${{ steps.process_release_version.outputs.major_version }}/nix_flake_version |
| 81 | + tar -czvf pg_upgrade_bin.tar.gz ${{ steps.process_release_version.outputs.major_version }} |
| 82 | +
|
| 83 | + - name: configure aws credentials - prod |
| 84 | + uses: aws-actions/configure-aws-credentials@v1 |
| 85 | + with: |
| 86 | + role-to-assume: ${{ secrets.PROD_AWS_ROLE }} |
| 87 | + aws-region: "us-east-1" |
| 88 | + |
| 89 | + - name: Upload pg_upgrade scripts to s3 prod |
| 90 | + run: | |
| 91 | + aws s3 cp /tmp/pg_upgrade_bin.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz |
| 92 | +
|
| 93 | + - name: Slack Notification on Failure |
| 94 | + if: ${{ failure() }} |
| 95 | + uses: rtCamp/action-slack-notify@v2 |
| 96 | + env: |
| 97 | + SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }} |
| 98 | + SLACK_USERNAME: 'gha-failures-notifier' |
| 99 | + SLACK_COLOR: 'danger' |
| 100 | + SLACK_MESSAGE: 'Publishing pg_upgrade binaries flake version failed' |
| 101 | + SLACK_FOOTER: '' |
0 commit comments