From 26739f4b635e6b058a4de7c116433a56700cd349 Mon Sep 17 00:00:00 2001 From: Tyler Gillispie Date: Sun, 23 Aug 2026 10:41:03 -0700 Subject: [PATCH] feat(infra): add release script, secrets verification, and dump subcommands to setup CLI --- deno.json | 7 ++- infra/release.sh | 56 +++++++++++++++++++++ infra/setup.ts | 126 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 188 insertions(+), 1 deletion(-) create mode 100755 infra/release.sh diff --git a/deno.json b/deno.json index 36d1d47..4ef6ee3 100644 --- a/deno.json +++ b/deno.json @@ -10,7 +10,12 @@ "fmt": "deno fmt", "check": "deno check server/**/*.ts sdk/**/*.ts ui/**/*.ts infra/**/*.ts", "test": "deno test -A", - "setup": "deno run -A infra/setup.ts" + "setup": "deno run -A infra/setup.ts", + "secrets": "deno run -A infra/setup.ts secrets", + "dump:compose": "deno run -A infra/setup.ts dump_compose", + "dump:env": "deno run -A infra/setup.ts dump_env", + "build": "deno run -A infra/setup.ts build", + "release": "./infra/release.sh" }, "lint": { "exclude": [ diff --git a/infra/release.sh b/infra/release.sh new file mode 100755 index 0000000..563650e --- /dev/null +++ b/infra/release.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# ============================================================================== +# Auth-Yes Full Infrastructure Build & Release Pipeline +# ============================================================================== +set -e + +# Change to repository root +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$REPO_ROOT" + +echo "================================================================" +echo " Auth-Yes Build & Release Pipeline" +echo "================================================================" + +# 1. Run Pre-flight Quality Gates +echo -e "\n[1/5] Running Quality Gates..." +deno fmt --check +deno task lint +deno task check +deno task test + +# 2. Compile Protobufs & Workload APIs +echo -e "\n[2/5] Compiling Protobufs..." +deno run -A infra/setup.ts compile_proto + +# 3. Generate Infrastructure Artifacts (Non-Interactive / Headless) +echo -e "\n[3/5] Generating Infrastructure Configuration Artifacts..." +deno run -A infra/setup.ts auth --auto \ + --registry "${REG:-quay.atyg.org}" \ + --ghcr-registry "${GHCR_REG:-ghcr.atyg.org}" \ + --domain "${SYSTEM_DOMAIN:-auth.atyg.org}" \ + --db-path "${DB_DATA_PATH:-/volume1/docker/auth-yes/data}" \ + --spire-path "${SPIRE_DATA_PATH:-/volume1/docker/spire}" + +# 4. Build & Push All Container Images to Registry +echo -e "\n[4/5] Building and Pushing Container Images..." +deno run -A infra/setup.ts build + +# 5. Output Summary, Persistence Topology, and Compose Stacks +echo -e "\n[5/5] Release Summary & Stack Specifications..." +deno run -A infra/setup.ts secrets + +echo -e "\n----------------------------------------------------------------" +echo " GENERATED DOCKER / PODMAN COMPOSE SPECIFICATIONS" +echo "----------------------------------------------------------------" +deno run -A infra/setup.ts dump_compose + +echo -e "\n================================================================" +echo " DEPLOYMENT COMMANDS" +echo "================================================================" +echo "1. Deploy SPIRE Authority Stack:" +echo " podman-compose --project-name spire --env-file infra/.env -f infra/compose.spire.yml up -d" +echo "" +echo "2. Deploy Auth-Yes IAM Stack:" +echo " podman-compose --project-name auth-yes --env-file infra/.env -f infra/compose.yml up -d" +echo "================================================================" diff --git a/infra/setup.ts b/infra/setup.ts index ea02b90..363811a 100644 --- a/infra/setup.ts +++ b/infra/setup.ts @@ -667,6 +667,132 @@ if (import.meta.main) { } Deno.exit(1); } + }) + .command("dump_compose", "Output all generated Compose YAML configurations") + .action(() => { + console.log( + colors.bold( + colors.blue( + "\n================================================================", + ), + ), + ); + console.log( + colors.bold( + colors.green(" STACK 1: Auth-Yes Stack (infra/compose.yml)"), + ), + ); + console.log( + colors.bold( + colors.blue( + "================================================================\n", + ), + ), + ); + console.log(generateDockerCompose()); + console.log( + colors.bold( + colors.blue( + "================================================================", + ), + ), + ); + console.log( + colors.bold( + colors.green( + " STACK 2: Standalone SPIRE Stack (infra/compose.spire.yml)", + ), + ), + ); + console.log( + colors.bold( + colors.blue( + "================================================================\n", + ), + ), + ); + console.log(generateSpireDockerCompose()); + }) + .command("dump_env", "Output current environment configuration (.env)") + .action(async () => { + const loadedEnv = await readEnv(); + const currentConfig: AuthSetupConfig = { + ...DEFAULT_AUTH_CONFIG, + ...loadedEnv, + }; + console.log( + colors.bold( + colors.blue( + "\n================================================================", + ), + ), + ); + console.log( + colors.bold( + colors.green(" ENVIRONMENT CONFIGURATION (infra/.env)"), + ), + ); + console.log( + colors.bold( + colors.blue( + "================================================================\n", + ), + ), + ); + console.log(generateEnv(currentConfig)); + }) + .command("secrets", "Inspect secrets status and persistence paths") + .action(async () => { + const loadedEnv = await readEnv(); + const currentConfig: AuthSetupConfig = { + ...DEFAULT_AUTH_CONFIG, + ...loadedEnv, + }; + console.log( + colors.bold( + colors.blue( + "\n=== Auth-Yes Secrets & Persistence Topology ===\n", + ), + ), + ); + console.log( + `${ + colors.cyan("Database Persistence Path:") + } ${currentConfig.dbDataPath}`, + ); + console.log( + `${ + colors.cyan("SPIRE Persistence Path:") + } ${currentConfig.spireDataPath}`, + ); + console.log( + `${ + colors.cyan("Local Artifact Files:") + } ${ENV_PATH}, ${COMPOSE_PATH}, ${SPIRE_COMPOSE_PATH}`, + ); + console.log( + `${colors.cyan("PostgreSQL Password:")} ${ + currentConfig.dbPassword + ? colors.green( + "✓ Configured (len: " + currentConfig.dbPassword.length + ")", + ) + : colors.red("✗ Missing") + }`, + ); + console.log( + `${colors.cyan("Application Secret:")} ${ + currentConfig.appSecret + ? colors.green( + "✓ Configured (len: " + currentConfig.appSecret.length + ")", + ) + : colors.red("✗ Missing") + }`, + ); + console.log( + colors.gray( + "\nTip: To dump raw environment variables, run: deno run -A infra/setup.ts dump_env\n", + ), + ); }); await cmd.parse(Deno.args);