Comp AI CRM is an open source, CRM designed for AI agents. Agentic-first CRM.
TypeScript
fix(ci): tag releases automatically and keep previews off the production schema (#82)
github-actions[bot]6078a84b4fa4
diff --git a/.github/release-please-config.json b/.github/release-please-config.jsonindex 445bd643..e17d8c90 100644--- a/.github/release-please-config.json+++ b/.github/release-please-config.json@@ -25,7 +25,6 @@}},"bootstrap-sha": "64f154b086cbad6cac232357dc21c954543ef217",- "separate-pull-requests": false,- "pull-request-title-pattern": "chore(release): ${version}",+ "separate-pull-requests": true,"pull-request-header": "The changelog below is what will be published as the release notes. Edit the commit subjects, not this PR body — the body is regenerated on every push to main. Merge this before the promotion pull request, so the tag lands on the commit `release` receives."}diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex b03343e7..ba911a7d 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -38,3 +38,23 @@ jobs:elseecho "No tag this run — either the release pull request is still open, or nothing releasable landed." >> "$GITHUB_STEP_SUMMARY"fi++ - name: Fail on a merged release pull request that was never tagged+ env:+ GH_TOKEN: ${{ secrets.AUTOMATION_TOKEN || secrets.GITHUB_TOKEN }}+ run: |+ set -euo pipefail++ stuck=$(gh pr list --repo "$GITHUB_REPOSITORY" --base main --state merged --label "autorelease: pending" --limit 1 --json number,title --jq '.[0] | select(.) | "#\(.number) \(.title)"')++ if [ -z "$stuck" ]; then+ exit 0+ fi++ {+ echo "**$stuck merged without a tag.** release-please aborts on it, so nothing releases and no release"+ echo "pull request opens until it is cleared: create the tag and GitHub Release at that pull request's"+ echo "merge commit, then swap its \`autorelease: pending\` label for \`autorelease: tagged\`."+ } >> "$GITHUB_STEP_SUMMARY"++ exit 1diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 6105fee6..9a0ed91b 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -81,7 +81,7 @@ push a branch ──▶ PR opens by itself, titled from the diff◀── click 1: squash into main│two pull requests open, and stay open, together- `chore(release): 0.2.0` ──▶ main+ `chore(main): release 0.2.0` ──▶ main`release: promote main` ──▶ release│◀── click 2: the release PR — tag, notes, CHANGELOG.md@@ -132,7 +132,7 @@ only ever move through a pull request, and shipping is two of them.Both open as soon as something lands on `main`, and both stay open and up to date until you usethem — so the version you are about to cut is readable *before* you decide to ship it.-**The release pull request — `chore(release): 0.2.0`, into `main`.**+**The release pull request — `chore(main): release 0.2.0`, into `main`.**[release-please](https://github.com/googleapis/release-please) accumulates every releasable commitinto this one. Merging it writes `CHANGELOG.md`, bumps the version, tags `v0.2.0` and publishes theGitHub Release. The notes are reviewable before they are public, and a stack of merges is one@@ -168,17 +168,24 @@ release workflow, which cannot wait on a run in another workflow.### When it jams-The Release workflow reports success even when it has done nothing, so the symptom of a jam is-silence: merges land, no release PR appears. Read the log rather than the status. Two failures have-actually happened here:+A jam used to be silent — the workflow reported success while doing nothing, and the symptom was+merges landing with no release PR behind them. **The workflow now fails when a merged release PR+carries `autorelease: pending`**, which is the state every jam ends in, so the Actions tab tells you+within a minute of the merge that shipped it. Read the log rather than the status anyway. Two+failures have actually happened here:- **`There are untagged, merged release PRs outstanding - aborting`.** A release PR was merged butnever tagged, and release-please refuses to move past it — every later run aborts on the same PR,which is how this repo sat from `v1.0.0` in August with no tags at all. Fix it by hand: create thetag and GitHub Release at the release PR's merge commit, then swap that PR's`autorelease: pending` label for `autorelease: tagged`. The next run picks up where it left off.- The usual cause is a release PR whose title does not match `pull-request-title-pattern`, because- the version is parsed back out of that title — so do not edit the pattern with a release PR open.+ The cause was `separate-pull-requests: false` with one package: the Merge plugin renamed the+ release branch from `release-please--branches--main--components--crm` to+ `release-please--branches--main`, and the tagging step reads the component back out of that branch+ name and compares it against the package name. `undefined` never equalled `crm`, so nothing was+ ever tagged automatically — `v1.0.0` through `v1.3.0` were all cut by hand. **A second package+ will bring the Merge plugin back**, and with it this bug: give the packages components in the tag,+ or check that a merged release PR still gets `autorelease: tagged`.- **`commit could not be parsed`, in bulk.** Non-conventional subjects reached `main`. They are noterrors, they are silently missing changelog lines. The squash-only merge policy and the`conventional commit` check exist to stop this; if you see it again, one of the two has beendiff --git a/apps/api/scripts/build-func.mjs b/apps/api/scripts/build-func.mjsindex 122215a0..25740c26 100644--- a/apps/api/scripts/build-func.mjs+++ b/apps/api/scripts/build-func.mjs@@ -164,7 +164,9 @@ writeFileSync(console.log(`✓ built ${outDir}`);-const directDatabaseUrl = !process.env.VERCEL+const isProductionDeployment = process.env.VERCEL_ENV === "production";++const directDatabaseUrl = !isProductionDeployment? undefined: process.env.DIRECT_DATABASE_URL ||process.env.POSTGRES_URL_NON_POOLING ||@@ -173,6 +175,10 @@ const directDatabaseUrl = !process.env.VERCELif (!process.env.VERCEL) {console.log("• not a Vercel build — skipping migrations");+} else if (!isProductionDeployment) {+ console.log(+ `• ${process.env.VERCEL_ENV || "non-production"} deployment — skipping migrations, only production applies them`,+ );} else if (!directDatabaseUrl) {console.log("• no database URL at build time — skipping migrations");} else {diff --git a/docs/setup.md b/docs/setup.mdindex 01200dff..a3e398b8 100644--- a/docs/setup.md+++ b/docs/setup.md@@ -98,6 +98,21 @@ the live database. On 2026-08-01 eleven migrations landed on Neon from a laptop.auto-loads the working directory's `.env` while Prisma's CLI only sees`@crm/env/load`.+## Migrations run on the production deploy, and nowhere else++`apps/api/scripts/build-func.mjs` runs `prisma migrate deploy` during the crm-api+build, gated on `VERCEL_ENV === "production"`. The schema therefore moves when the+promotion pull request merges and `release` deploys — with the code that needs it,+and once rather than once per branch.++Preview deploys share the production database: `DATABASE_URL` is a single value+across production, preview and development. Until that changes, **a preview of a+branch that adds a migration runs against a database without those tables** — it+builds, and the pages that touch them fail. Test schema changes locally, where+`bun run dev` migrates for you. Before the gate existed the reverse was true and+worse: every preview applied its own migrations to the production database, so on+2026-08-07 the live schema ran six migrations ahead of the live code all day.+## Secrets hygiene`.gitignore` ignores `.env` and `.env.*` with one negation for `.env.example`, so