Merge pull request #486 from supabase/chore/release-v2.0.6-on-staging #269
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish upgrade artifacts to staging | |
on: | |
push: | |
branches: | |
- release_stage | |
env: | |
INCLUDE_ERTS: true | |
MIX_ENV: prod | |
jobs: | |
publish: | |
runs-on: u22-arm-runner | |
timeout-minutes: 15 | |
permissions: | |
contents: write | |
packages: write | |
id-token: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set upgrade variables | |
run: | | |
elixir ./deploy/upgrade/handler.exs all_keys ./deploy/upgrade/staging.config | |
echo "RELEASE_FROM=$(elixir ./deploy/upgrade/handler.exs upgrade_from ./deploy/upgrade/staging.config)" >> $GITHUB_ENV | |
echo "RELEASE_TO=$(elixir ./deploy/upgrade/handler.exs upgrade_to ./deploy/upgrade/staging.config)" >> $GITHUB_ENV | |
echo "NAME=$(elixir ./deploy/upgrade/handler.exs name ./deploy/upgrade/staging.config)" >> $GITHUB_ENV | |
echo "TYPE=$(elixir ./deploy/upgrade/handler.exs type ./deploy/upgrade/staging.config)" >> $GITHUB_ENV | |
- name: Setup Elixir | |
run: | | |
. ~/.asdf/asdf.sh | |
echo 'elixir v1.14.5-otp-25' >> ~/.tool-versions | |
echo 'erlang 25.3.2.7' >> ~/.tool-versions | |
elixir -v | |
- name: Set up Rust | |
uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Get git tags | |
run: git fetch --tags origin | |
- name: Checkout RELEASE_FROM | |
if: env.TYPE == 'soft' | |
run: git checkout v${{ env.RELEASE_FROM }} | |
- name: Cache Mix | |
if: env.TYPE == 'soft' | |
uses: actions/cache@v3 | |
with: | |
path: deps | |
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | |
restore-keys: | | |
${{ runner.os }}-mix- | |
- name: Install dependencies | |
if: env.TYPE == 'soft' | |
run: | | |
mix local.hex --force | |
mix local.rebar --force | |
mix deps.get | |
- name: Make old release | |
if: env.TYPE == 'soft' | |
run: mix release supavisor | |
- name: Checkout RELEASE_TO | |
run: git checkout v${{ env.RELEASE_TO }} | |
- name: Cache Mix | |
uses: actions/cache@v3 | |
with: | |
path: deps | |
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | |
restore-keys: | | |
${{ runner.os }}-mix- | |
- name: Clean up old release(s) | |
if: env.TYPE == 'soft' | |
run: | | |
rm -rf ./_build/${{ env.MIX_ENV }}/lib/supavisor | |
rm ./_build/${{ env.MIX_ENV }}/rel/supavisor/releases/COOKIE | |
rm ./_build/${{ env.MIX_ENV }}/supavisor-${{ env.RELEASE_FROM }}.tar.gz | |
- name: Install dependencies | |
run: | | |
mix local.hex --force | |
mix local.rebar --force | |
mix deps.get | |
- name: Make upgrade release | |
if: env.TYPE == 'soft' | |
run: RELEASE_COOKIE=${{ secrets.RELEASE_COOKIE_STAGE }} UPGRADE_FROM=${{ env.RELEASE_FROM }} mix release supavisor | |
- name: Make hard ${{ env.RELEASE_TO }} release | |
if: env.TYPE == 'hard' | |
run: RELEASE_COOKIE=${{ secrets.RELEASE_COOKIE_STAGE }} mix release supavisor | |
- name: Create tarball | |
run: cd _build/${{ env.MIX_ENV }} && mv supavisor-${{ env.RELEASE_TO }}.tar.gz "${{ env.NAME }}_$(date "+%s").tar.gz" | |
- name: configure aws credentials - staging | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.DEV_AWS_ROLE }} | |
aws-region: "us-east-1" | |
- name: Deploy to S3 | |
shell: bash | |
run: aws s3 sync ./_build/${{ env.MIX_ENV }} ${{ secrets.TARBALLS_PATH_STAGE }} --exclude '*' --include '*tar.gz' |