Skip to content

Commit 2937085

Browse files
authored
fix: improve hotfix flow (#2523)
1 parent 8f4ebc0 commit 2937085

File tree

2 files changed

+13
-76
lines changed

2 files changed

+13
-76
lines changed

.github/workflows/on-pull-requests.yml

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -85,61 +85,6 @@ jobs:
8585
echo "::error::❄️ Release freeze is active. Merging release-please PRs is blocked."
8686
exit 1
8787
88-
version-clash-check:
89-
name: Version Clash Check
90-
# Only run on release-please PRs
91-
if: github.event_name == 'pull_request' && startsWith(github.head_ref, 'release-please--')
92-
runs-on: ubuntu-latest
93-
permissions:
94-
contents: read
95-
steps:
96-
- name: Checkout repository
97-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
98-
with:
99-
fetch-depth: 0
100-
persist-credentials: false
101-
102-
- name: Extract version from PR title
103-
id: extract-version
104-
env:
105-
PR_TITLE: ${{ github.event.pull_request.title }}
106-
run: |
107-
# PR title format: "chore(main): release platform vX.Y.Z" or "chore(release/vX.Y.Z): release platform vX.Y.Z"
108-
VERSION=$(echo "$PR_TITLE" | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | tail -1)
109-
if [ -z "$VERSION" ]; then
110-
echo "⚠️ Could not extract version from PR title: $PR_TITLE"
111-
echo "version=" >> "$GITHUB_OUTPUT"
112-
else
113-
echo "📦 Extracted version: $VERSION"
114-
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
115-
fi
116-
117-
- name: Check if version tag already exists
118-
if: steps.extract-version.outputs.version != ''
119-
env:
120-
VERSION: ${{ steps.extract-version.outputs.version }}
121-
BASE_REF: ${{ github.base_ref }}
122-
run: |
123-
# Check if the tag already exists
124-
if git rev-parse "platform-$VERSION" >/dev/null 2>&1; then
125-
echo "::error::❌ Version clash detected! Tag 'platform-$VERSION' already exists."
126-
echo ""
127-
echo "This usually happens when a hotfix release was created while this PR was open."
128-
echo ""
129-
echo "To fix this, bump the version on your target branch:"
130-
echo ""
131-
echo " git checkout $BASE_REF"
132-
echo " git pull"
133-
echo " git commit -m \"chore(release): bump version\" -m \"release-as: X.Y.Z\" --allow-empty"
134-
echo " git push"
135-
echo ""
136-
echo "Replace X.Y.Z with the next available version number."
137-
echo "See RELEASE.md for more details on handling version clashes."
138-
exit 1
139-
else
140-
echo "✅ No version clash - tag 'platform-$VERSION' does not exist yet"
141-
fi
142-
14388
lint-pr-title:
14489
name: PR Title Linter
14590
if: github.event_name == 'pull_request'

platform/dev/RELEASE.md

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ When you merge to `release/v1.0.22`:
8181
- Release Please creates a PR for `v1.0.23` targeting the release branch
8282
- Merge this PR to create the hotfix release
8383

84-
**Important:** If there's already a release-please PR on `main` targeting the same version (v1.0.23), you'll need to resolve the version clash after releasing the hotfix. See [Version Clash](#version-clash-after-hotfix) in Troubleshooting.
85-
8684
### 4. Backport to Main
8785

8886
After releasing the hotfix, apply the fix to `main`:
@@ -99,6 +97,19 @@ git cherry-pick <commit-sha>
9997
git push origin main
10098
```
10199

100+
### 5. IMPORTANT! Bump the version on `main` using the `release-as` directive:
101+
102+
```bash
103+
git checkout main
104+
git pull origin main
105+
git commit -m "chore(release): bump version" -m "release-as: X.Y.Z" --allow-empty
106+
git push origin main
107+
```
108+
(alternatively create PR with this empty commit and merge to `main`)
109+
Replace X.Y.Z with a version higher than the hotfix you just released (e.g., if hotfix was v1.0.23, use v1.0.24)
110+
111+
Now the version of existing release-please PR for `main` will be bumped
112+
102113
## Quick Reference
103114

104115
### Release a New Version
@@ -145,22 +156,3 @@ Check the "On commits to main" workflow for errors. Common issues:
145156
- Docker build failures
146157
- Kubernetes deployment issues
147158
- Secret configuration problems
148-
149-
### Version Clash After Hotfix
150-
151-
**Scenario:** You released a hotfix (e.g., v1.0.23) from a `release/*` branch, but `main` already has a release-please PR targeting the same version.
152-
153-
**Symptom:** The "Version Clash Check" CI job fails on the release-please PR for `main`.
154-
155-
**Solution:** Bump the version on `main` using the `release-as` directive:
156-
157-
```bash
158-
git checkout main
159-
git pull origin main
160-
git commit -m "chore(release): bump version" -m "release-as: 1.0.24" --allow-empty
161-
git push origin main
162-
```
163-
164-
This creates an empty commit that tells Release Please to target v1.0.24 instead. The release-please PR will automatically update.
165-
166-
**Prevention:** Before merging any release-please PR, check that the target version hasn't already been used. The CI check does this automatically, but if you're releasing a hotfix, be aware that you may need to bump the version on `main` afterwards.

0 commit comments

Comments
 (0)