Skip to content

Commit

Permalink
feat: upload software artifacts to internal bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
darora committed Feb 22, 2023
1 parent 141e7da commit 2c56608
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 3 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/ami-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ on:

jobs:
build:
runs-on: [self-hosted, linux]
runs-on: [self-hosted, X64]
timeout-minutes: 150
permissions:
contents: write
packages: write
id-token: write

steps:
- name: Checkout Repo
Expand All @@ -26,6 +30,20 @@ jobs:
VERSION=$(sed -e 's/postgres-version = "\(.*\)"/\1/g' common.vars.pkr.hcl)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: configure aws credentials - staging
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
aws-region: "us-east-1"

- name: Upload software manifest to s3
run: |
cd ansible
ansible-playbook -i localhost \
-e "ami_release_version=${{ steps.process_release_version.outputs.version }}" \
-e "internal_artifacts_bucket=${{ secrets.ARTIFACTS_BUCKET }}" \
manifest-playbook.yml
- name: Create release
uses: softprops/action-gh-release@v1
with:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
.python-version
venv/
*.swp
docker/cache/
docker/cache/

ansible/image-manifest*.json
1 change: 1 addition & 0 deletions ansible/files/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ vars | to_json }}
73 changes: 73 additions & 0 deletions ansible/manifest-playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
- hosts: localhost
gather_facts: no

vars_files:
- ./vars.yml

tasks:
- name: Write out image manifest
action: template src=files/manifest.json dest=./image-manifest-{{ ami_release_version }}.json

- name: Upload image manifest
shell: |
aws s3 cp ./image-manifest-{{ ami_release_version }}.json s3://{{ internal_artifacts_bucket }}/manifests/postgres-{{ ami_release_version }}/software-manifest.json
# upload software artifacts of interest
# Generally - download, extract, repack as xz archive, upload
# currently, we upload gotrue, adminapi, postgrest
- name: gotrue - download commit archive
get_url:
url: "https://github.com/supabase/gotrue/releases/download/{{ gotrue_release }}/gotrue-{{ gotrue_release }}-arm64.tar.gz"
dest: /tmp/gotrue.tar.gz
checksum: "{{ gotrue_release_checksum }}"
timeout: 60

- name: gotrue - create /tmp/gotrue
file:
path: /tmp/gotrue
state: directory
mode: 0775

- name: gotrue - unpack archive in /tmp/gotrue
unarchive:
remote_src: yes
src: /tmp/gotrue.tar.gz
dest: /tmp/gotrue

- name: gotrue - pack archive
shell: |
tar -cJf /tmp/gotrue-{{ gotrue_release }}-arm64.tar.xz /tmp/gotrue
- name: PostgREST - download ubuntu binary archive (arm)
get_url:
url: "https://github.com/PostgREST/postgrest/releases/download/v{{ postgrest_release }}/postgrest-v{{ postgrest_release }}-ubuntu-aarch64.tar.xz"
dest: /tmp/postgrest-{{ postgrest_release }}-arm64.tar.xz
checksum: "{{ postgrest_arm_release_checksum }}"
timeout: 60

- name: Download adminapi archive
get_url:
url: "https://supabase-public-artifacts-bucket.s3.amazonaws.com/supabase-admin-api/v{{ adminapi_release }}/supabase-admin-api_{{ adminapi_release }}_linux_arm64.tar.gz"
dest: "/tmp/adminapi.tar.gz"
timeout: 90

- name: adminapi - unpack archive in /tmp
unarchive:
remote_src: yes
src: /tmp/adminapi.tar.gz
dest: /tmp

- name: adminapi - pack archive
shell: |
tar -cJf /tmp/supabase-admin-api-{{ adminapi_release }}-arm64.tar.xz /tmp/supabase-admin-api
- name: upload archives
shell: |
aws s3 cp /tmp/{{ item.file }} s3://{{ internal_artifacts_bucket }}/upgrades/{{ item.service }}/{{ item.file }}
with_items:
- service: gotrue
file: gotrue-{{ gotrue_release }}-arm64.tar.xz
- service: postgrest
file: postgrest-{{ postgrest_release }}-arm64.tar.xz
- service: supabase-admin-api
file: supabase-admin-api-{{ adminapi_release }}-arm64.tar.xz
2 changes: 1 addition & 1 deletion common.vars.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
postgres-version = "15.1.0.45"
postgres-version = "15.1.0.46-rc0"

0 comments on commit 2c56608

Please sign in to comment.