Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,34 @@ jobs:
git checkout -b "$BRANCH"

# A merge, so the PR's diff is exactly what `production` changed.
#
# The version files can conflict: the last back-merge was squashed,
# so git still sees dev's and production's version lines as two
# separate edits (5.12.1 hit this). `production` holds what was just
# released, so its side is right for those three files. Any other
# conflict still stops the job for a human.
if ! git merge --no-ff origin/production -m "chore: merge production into dev after ${VERSION}"; then
echo "Back-merge of production into dev conflicts — resolve it by hand." >&2
git merge --abort || true
exit 1
conflicts=$(git diff --name-only --diff-filter=U)
others=$(grep -vxE 'package\.json|server\.json|CHANGELOG\.md' <<<"$conflicts" || true)
if [ -n "$others" ]; then
echo "::error::Back-merge of production into dev conflicts in $(paste -sd, - <<<"$others"). Resolve it by hand."
git merge --abort || true
exit 1
fi
# Hunk by hunk, not `checkout --theirs`: that would take production's
# whole file and drop anything else dev changed in it, such as a
# dependency bump in package.json.
# merge-file needs real files; it can't read process substitutions.
tmp=$(mktemp -d)
for f in $conflicts; do
git show ":1:$f" > "$tmp/base"
git show ":2:$f" > "$tmp/ours"
git show ":3:$f" > "$tmp/theirs"
git merge-file -p --theirs "$tmp/ours" "$tmp/base" "$tmp/theirs" > "$f"
done
echo "::notice::Took production's side of the conflicting lines in: $(paste -sd, - <<<"$conflicts")"
git add -- $conflicts
git commit --no-edit
fi

if git diff --quiet "origin/dev..HEAD"; then
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Full guide in `CONTRIBUTING.md`; the operationally important parts (the ones tha
| **stable** | every push to `dev` runs **Promote to stable** (`promote.yml`), which keeps one release PR into `production` current; merging it tags, publishes and uploads binaries | `X.Y.Z` | `latest` |
| **beta** | run **Release beta** (`release-beta.yml`) by hand from `dev` | `X.Y.Z-beta.N` | `beta` |

**Cutting a stable release.** You don't start one: you merge the open `chore: release X.Y.Z` PR from `promote/cli-next` into `production`. Use a **merge commit**, the only method `production` allows. That push runs `release-please.yml`. It finds an untagged version on `production`, tags it, and creates the GitHub Release from the changelog section. It then **chains** into `npm-publish.yml` and `release-binaries.yml` as `needs:` jobs, because a `GITHUB_TOKEN`-created release won't fire `release: published`. Last, it opens a **back-merge PR** into `dev`. `get.devicecloud.dev` serves the binaries by reading the GitHub Releases API at runtime, so there's no separate manifest to deploy. To hold a release, just don't merge the PR. Closing it doesn't pause releases, because the next push to `dev` opens a new one.
**Cutting a stable release.** You don't start one: you merge the open `chore: release X.Y.Z` PR from `promote/cli-next` into `production`. Use a **merge commit**, the only method `production` allows. That push runs `release-please.yml`. It finds an untagged version on `production`, tags it, and creates the GitHub Release from the changelog section. It then **chains** into `npm-publish.yml` and `release-binaries.yml` as `needs:` jobs, because a `GITHUB_TOKEN`-created release won't fire `release: published`. Last, it opens a **back-merge PR** into `dev`. If that merge conflicts only in `package.json`, `server.json` or `CHANGELOG.md`, it takes `production`'s side, which holds the version just released. A conflict in any other file stops the job, and you build the back-merge by hand. `get.devicecloud.dev` serves the binaries by reading the GitHub Releases API at runtime, so there's no separate manifest to deploy. To hold a release, just don't merge the PR. Closing it doesn't pause releases, because the next push to `dev` opens a new one.

**How the release PR is kept current.** `promote.yml` runs on every push to `dev`. It rebuilds `promote/cli-next` from `origin/dev`, with `origin/production` merged in, plus one `chore: release X.Y.Z` commit that sets the version in `package.json` and `server.json` and adds the `CHANGELOG.md` section. Then it force-pushes the branch and opens the PR, or updates the open one's title and body. So the PR always carries all of `dev`, and its version moves up as `feat`s land. A push with nothing releasable since the last release, such as a docs change or the back-merge, does nothing. If `production` moved during the run because a release just merged, the run pushes nothing, and the back-merge's push into `dev` rebuilds the PR. If an open PR into `production` came from another branch, push runs warn and leave it alone. The workflow can also be run by hand (`gh workflow run promote.yml --ref dev`, or the Actions tab) to set the `version`. `dry_run: true` shows the version and changelog in the run summary and pushes nothing. The `CHANGELOG.md` date is the day the PR was last rebuilt.

Expand Down
Loading