Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prod deploy #2007

Merged
merged 17 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
push:
branches:
- main
- develop

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
pull_request:
push:
branches:
- main
- develop

jobs:
analyze:
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Prod Deploy

on:
# Run this action every Tuesday at 02:00 UTC (Singapore 10AM)
schedule:
- cron: "0 2 * * 2"
workflow_dispatch:

permissions:
pull-requests: write
contents: write

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: gh pr create -B main -H develop --title 'Prod deploy' --fill
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/fast-forward.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Fast-forward

on:
pull_request_review:
types:
- submitted

permissions:
contents: write

jobs:
approved:
if: |
github.event.pull_request.head.ref == 'develop' &&
github.event.pull_request.base.ref == 'main' &&
github.event.review.state == 'approved'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: |
git checkout main
git merge --ff-only "${{ github.event.pull_request.head.sha }}"
git push origin main

publish:
needs:
- approved
# Call workflow explicitly because events from actions cannot trigger more actions
uses: ./.github/workflows/release.yml
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- 'scripts/**'
push:
branches:
- main
- develop
paths:
- '.github/workflows/install.yml'
- 'package.json'
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/release-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release (Beta)
on:
push:
branches:
- main
- develop
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -48,8 +48,6 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BREWTAP_TOKEN: ${{ secrets.GH_PAT }}
SCOOP_TOKEN: ${{ secrets.GH_PAT }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}

- run: gh release edit v${{ needs.release.outputs.new-release-version }} --draft=false --prerelease
Expand All @@ -69,7 +67,7 @@ jobs:
with:
go-version-file: go.mod
cache: true
- run: go run tools/publish/main.go --beta "${GITHUB_REF_NAME#v}"
- run: go run tools/publish/main.go --beta "${{ needs.release.outputs.new-release-version }}"
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}

Expand Down
41 changes: 33 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,75 @@
name: Release

on:
release:
types:
- released
push:
branches:
- main
workflow_call:

jobs:
settings:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
release_tag: ${{ steps.prerelease.outputs.tagName }}
steps:
- uses: actions/checkout@v4
- id: prerelease
run: |
gh release list --limit 1 --json tagName --jq \
'.[]|to_entries|map("\(.key)=\(.value|tostring)")|.[]' >> $GITHUB_OUTPUT
- run: gh release edit ${{ steps.prerelease.outputs.tagName }} --latest

commit:
name: Publish Brew and Scoop
needs:
- settings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- run: go run tools/publish/main.go "${GITHUB_REF_NAME#v}"
- run: go run tools/publish/main.go ${{ needs.settings.outputs.release_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}

publish:
name: Publish NPM
needs:
- settings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
- run: npm dist-tag add "supabase@${GITHUB_REF_NAME#v}" latest
- run: npm dist-tag add "supabase@${RELEASE_TAG#v}" latest
env:
RELEASE_TAG: ${{ needs.settings.outputs.release_tag }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

compose:
name: Publish self-hosted
name: Bump self-hosted versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- run: go run tools/selfhost/main.go "cli/$GITHUB_REF_NAME"
- run: go run tools/selfhost/main.go
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}

changelog:
name: Publish changelog
needs:
- commit
- publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -61,13 +84,15 @@ jobs:

docs:
name: Publish reference docs
needs:
- settings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- run: go run docs/main.go "${GITHUB_REF_NAME#v}" | go run tools/bumpdoc/main.go apps/docs/spec/cli_v1_commands.yaml
- run: go run docs/main.go ${{ needs.settings.outputs.release_tag }} | go run tools/bumpdoc/main.go apps/docs/spec/cli_v1_commands.yaml
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
9 changes: 6 additions & 3 deletions docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bytes"
"embed"
"flag"
"fmt"
"log"
"os"
Expand All @@ -27,9 +28,11 @@ var (
)

func main() {
semver := "latest"
if len(os.Args) > 1 {
semver = os.Args[1]
semver := flag.Arg(0)
if len(semver) == 0 {
semver = "latest"
} else if semver[0] == 'v' {
semver = semver[1:]
}

if err := generate(semver); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ require (
github.com/mitchellh/mapstructure v1.5.0
github.com/muesli/reflow v0.3.0
github.com/oapi-codegen/runtime v1.1.1
github.com/slack-go/slack v0.12.4
github.com/slack-go/slack v0.12.5
github.com/spf13/afero v1.11.0
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
github.com/stripe/pg-schema-diff v0.6.0
github.com/withfig/autocomplete-tools/packages/cobra v1.2.0
github.com/zalando/go-keyring v0.2.3
Expand Down Expand Up @@ -285,7 +285,7 @@ require (
github.com/spf13/cast v1.6.0 // indirect
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect
github.com/tdakkota/asciicheck v0.2.0 // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,8 @@ github.com/sivchari/tenv v1.7.1 h1:PSpuD4bu6fSmtWMxSGWcvqUUgIn7k3yOJhOIzVWn8Ak=
github.com/sivchari/tenv v1.7.1/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg=
github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ=
github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
github.com/slack-go/slack v0.12.4 h1:4iLT2opw+/QptmQxBNA7S8pNfSIvtn0NDGu7Jq0emi4=
github.com/slack-go/slack v0.12.4/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw=
github.com/slack-go/slack v0.12.5 h1:ddZ6uz6XVaB+3MTDhoW04gG+Vc/M/X1ctC+wssy2cqs=
github.com/slack-go/slack v0.12.5/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw=
github.com/sonatard/noctx v0.0.2 h1:L7Dz4De2zDQhW8S0t+KUjY0MAQJd6SgVwhzNIc4ok00=
github.com/sonatard/noctx v0.0.2/go.mod h1:kzFz+CzWSjQ2OzIm46uJZoXuBpa2+0y3T36U18dWqIo=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
Expand Down Expand Up @@ -908,8 +908,9 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
Expand All @@ -920,8 +921,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stripe/pg-schema-diff v0.6.0 h1:A/fSyNrj4uA3yHw8KPDlhfL+kaPYUmFpVmF+Hh7qISk=
github.com/stripe/pg-schema-diff v0.6.0/go.mod h1:NTdRinkrNDP9A0p1y9ioutRv0DOmjBcIwjpPnHW8sMY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
Expand Down
2 changes: 1 addition & 1 deletion internal/db/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func diffRemoteSchema(p utils.Program, ctx context.Context, schema []string, pat
if len(output) == 0 {
return errors.New(errInSync)
}
if err := afero.WriteFile(fsys, path, []byte(output), 0644); err != nil {
if err := utils.WriteFile(path, []byte(output), fsys); err != nil {
return errors.Errorf("failed to write dump file: %w", err)
}
return nil
Expand Down
1 change: 0 additions & 1 deletion internal/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,6 @@ EOF
"STUDIO_PG_META_URL=http://" + utils.PgmetaId + ":8080",
"POSTGRES_PASSWORD=" + dbConfig.Password,
"SUPABASE_URL=http://" + utils.KongId + ":8000",
fmt.Sprintf("SUPABASE_REST_URL=%s:%v/rest/v1/", utils.Config.Studio.ApiUrl, utils.Config.Api.Port),
fmt.Sprintf("SUPABASE_PUBLIC_URL=%s:%v/", utils.Config.Studio.ApiUrl, utils.Config.Api.Port),
"SUPABASE_ANON_KEY=" + utils.Config.Auth.AnonKey,
"SUPABASE_SERVICE_KEY=" + utils.Config.Auth.ServiceRoleKey,
Expand Down
17 changes: 15 additions & 2 deletions internal/start/templates/kong.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,29 @@ services:
add:
headers:
- "Content-Profile: graphql_public"
- name: realtime-v1
- name: realtime-v1-ws
_comment: "Realtime: /realtime/v1/* -> ws://realtime:4000/socket/*"
url: http://{{ .RealtimeId }}:4000/socket
protocol: ws
routes:
- name: realtime-v1-all
- name: realtime-v1-ws
strip_path: true
paths:
- /realtime/v1/
plugins:
- name: cors
- name: realtime-v1-rest
_comment: "Realtime: /realtime/v1/* -> http://realtime:4000/api/*"
url: http://{{ .RealtimeId }}:4000/api
protocol: http
routes:
- name: realtime-v1-rest
strip_path: true
paths:
- /realtime/v1/api
plugins:
- name: cors

- name: storage-v1
_comment: "Storage: /storage/v1/* -> http://storage-api:5000/*"
url: http://{{ .StorageId }}:5000/
Expand Down
6 changes: 3 additions & 3 deletions internal/utils/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ const (
DifferImage = "supabase/pgadmin-schema-diff:cli-0.0.5"
MigraImage = "supabase/migra:3.0.1663481299"
PgmetaImage = "supabase/postgres-meta:v0.79.0"
StudioImage = "supabase/studio:20240205-b145c86"
StudioImage = "supabase/studio:20240301-0942bfe"
ImageProxyImage = "darthsim/imgproxy:v3.8.0"
EdgeRuntimeImage = "supabase/edge-runtime:v1.36.7"
EdgeRuntimeImage = "supabase/edge-runtime:v1.38.0"
VectorImage = "timberio/vector:0.28.1-alpine"
PgbouncerImage = "bitnami/pgbouncer:1.20.1-debian-11-r39"
PgProveImage = "supabase/pg_prove:3.36"
GotrueImage = "supabase/gotrue:v2.143.0"
RealtimeImage = "supabase/realtime:v2.25.50"
RealtimeImage = "supabase/realtime:v2.25.66"
StorageImage = "supabase/storage-api:v0.46.4"
LogflareImage = "supabase/logflare:1.4.0"
// Should be kept in-sync with EdgeRuntimeImage
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"channel": "hotfix"
},
{
"name": "main",
"name": "develop",
"channel": "beta"
}
],
Expand Down
2 changes: 2 additions & 0 deletions tools/publish/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ func main() {
semver := flag.Arg(0)
if len(semver) == 0 {
log.Fatalln("Missing required arg: version")
} else if semver[0] == 'v' {
semver = semver[1:]
}

ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt)
Expand Down
Loading