Skip to content

Commit aa1a7e8

Browse files
committed
finalize doc
1 parent 315bea6 commit aa1a7e8

File tree

4 files changed

+219
-257
lines changed

4 files changed

+219
-257
lines changed

.github/workflows/create-major-minor-rc.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name: Create Major/Minor Release Candidate
33
on:
44
workflow_dispatch:
55
inputs:
6-
version:
7-
description: 'Target version (e.g., 1.3.0)'
8-
required: true
9-
type: string
106
dry_run:
117
description: 'Dry run (simulate without pushing)'
128
required: true
@@ -60,7 +56,7 @@ jobs:
6056
GITHUB_REPOSITORY: ${{ github.repository }}
6157
GITHUB_OUTPUT: ${{ github.output }}
6258
run: |
63-
bash ci/create_major_minor_rc.sh "${{ inputs.version }}"
59+
bash ci/create_major_minor_rc.sh
6460
6561
- name: Push changes (if not dry run)
6662
if: ${{ !inputs.dry_run }}
@@ -92,11 +88,11 @@ jobs:
9288
DISCUSSION_TITLE="[VOTE] Release Candidate ${{ steps.create_rc.outputs.RC_TAG }}"
9389
DISCUSSION_BODY="## Release Candidate: ${{ steps.create_rc.outputs.RC_TAG }}
9490
95-
This is the initial release candidate for version **${{ inputs.version }}**.
91+
This is the initial release candidate for version **${{ steps.create_rc.outputs.RC_VERSION }}**.
9692
9793
### Release Information
9894
- **RC Tag**: ${{ steps.create_rc.outputs.RC_TAG }}
99-
- **Target Version**: ${{ inputs.version }}
95+
- **Target Version**: ${{ steps.create_rc.outputs.RC_VERSION }}
10096
- **Release Branch**: ${{ steps.create_rc.outputs.RELEASE_BRANCH }}
10197
- **Main Version**: ${{ steps.create_rc.outputs.MAIN_VERSION }} (unreleased)
10298
- **Source Branch**: main (HEAD)
@@ -177,7 +173,7 @@ jobs:
177173
run: |
178174
echo "## Major/Minor RC Creation Summary" >> $GITHUB_STEP_SUMMARY
179175
echo "" >> $GITHUB_STEP_SUMMARY
180-
echo "- **Target Version:** ${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
176+
echo "- **Target Version:** ${{ steps.create_rc.outputs.RC_VERSION }}" >> $GITHUB_STEP_SUMMARY
181177
echo "- **RC Tag:** ${{ steps.create_rc.outputs.RC_TAG }}" >> $GITHUB_STEP_SUMMARY
182178
echo "- **Release Branch:** ${{ steps.create_rc.outputs.RELEASE_BRANCH }}" >> $GITHUB_STEP_SUMMARY
183179
echo "- **Release Root Tag:** ${{ steps.create_rc.outputs.RELEASE_ROOT_TAG }}" >> $GITHUB_STEP_SUMMARY

ci/create_major_minor_rc.sh

Lines changed: 82 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,98 @@ set -e
33

44
# Script to create a major/minor release candidate (RC)
55
# Always creates RC from the tip of main branch
6-
# Usage: create_major_minor_rc.sh <target_version>
7-
# Example: create_major_minor_rc.sh 1.3.0
6+
# Checks for breaking changes and bumps major version if needed
7+
# The version is automatically determined from main branch HEAD
8+
# Usage: create_major_minor_rc.sh
9+
# Example: create_major_minor_rc.sh
810

9-
TARGET_VERSION=${1:?"Error: target version required (e.g., 1.3.0)"}
10-
TAG_PREFIX=${2:-"v"}
11+
TAG_PREFIX=${1:-"v"}
1112

1213
readonly SELF_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
1314

14-
echo "Creating major/minor RC for version ${TARGET_VERSION} from main HEAD"
15-
16-
# Parse major.minor from target version
17-
MAJOR=$(echo "${TARGET_VERSION}" | cut -d. -f1)
18-
MINOR=$(echo "${TARGET_VERSION}" | cut -d. -f2)
19-
RELEASE_BRANCH="release/v${MAJOR}.${MINOR}"
20-
21-
echo "Will create release branch: ${RELEASE_BRANCH}"
22-
23-
# Check if main is at beta.0, bump to beta.1 first
2415
git checkout main
2516
MAIN_VERSION=$(grep '^version = ' Cargo.toml | head -n1 | cut -d'"' -f2)
2617
echo "Main branch current version: ${MAIN_VERSION}"
2718

28-
if [[ "${MAIN_VERSION}" =~ -beta\.0$ ]]; then
29-
echo "Main is at beta.0, bumping to beta.1 first"
30-
bump-my-version bump -vv prerelease_num
19+
# Extract the base version from main (remove beta suffix if present)
20+
if [[ "${MAIN_VERSION}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-beta\.([0-9]+))?$ ]]; then
21+
CURR_MAJOR="${BASH_REMATCH[1]}"
22+
CURR_MINOR="${BASH_REMATCH[2]}"
23+
CURR_PATCH="${BASH_REMATCH[3]}"
24+
BASE_VERSION="${CURR_MAJOR}.${CURR_MINOR}.${CURR_PATCH}"
25+
else
26+
echo "ERROR: Cannot parse version from main branch: ${MAIN_VERSION}"
27+
exit 1
28+
fi
29+
30+
echo "Current base version on main: ${BASE_VERSION}"
31+
32+
# Check for existing release-root tag to find comparison base
33+
CURR_RELEASE_ROOT_TAG="release-root/${BASE_VERSION}-beta.N"
34+
35+
if git rev-parse "${CURR_RELEASE_ROOT_TAG}" >/dev/null 2>&1; then
36+
echo "Found release root tag: ${CURR_RELEASE_ROOT_TAG}"
37+
COMPARE_TAG="${CURR_RELEASE_ROOT_TAG}"
38+
COMPARE_COMMIT=$(git rev-parse "${CURR_RELEASE_ROOT_TAG}")
39+
echo "Will compare against: ${COMPARE_TAG} (commit: ${COMPARE_COMMIT})"
40+
else
41+
echo "No release root tag found for current version series"
42+
COMPARE_TAG=""
43+
fi
3144

32-
git add -A
33-
git commit -m "chore: bump to beta.1 for preview release"
45+
# Check for breaking changes
46+
BREAKING_CHANGES="false"
47+
if [ -n "${COMPARE_TAG}" ]; then
48+
if [ -x "${SELF_DIR}/check_breaking_changes.py" ]; then
49+
if python3 "${SELF_DIR}/check_breaking_changes.py" --detect-only "${COMPARE_TAG}" "HEAD"; then
50+
echo "No breaking changes detected"
51+
BREAKING_CHANGES="false"
52+
else
53+
echo "Breaking changes detected"
54+
BREAKING_CHANGES="true"
55+
fi
56+
fi
3457
fi
3558

59+
# Determine RC version based on breaking changes
60+
if [ "${BREAKING_CHANGES}" = "true" ]; then
61+
# If breaking changes, check if we need to bump major
62+
# Extract the base RC version from the release-root tag message
63+
# This is the RC version we're comparing against (stays constant across major bumps)
64+
TAG_MESSAGE=$(git tag -l --format='%(contents)' "${CURR_RELEASE_ROOT_TAG}")
65+
BASE_RC_VERSION=$(echo "${TAG_MESSAGE}" | head -n1 | sed 's/Base: //')
66+
BASE_RC_MAJOR=$(echo "${BASE_RC_VERSION}" | cut -d. -f1 | sed 's/^v//')
67+
68+
echo "Base RC version: ${BASE_RC_VERSION} (major: ${BASE_RC_MAJOR})"
69+
70+
if [ "${CURR_MAJOR}" -gt "${BASE_RC_MAJOR}" ]; then
71+
echo "Major version already bumped from ${BASE_RC_MAJOR} to ${CURR_MAJOR}"
72+
RC_VERSION="${BASE_VERSION}-rc.0"
73+
else
74+
echo "Breaking changes require major version bump"
75+
RC_MAJOR=$((CURR_MAJOR + 1))
76+
RC_VERSION="${RC_MAJOR}.0.0-rc.0"
77+
fi
78+
else
79+
# No breaking changes, use current base version
80+
RC_VERSION="${BASE_VERSION}-rc.0"
81+
fi
82+
83+
echo "Creating RC version: ${RC_VERSION}"
84+
85+
# Parse RC version for release branch
86+
RC_MAJOR=$(echo "${RC_VERSION}" | cut -d. -f1)
87+
RC_MINOR=$(echo "${RC_VERSION}" | cut -d. -f2)
88+
RELEASE_BRANCH="release/v${RC_MAJOR}.${RC_MINOR}"
89+
90+
echo "Will create release branch: ${RELEASE_BRANCH}"
91+
3692
# Create release branch from main HEAD
3793
echo "Creating release branch ${RELEASE_BRANCH} from main HEAD"
3894
git checkout -b "${RELEASE_BRANCH}"
3995

40-
# Set version to target-rc.1
41-
RC_VERSION="${TARGET_VERSION}-rc.1"
96+
# Set version to RC version
4297
echo "Setting version to ${RC_VERSION}"
43-
4498
bump-my-version bump -vv --new-version "${RC_VERSION}" --no-tag patch
4599

46100
# Commit the RC version
@@ -58,32 +112,13 @@ echo "Successfully created RC tag: ${RC_TAG} on branch ${RELEASE_BRANCH}"
58112
echo "Bumping main to next version beta.0"
59113
git checkout main
60114

61-
# Get current version on main
62-
CURRENT_MAIN_VERSION=$(grep '^version = ' Cargo.toml | head -n1 | cut -d'"' -f2)
63-
echo "Current main version: ${CURRENT_MAIN_VERSION}"
64-
65-
# Parse current version
66-
CURR_MAJOR=$(echo "${CURRENT_MAIN_VERSION}" | cut -d. -f1 | sed 's/-beta.*//')
67-
CURR_MINOR=$(echo "${CURRENT_MAIN_VERSION}" | cut -d. -f2)
68-
CURR_PATCH=$(echo "${CURRENT_MAIN_VERSION}" | cut -d. -f3 | cut -d- -f1)
69-
70-
# Determine next version - just increment based on what we have
71-
# Breaking change detection will happen during beta publish
72-
if [ "${CURR_PATCH}" != "0" ]; then
73-
# If on a patch version, bump to next minor
74-
NEXT_MINOR=$((CURR_MINOR + 1))
75-
NEXT_VERSION="${CURR_MAJOR}.${NEXT_MINOR}.0-beta.0"
76-
elif [ "${CURR_MINOR}" -gt "0" ]; then
77-
# On minor version, bump to next minor
78-
NEXT_MINOR=$((CURR_MINOR + 1))
79-
NEXT_VERSION="${CURR_MAJOR}.${NEXT_MINOR}.0-beta.0"
80-
else
81-
# On major.0.0, bump to next major
82-
NEXT_MAJOR=$((CURR_MAJOR + 1))
83-
NEXT_VERSION="${NEXT_MAJOR}.0.0-beta.0"
84-
fi
115+
# Determine next version for main based on RC version
116+
# Always bump minor from the RC version
117+
NEXT_MAJOR="${RC_MAJOR}"
118+
NEXT_MINOR=$((RC_MINOR + 1))
119+
NEXT_VERSION="${NEXT_MAJOR}.${NEXT_MINOR}.0-beta.0"
85120

86-
echo "Bumping main to ${NEXT_VERSION} (unreleased, will be adjusted during beta publish)"
121+
echo "Bumping main to ${NEXT_VERSION} (unreleased)"
87122

88123
bump-my-version bump -vv --new-version "${NEXT_VERSION}" --no-tag patch
89124

ci/publish_beta.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ if [[ "${BRANCH}" == "main" ]] && [[ "${CURRENT_VERSION}" =~ -beta\.[0-9]+$ ]];
5151
echo "Release root tag ${CURR_RELEASE_ROOT_TAG} not found"
5252
echo "Treating as major version bump (no comparison base)"
5353

54+
# Store current commit before bumping version
55+
PREV_COMMIT=$(git rev-parse HEAD)
56+
5457
NEXT_MAJOR=$((CURR_MAJOR + 1))
55-
NEXT_BETA=$((CURR_BETA + 1))
56-
NEXT_VERSION="${NEXT_MAJOR}.0.0-beta.${NEXT_BETA}"
58+
# Reset to beta.1 for new major version
59+
NEXT_VERSION="${NEXT_MAJOR}.0.0-beta.1"
5760
echo "Bumping to ${NEXT_VERSION} (no release root found)"
5861

5962
echo "Updating version from ${CURRENT_VERSION} to ${NEXT_VERSION}"
@@ -64,6 +67,19 @@ if [[ "${BRANCH}" == "main" ]] && [[ "${CURRENT_VERSION}" =~ -beta\.[0-9]+$ ]];
6467

6568
CURRENT_VERSION="${NEXT_VERSION}"
6669

70+
# Create release-root tag for the new major version series
71+
# Point it to the commit before the version bump
72+
# Use the previous version as the base (this is what we're comparing against)
73+
NEW_RELEASE_ROOT_TAG="release-root/${NEXT_VERSION}-beta.N"
74+
echo "Creating release root tag ${NEW_RELEASE_ROOT_TAG} at commit ${PREV_COMMIT}"
75+
# Extract previous base version (without beta suffix)
76+
PREV_BASE_VERSION=$(echo "${CURRENT_VERSION}" | sed 's/-beta\.[0-9]*$//')
77+
# Decrement major to get what the "RC" would have been
78+
PREV_MAJOR=$((NEXT_MAJOR - 1))
79+
BASE_RC_VERSION="${PREV_MAJOR}.${CURR_MINOR}.${CURR_PATCH}-rc.0"
80+
git tag -a "${NEW_RELEASE_ROOT_TAG}" "${PREV_COMMIT}" -m "Base: ${BASE_RC_VERSION}
81+
Release root for ${NEXT_VERSION}-beta.N series (created during major bump)"
82+
6783
# Create beta tag
6884
BETA_TAG="${TAG_PREFIX}${CURRENT_VERSION}"
6985
echo "Creating beta tag: ${BETA_TAG}"
@@ -72,6 +88,7 @@ if [[ "${BRANCH}" == "main" ]] && [[ "${CURRENT_VERSION}" =~ -beta\.[0-9]+$ ]];
7288
echo "Successfully published beta release: ${BETA_TAG}"
7389
echo "BETA_TAG=${BETA_TAG}" >> $GITHUB_OUTPUT 2>/dev/null || true
7490
echo "BETA_VERSION=${CURRENT_VERSION}" >> $GITHUB_OUTPUT 2>/dev/null || true
91+
echo "RELEASE_ROOT_TAG=${NEW_RELEASE_ROOT_TAG}" >> $GITHUB_OUTPUT 2>/dev/null || true
7592
exit 0
7693
fi
7794

@@ -94,6 +111,7 @@ if [[ "${BRANCH}" == "main" ]] && [[ "${CURRENT_VERSION}" =~ -beta\.[0-9]+$ ]];
94111
if [ "${BREAKING_CHANGES}" = "true" ]; then
95112
# Extract the base RC version from the release-root tag message
96113
# Format: "Base: X.Y.Z-rc.N\nRelease root for..."
114+
# This is the RC version we're comparing against (stays constant across major bumps)
97115
TAG_MESSAGE=$(git tag -l --format='%(contents)' "${CURR_RELEASE_ROOT_TAG}")
98116
BASE_RC_VERSION=$(echo "${TAG_MESSAGE}" | head -n1 | sed 's/Base: //')
99117
BASE_VERSION=$(echo "${BASE_RC_VERSION}" | sed 's/-rc\.[0-9]*$//')
@@ -109,9 +127,8 @@ if [[ "${BRANCH}" == "main" ]] && [[ "${CURRENT_VERSION}" =~ -beta\.[0-9]+$ ]];
109127
else
110128
echo "Breaking changes detected since ${BASE_VERSION}, bumping major version"
111129
NEXT_MAJOR=$((CURR_MAJOR + 1))
112-
# Increment beta number
113-
NEXT_BETA=$((CURR_BETA + 1))
114-
NEXT_VERSION="${NEXT_MAJOR}.0.0-beta.${NEXT_BETA}"
130+
# Reset to beta.1 for new major version
131+
NEXT_VERSION="${NEXT_MAJOR}.0.0-beta.1"
115132
echo "Bumping to ${NEXT_VERSION}"
116133

117134
echo "Updating version from ${CURRENT_VERSION} to ${NEXT_VERSION}"

0 commit comments

Comments
 (0)