Comp AI CRM is an open source, CRM designed for AI agents. Agentic-first CRM.
TypeScript
fix(ci): ship releases by opening a pull request into release (#114)
github-actions[bot]924060bac114
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex dd407cd5..0350ec94 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -27,42 +27,59 @@ jobs:target-branch: maintoken: ${{ secrets.AUTOMATION_TOKEN || secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }}+ # `release` carries a ruleset that requires a pull request, and the only+ # bypass is the admin role. So this cannot push a merge commit itself:+ # the REST `merges` API writes straight to the branch, the ruleset refused+ # it, and every tag from v1.6.1 on was cut on `main` and never shipped —+ # production sat on whatever pull request last reached `release` by hand.+ # A pull request from `main` is the one door that is open, which is also+ # what `pr-base.yml` assumes when it leaves a `main` head alone.- name: Put the tag on release- if: steps.release.outputs.tag_name+ if: steps.release.outputs.tag_name || github.event_name == 'workflow_dispatch'env:GH_TOKEN: ${{ secrets.AUTOMATION_TOKEN || secrets.GITHUB_TOKEN }}+ GH_REPO: ${{ github.repository }}TAG: ${{ steps.release.outputs.tag_name }}- SHA: ${{ steps.release.outputs.sha || github.sha }}URL: ${{ steps.release.outputs.html_url }}run: |set -euo pipefail- 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"+ tag="${TAG:-$(gh release view --json tagName --jq .tagName)}"+ url="${URL:-$(gh release view "$tag" --json url --jq .url)}"++ if [ "$(gh api "repos/$GH_REPO/compare/release...main" --jq .ahead_by)" = "0" ]; then+ echo "Released [$tag]($url); \`release\` already had it." >> "$GITHUB_STEP_SUMMARY"exit 0fi- 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+ number=$(gh pr list --base release --head main --state open --limit 1 --json number --jq '.[0].number // empty')++ if [ -z "$number" ]; then+ gh pr create --base release --head main \+ --title "release: $tag" \+ --body "Puts [$tag]($url) on \`release\`, which is the branch production deploys from. Opened by the Release workflow."+ number=$(gh pr list --base release --head main --state open --limit 1 --json number --jq '.[0].number')+ fi++ for _ in 1 2 3 4 5; do+ if out=$(gh pr merge "$number" --merge 2>&1); then+ echo "Released [$tag]($url) and put it on \`release\` in #$number. It is live." >> "$GITHUB_STEP_SUMMARY"+ exit 0+ fi+ sleep 5+ done++ {+ echo "**[$tag]($url) is tagged but did not reach \`release\`.**"+ echo+ echo "#$number is open and merging it ships this release."+ echo+ echo "\`\`\`"+ echo "$out"+ echo "\`\`\`"+ } >> "$GITHUB_STEP_SUMMARY"++ exit 1- name: Say what happenedif: ${{ !steps.release.outputs.tag_name }}diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 56cdf11f..0c58b41a 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -153,8 +153,17 @@ releasable lands. It accumulates every releasable commit, so a stack of merges irather than five, and the notes are readable *before* you decide to ship them.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.**+— and then the workflow opens a `release: v0.2.0` pull request from `main` into `release` and+merges it, which is what a deploy and a plain clone both point at. **Nothing else to merge, and no+order to remember**: that pull request opens and closes inside the same run, and you see it only in+the branch's history.++**It has to be a pull request, not a push.** `release` carries a ruleset that requires one, and the+only bypass is the admin role — which `GITHUB_TOKEN` does not have. The step used to call the REST+`merges` API, which writes a merge commit straight to the branch, so the ruleset refused it: every+tag from `v1.6.1` to `v1.8.0` was cut on `main`, published, and never shipped, while production sat+on the last pull request that had reached `release` by hand. The failure was quiet in the worst way+— the release itself looked perfect, and only the Vercel dashboard's commit line said otherwise.It used to be two pull requests, the release one and a `release: promote main`, with a warning onthe promotion telling you to merge the other one first. Get that order wrong and you shipped