From 84d2bbd35f0d95be091b5f24d38a9fd6a193de04 Mon Sep 17 00:00:00 2001 From: evgeny Date: Wed, 25 Mar 2026 16:30:01 +0000 Subject: [PATCH] feat: add release automation command `/release` with version bump and CHANGELOG update logic --- .claude/commands/release.md | 53 +++++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 20 +++++--------- 2 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 .claude/commands/release.md diff --git a/.claude/commands/release.md b/.claude/commands/release.md new file mode 100644 index 000000000..2b9d23cd7 --- /dev/null +++ b/.claude/commands/release.md @@ -0,0 +1,53 @@ +--- +description: "Create a release branch, bump version, and update CHANGELOG. Usage: /release patch|minor|major" +allowed-tools: Bash, Read, Edit, Write +--- + +Read the current version from `gradle.properties` (the `VERSION_NAME` property). + +The bump type is: $ARGUMENTS + +Compute the new version by incrementing the appropriate component of the current version: +- `patch` — increment the third number, keep major and minor (e.g. 1.7.0 → 1.7.1) +- `minor` — increment the second number, reset patch to 0 (e.g. 1.7.0 → 1.8.0) +- `major` — increment the first number, reset minor and patch to 0 (e.g. 1.7.0 → 2.0.0) + +Then perform these steps in order: + +1. Run `git checkout -b release/NEW_VERSION` +2. Replace `OLD_VERSION` with `NEW_VERSION` in all of the following files: + - `gradle.properties` — the `VERSION_NAME` property + - `README.md` — 3 places: Maven ``, Gradle `implementation '…'`, and LiveObjects `runtimeOnly("…")` + - `CONTRIBUTING.md` — the `implementation files('libs/ably-android-OLD_VERSION.aar')` line + - `lib/src/test/java/io/ably/lib/test/realtime/RealtimeHttpHeaderTest.java` — the hardcoded `"ably-java/OLD_VERSION"` string in the agent header assertion + Commit all five files together with message: `chore: bump version to NEW_VERSION` +3. Fetch merged PRs since the last release tag using: + ``` + gh pr list --state merged --base main --json number,title,mergedAt --limit 200 + ``` + Then get the date of the last release tag with: + ``` + git log vOLD_VERSION --format="%aI" -1 + ``` + Filter the PRs to only those merged after that tag date. Format each as: + ``` + - Short, one sentence summary from PR title and description [#NUMBER](https://github.com/ably/ably-java/pull/NUMBER) + ``` + If the tag doesn't exist or there are no merged PRs, use a single `-` placeholder bullet instead. + +4. In `CHANGELOG.md`, insert the following block immediately after the `# Change Log` heading (and its trailing blank line), before the first existing `## [` version entry: + +``` +## [NEW_VERSION](https://github.com/ably/ably-java/tree/vNEW_VERSION) + +[Full Changelog](https://github.com/ably/ably-java/compare/vOLD_VERSION...vNEW_VERSION) + +### What's Changed + +BULLETS_FROM_STEP_3 + +``` + +5. Commit `CHANGELOG.md` with message: `docs: update CHANGELOG for NEW_VERSION release` + +After completing all steps, show the user a summary of what was done. If PRs were found, list them. If the placeholder `-` was used instead, remind them to fill in the `### What's Changed` bullet points in `CHANGELOG.md` before merging. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a22137143..292ae524d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -244,19 +244,13 @@ implementation files('libs/ably-android-1.7.0.aar') This library uses [semantic versioning](http://semver.org/). For each release, the following needs to be done: -1. Create a branch for the release, named like `release/1.2.4` (where `1.2.4` is what you're releasing, being the new version) -2. Replace all references of the current version number with the new version number (check the [README.md](./README.md) and [gradle.properties](./gradle.properties)) and commit the changes -3. Run [`github_changelog_generator`](https://github.com/github-changelog-generator/github-changelog-generator) to automate the update of the [CHANGELOG](./CHANGELOG.md). This may require some manual intervention, both in terms of how the command is run and how the change log file is modified. Your mileage may vary: - - The command you will need to run will look something like this: `github_changelog_generator -u ably -p ably-java --since-tag v1.2.3 --output delta.md --token $GITHUB_TOKEN_WITH_REPO_ACCESS`. Generate token [here](https://github.com/settings/tokens/new?description=GitHub%20Changelog%20Generator%20token). - - Using the command above, `--output delta.md` writes changes made after `--since-tag` to a new file. - - The contents of that new file (`delta.md`) then need to be manually inserted at the top of the `CHANGELOG.md`, changing the "Unreleased" heading and linking with the current version numbers. - - Also ensure that the "Full Changelog" link points to the new version tag instead of the `HEAD`. -4. Commit [CHANGELOG](./CHANGELOG.md) -5. Make a PR against `main` -6. Once the PR is approved, merge it into `main` -7. Create the release and the release tag on Github including populating the release notes -8. Use the [GitHub action](https://github.com/ably/ably-java/actions/workflows/release.yaml) to publish the release. Run the workflow on the latest release tag. -9. Create the entry on the [Ably Changelog](https://changelog.ably.com/) (via [headwayapp](https://headwayapp.co/)) +1. Run `/release patch|minor|major` in Claude Code — this creates the release branch, bumps the version in all required files, and populates the [CHANGELOG](./CHANGELOG.md) with merged PRs since the last tag automatically +2. Review the `### What's Changed` entries in [CHANGELOG.md](./CHANGELOG.md) and adjust if needed, then commit any edits +3. Make a PR against `main` +4. Once the PR is approved, merge it into `main` +5. Create the release and the release tag on Github including populating the release notes +6. Use the [GitHub action](https://github.com/ably/ably-java/actions/workflows/release.yaml) to publish the release. Run the workflow on the latest release tag. +7. Create the entry on the [Ably Changelog](https://changelog.ably.com/) (via [headwayapp](https://headwayapp.co/)) ### Signing