136 lines
4.8 KiB
YAML
136 lines
4.8 KiB
YAML
# Release: publish the three registry images the federated suite pulls.
|
|
#
|
|
# Trigger: semver tags WITHOUT a v prefix (the suite's VERSION_RX is
|
|
# '^[0-9][0-9\.]*$'), e.g. 1.0.0. Every release pushes:
|
|
# federatedcomputer/superbrain-app:<tag> + :latest
|
|
# federatedcomputer/superbrain-web:<tag> + :latest
|
|
# federatedcomputer/superbrain-migrate:<tag> + :latest
|
|
# all three sharing the same version tag (house tooling tracks one version
|
|
# per app), for linux/amd64 and linux/arm64.
|
|
#
|
|
# Required secrets: DOCKERHUB_USERNAME, DOCKERHUB_TOKEN (an access token
|
|
# scoped to the federatedcomputer namespace).
|
|
#
|
|
# The publish job is gated on the smoke job: the migrate image is actually
|
|
# bootstrapped against a throwaway PostgreSQL (fresh schema + full ledger +
|
|
# idempotent re-run) before anything is pushed, so a broken db/ can never
|
|
# reach a tag the upgrade flow will pull.
|
|
|
|
name: release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- '[0-9]+.[0-9]+.[0-9]+'
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
smoke:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: postgres:16.15-alpine
|
|
env:
|
|
POSTGRES_USER: superbrain
|
|
POSTGRES_PASSWORD: smoke-only
|
|
POSTGRES_DB: superbrain
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd "pg_isready -U superbrain"
|
|
--health-interval 3s
|
|
--health-timeout 3s
|
|
--health-retries 20
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Go build + vet + unit tests (DB suites skipped without TEST_DATABASE_URL)
|
|
run: |
|
|
go build ./internal/... .
|
|
go vet ./internal/... .
|
|
go test ./internal/...
|
|
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build the migrate image
|
|
run: |
|
|
docker buildx build --load --build-context deploy=deploy/federated \
|
|
-t superbrain-migrate:smoke db/
|
|
# Hosts install/update from these baked files — they must be there.
|
|
docker run --rm superbrain-migrate:smoke sh -c \
|
|
'for f in install.sh update.sh lib-superbrain.sh service upgrade-pre; do test -f /deploy/$f || { echo "missing /deploy/$f"; exit 1; }; done'
|
|
|
|
- name: Bootstrap a fresh database with the image
|
|
run: |
|
|
docker run --rm --network host \
|
|
-e DB_HOST=127.0.0.1 -e PGPASSWORD=smoke-only \
|
|
superbrain-migrate:smoke
|
|
tables=$(docker run --rm --network host -e PGPASSWORD=smoke-only \
|
|
postgres:16.15-alpine psql -h 127.0.0.1 -U superbrain -d superbrain \
|
|
-t -A -c "SELECT count(*) FROM information_schema.tables WHERE table_schema='public'")
|
|
ledger=$(docker run --rm --network host -e PGPASSWORD=smoke-only \
|
|
postgres:16.15-alpine psql -h 127.0.0.1 -U superbrain -d superbrain \
|
|
-t -A -c "SELECT count(*) FROM _migration")
|
|
files=$(ls db/migrations/*.sql | wc -l)
|
|
echo "tables=$tables ledger=$ledger files=$files"
|
|
[ "$tables" -ge 20 ] || { echo "schema.sql did not apply"; exit 1; }
|
|
[ "$ledger" = "$files" ] || { echo "ledger incomplete"; exit 1; }
|
|
|
|
- name: Re-run must be a no-op (idempotency)
|
|
run: |
|
|
docker run --rm --network host \
|
|
-e DB_HOST=127.0.0.1 -e PGPASSWORD=smoke-only \
|
|
superbrain-migrate:smoke | grep -q "up to date"
|
|
|
|
publish:
|
|
needs: smoke
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Push superbrain-app
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: |
|
|
federatedcomputer/superbrain-app:${{ github.ref_name }}
|
|
federatedcomputer/superbrain-app:latest
|
|
|
|
- name: Push superbrain-web
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: web
|
|
file: web/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: |
|
|
federatedcomputer/superbrain-web:${{ github.ref_name }}
|
|
federatedcomputer/superbrain-web:latest
|
|
|
|
- name: Push superbrain-migrate
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: db
|
|
file: db/Dockerfile
|
|
build-contexts: |
|
|
deploy=deploy/federated
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: |
|
|
federatedcomputer/superbrain-migrate:${{ github.ref_name }}
|
|
federatedcomputer/superbrain-migrate:latest
|