Skip to content

armgit / crm

Public Imported from GitHub
0

Comp AI CRM is an open source, CRM designed for AI agents. Agentic-first CRM.

TypeScript

fix(ci): make a release one pull request instead of two

Lewis Carhart206c7461e75e
diff --git a/.github/release-please-config.json b/.github/release-please-config.json
index e17d8c90..f45adbbc 100644
--- a/.github/release-please-config.json
+++ b/.github/release-please-config.json
@@ -26,5 +26,5 @@
},
"bootstrap-sha": "64f154b086cbad6cac232357dc21c954543ef217",
"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."
+ "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. Merging it tags the release and puts that commit on `release`, so it is live — there is nothing else to merge."
}
diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml
deleted file mode 100644
index 9b59a69e..00000000
--- a/.github/workflows/promote.yml
+++ /dev/null
@@ -1,66 +0,0 @@
-name: Promote
-
-on:
- push:
- branches: [main]
- workflow_dispatch:
-
-concurrency:
- group: promote
- cancel-in-progress: false
-
-permissions:
- contents: read
- pull-requests: write
-
-jobs:
- promote:
- name: Pull request from main into release
- runs-on: ubuntu-24.04
- timeout-minutes: 5
- steps:
- - uses: actions/checkout@v5
- with:
- fetch-depth: 0
-
- - name: Open or update the promotion pull request
- env:
- GH_TOKEN: ${{ secrets.AUTOMATION_TOKEN || secrets.GITHUB_TOKEN }}
- run: |
- set -euo pipefail
-
- if [ "$(git rev-list --count origin/release..origin/main)" = "0" ]; then
- echo "\`release\` already has everything on \`main\`." >> "$GITHUB_STEP_SUMMARY"
- exit 0
- fi
-
- pending=$(gh pr list --base main --state open --label "autorelease: pending" --limit 1 --json number,title --jq '.[0] | select(.) | "#\(.number) \(.title)"')
-
- if [ -n "$pending" ]; then
- warning="**Merge $pending first.** It is the release pull request: it writes the changelog, bumps the version and cuts the tag on \`main\`. Merge it before this one and the tag lands on a commit \`release\` receives. Merge this one first and you ship the code untagged, and the version does not reach \`release\` until the next promotion."
- else
- warning="Nothing releasable is waiting — no version bump will ride along with this."
- fi
-
- body=$(cat <<EOF
- Everything on \`main\` that \`release\` does not have yet. Merging this is what puts it in
- front of users, because \`release\` is what a deploy and a plain clone both point at.
-
- $warning
-
- Merge it with a **merge commit**, not a squash: a squash would give \`release\` a new
- commit of its own, and the tags on \`main\` would stop being ancestors of what you shipped.
-
- $(git log origin/release..origin/main --no-merges --reverse --format='- %s')
- EOF
- )
-
- existing=$(gh pr list --base release --head main --state open --limit 1 --json number --jq '.[0].number // ""')
-
- if [ -n "$existing" ]; then
- gh pr edit "$existing" --body "$body"
- echo "Updated promotion pull request #$existing." >> "$GITHUB_STEP_SUMMARY"
- else
- gh pr create --base release --head main --title "release: promote main" --body "$body"
- echo "Opened a promotion pull request into \`release\`." >> "$GITHUB_STEP_SUMMARY"
- fi
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 59023368..69d23b2a 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -27,18 +27,49 @@ jobs:
target-branch: main
token: ${{ secrets.AUTOMATION_TOKEN || secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }}
- - name: Say what happened
+ - name: Put the tag on release
+ if: steps.release.outputs.tag_name
env:
+ GH_TOKEN: ${{ secrets.AUTOMATION_TOKEN || secrets.GITHUB_TOKEN }}
TAG: ${{ steps.release.outputs.tag_name }}
+ SHA: ${{ steps.release.outputs.sha }}
URL: ${{ steps.release.outputs.html_url }}
run: |
set -euo pipefail
- if [ -n "${TAG:-}" ]; then
- echo "Released [$TAG]($URL) — merge the promotion pull request to put it on \`release\`." >> "$GITHUB_STEP_SUMMARY"
- else
- echo "No tag this run — either the release pull request is still open, or nothing releasable landed." >> "$GITHUB_STEP_SUMMARY"
+
+ if out=$(gh api "repos/$GITHUB_REPOSITORY/merges" \
+ -f base=release \
+ -f head="$SHA" \
+ -f commit_message="release: $TAG" 2>&1); then
+ echo "Released [$TAG]($URL) and put it on \`release\`. It is live." >> "$GITHUB_STEP_SUMMARY"
+ exit 0
fi
+ case "$out" in
+ *"Already merged"* | *"Nothing to merge"*)
+ echo "Released [$TAG]($URL); \`release\` already had it." >> "$GITHUB_STEP_SUMMARY"
+ ;;
+ *)
+ {
+ echo "**[$TAG]($URL) is tagged but did not reach \`release\`.**"
+ echo
+ echo "\`\`\`"
+ echo "$out"
+ echo "\`\`\`"
+ echo
+ echo "\`release\` only ever receives \`main\`, so this means somebody committed to it"
+ echo "directly. Reconcile the two branches, then re-run this workflow from the Actions tab."
+ } >> "$GITHUB_STEP_SUMMARY"
+ exit 1
+ ;;
+ esac
+
+ - name: Say what happened
+ if: ${{ !steps.release.outputs.tag_name }}
+ run: |
+ set -euo pipefail
+ echo "No tag this run — either the release pull request is still open, or nothing releasable landed." >> "$GITHUB_STEP_SUMMARY"
+
- name: Fail on a merged release pull request that was never tagged
env:
GH_TOKEN: ${{ secrets.AUTOMATION_TOKEN || secrets.GITHUB_TOKEN }}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e3f0b623..e91c3a18 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -90,13 +90,11 @@ push a branch ──▶ PR opens by itself, titled from the diff
│
◀── click 1: squash into main
│
- two pull requests open, and stay open, together
+ one pull request opens, and stays open and current
`chore(main): release 0.2.0` ──▶ main
- `release: promote main` ──▶ release
│
- ◀── click 2: the release PR — tag, notes, CHANGELOG.md
- │
- ◀── click 3: the promotion PR — `release` moves up
+ ◀── click 2: tag, notes, CHANGELOG.md — and the tagged
+ commit lands on `release` on its own, so it is live
```
**Pushing any branch that isn't `main` or `release` opens a pull request into `main`.** You do not
@@ -136,37 +134,33 @@ because the squashed commit body is left empty on purpose — the title is the w
## Releases
-Nothing is released by merging to `main`, and nothing is pushed to `release` by hand. Both branches
-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 use
-them — so the version you are about to cut is readable *before* you decide to ship it.
-
-**The release pull request — `chore(main): release 0.2.0`, into `main`.**
-[release-please](https://github.com/googleapis/release-please) accumulates every releasable commit
-into this one. Merging it writes `CHANGELOG.md`, bumps the version, tags `v0.2.0` and publishes the
-GitHub Release. The notes are reviewable before they are public, and a stack of merges is one
-release rather than five.
+**Shipping is one pull request.** `chore(main): release 0.2.0`, into `main`, opened and kept up to
+date by [release-please](https://github.com/googleapis/release-please) as soon as something
+releasable lands. It accumulates every releasable commit, so a stack of merges is one release
+rather than five, and the notes are readable *before* you decide to ship them.
-**The promotion pull request — `release: promote main`, into `release`.** Its body is the list of
-commits `release` does not have yet, so it is a standing answer to "what is waiting to ship".
-**Merge it with a merge commit, not a squash** — `release` only permits that method, because a
-squash would give `release` a commit of its own and the tags on `main` would stop being ancestors
-of what you shipped.
+Merging it writes `CHANGELOG.md`, bumps the version, tags `v0.2.0`, publishes the GitHub Release
+— and then the workflow merges that exact tagged commit into `release`, which is what a deploy and
+a plain clone both point at. **Nothing else to merge, and no order to remember.**
-**Merge the release one first.** Then the tag sits on a commit the promotion carries over, and
-`release` gets the code and its version together. The other order still works — it just ships
-untagged code and leaves the bump for the next promotion.
+It used to be two pull requests, the release one and a `release: promote main`, with a warning on
+the promotion telling you to merge the other one first. Get that order wrong and you shipped
+untagged code and left the version behind for the next promotion. There is no reason a human should
+hold that rule in their head: the tag and the code have to travel together, so the automation does
+it in one step. **`release` is only ever written by that step** — the tag it carries is by
+construction an ancestor of what you shipped.
Three consequences worth knowing:
- **A release PR with nothing in it is not a bug.** A run of `chore:` and `test:` commits bumps
- nothing, so no PR appears. That is the type doing its job.
-- **Neither automated PR runs CI.** A PR opened by `GITHUB_TOKEN` cannot trigger workflows — that is
- GitHub's own loop guard, not something to work around. The promotion PR does not care, because
- `release` has no required checks and the code was already green on `main`. The release PR targets
- `main`, which does have them, so **an admin merges it past the missing checks** — safe, because it
- only ever touches `CHANGELOG.md`, the root `version` and the manifest, none of which CI can judge.
+ nothing, so no PR appears. That is the type doing its job. It also means those commits **do not
+ reach production until the next release carries them** — `release` now moves only when a tag is
+ cut. If something has to ship, give it a type that releases: a `fix:` is the floor. Anything that
+ genuinely changes nothing for a user is not urgent, and anything urgent is not a `chore:`.
+- **The release PR does not run CI.** A PR opened by `GITHUB_TOKEN` cannot trigger workflows — that
+ is GitHub's own loop guard, not something to work around. It targets `main`, which has required
+ checks, so **an admin merges it past the missing ones** — safe, because it only ever touches
+ `CHANGELOG.md`, the root `version` and the manifest, none of which CI can judge.
- **`AUTOMATION_TOKEN` removes that click.** A PAT or GitHub App token in that secret makes the
automated PRs trigger CI like any other; every workflow already prefers it and falls back to
`GITHUB_TOKEN`. A branch you push yourself never needed it — your own push triggers CI and the
diff --git a/docs/setup.md b/docs/setup.md
index e953fcc0..28c1410d 100644
--- a/docs/setup.md
+++ b/docs/setup.md
@@ -102,7 +102,7 @@ the live database. On 2026-08-01 eleven migrations landed on Neon from a laptop.
`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,
+release 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