Skip to content

Commit 51a4e96

Browse files
jackye1995claude
andauthored
feat: implement auto version bump and release workflow (#41)
Implement automated version bump, release, and publish process similar to lance-spark. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3f5e82c commit 51a4e96

9 files changed

Lines changed: 835 additions & 1 deletion

File tree

.bumpversion.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[tool.bumpversion]
2+
current_version = "0.0.1"
3+
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
4+
serialize = ["{major}.{minor}.{patch}"]
5+
search = "{current_version}"
6+
replace = "{new_version}"
7+
regex = false
8+
ignore_missing_files = false
9+
ignore_missing_version = false
10+
tag = false
11+
sign_tags = false
12+
tag_name = "v{new_version}"
13+
tag_message = "Release version {new_version}"
14+
allow_dirty = false
15+
commit = false
16+
message = "chore: bump version {current_version} → {new_version}"
17+
18+
# pyproject.toml - project version
19+
[[tool.bumpversion.files]]
20+
filename = "pyproject.toml"
21+
search = 'version = "{current_version}"'
22+
replace = 'version = "{new_version}"'
23+
24+
# lance_ray/__init__.py - package version (if exists)
25+
[[tool.bumpversion.files]]
26+
filename = "lance_ray/__init__.py"
27+
search = '__version__ = "{current_version}"'
28+
replace = '__version__ = "{new_version}"'
29+
ignore_missing_files = true

.github/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
13+
changelog:
14+
exclude:
15+
labels:
16+
- ci
17+
- chore
18+
categories:
19+
- title: Breaking Changes 🛠
20+
labels:
21+
- breaking-change
22+
- title: New Features 🎉
23+
labels:
24+
- enhancement
25+
- title: Bug Fixes 🐛
26+
labels:
27+
- bug
28+
- title: Documentation 📚
29+
labels:
30+
- documentation
31+
- title: Performance Improvements 🚀
32+
labels:
33+
- performance
34+
- title: Other Changes
35+
labels:
36+
- "*"

.github/workflows/auto-bump.yml

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
name: Auto Bump Version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump_type:
7+
description: 'Type of version bump'
8+
required: false
9+
default: 'auto'
10+
type: choice
11+
options:
12+
- auto
13+
- patch
14+
- minor
15+
- major
16+
17+
jobs:
18+
check-for-changes:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
should_bump: ${{ steps.check.outputs.should_bump }}
22+
bump_type: ${{ steps.check.outputs.bump_type }}
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Check for unreleased changes
31+
id: check
32+
run: |
33+
# Get the last tag
34+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
35+
36+
if [ -z "$LAST_TAG" ]; then
37+
echo "No tags found, should create initial release"
38+
echo "should_bump=true" >> $GITHUB_OUTPUT
39+
echo "bump_type=patch" >> $GITHUB_OUTPUT
40+
exit 0
41+
fi
42+
43+
# Check for commits since last tag
44+
COMMITS_SINCE_TAG=$(git rev-list --count ${LAST_TAG}..HEAD)
45+
46+
if [ "$COMMITS_SINCE_TAG" -gt 0 ]; then
47+
echo "Found $COMMITS_SINCE_TAG commits since last tag $LAST_TAG"
48+
49+
# Determine bump type based on input or commit analysis
50+
if [ "${{ inputs.bump_type }}" != "auto" ] && [ -n "${{ inputs.bump_type }}" ]; then
51+
# Use manual input if provided and not "auto"
52+
BUMP_TYPE="${{ inputs.bump_type }}"
53+
else
54+
# Analyze commit messages to determine bump type
55+
BUMP_TYPE="patch"
56+
57+
# Check for breaking changes (major bump)
58+
if git log ${LAST_TAG}..HEAD --grep="BREAKING CHANGE" --grep="!:" | grep -q .; then
59+
BUMP_TYPE="major"
60+
# Check for features (minor bump)
61+
elif git log ${LAST_TAG}..HEAD --grep="^feat" --grep="^feature" | grep -q .; then
62+
BUMP_TYPE="minor"
63+
fi
64+
fi
65+
66+
echo "should_bump=true" >> $GITHUB_OUTPUT
67+
echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT
68+
else
69+
echo "No commits since last tag $LAST_TAG"
70+
echo "should_bump=false" >> $GITHUB_OUTPUT
71+
fi
72+
73+
- name: Summary
74+
run: |
75+
echo "## Auto Bump Check" >> $GITHUB_STEP_SUMMARY
76+
echo "" >> $GITHUB_STEP_SUMMARY
77+
if [ "${{ steps.check.outputs.should_bump }}" == "true" ]; then
78+
echo "✅ Version bump needed" >> $GITHUB_STEP_SUMMARY
79+
echo "- **Bump Type:** ${{ steps.check.outputs.bump_type }}" >> $GITHUB_STEP_SUMMARY
80+
else
81+
echo "⏭️ No version bump needed" >> $GITHUB_STEP_SUMMARY
82+
fi
83+
84+
create-bump-pr:
85+
needs: check-for-changes
86+
if: needs.check-for-changes.outputs.should_bump == 'true'
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Checkout repository
90+
uses: actions/checkout@v4
91+
with:
92+
token: ${{ secrets.GITHUB_TOKEN }}
93+
fetch-depth: 0
94+
95+
- name: Set up Python
96+
uses: actions/setup-python@v5
97+
with:
98+
python-version: '3.11'
99+
100+
- name: Install dependencies
101+
run: |
102+
pip install packaging toml bump-my-version
103+
104+
- name: Get current version
105+
id: current_version
106+
run: |
107+
CURRENT_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
108+
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
109+
echo "Current version: $CURRENT_VERSION"
110+
111+
- name: Calculate new version
112+
id: new_version
113+
run: |
114+
python ci/calculate_version.py \
115+
--current "${{ steps.current_version.outputs.version }}" \
116+
--type "${{ needs.check-for-changes.outputs.bump_type }}" \
117+
--channel "stable"
118+
119+
- name: Create feature branch
120+
run: |
121+
BRANCH_NAME="auto-bump-${{ steps.new_version.outputs.version }}"
122+
git checkout -b $BRANCH_NAME
123+
echo "branch=$BRANCH_NAME" >> $GITHUB_ENV
124+
125+
- name: Bump version
126+
run: |
127+
python ci/bump_version.py --version "${{ steps.new_version.outputs.version }}"
128+
129+
- name: Configure git
130+
run: |
131+
git config user.name 'github-actions[bot]'
132+
git config user.email 'github-actions[bot]@users.noreply.github.com'
133+
134+
- name: Commit changes
135+
run: |
136+
git add -A
137+
git commit -m "chore: bump version to ${{ steps.new_version.outputs.version }}
138+
139+
Automated version bump from ${{ steps.current_version.outputs.version }} to ${{ steps.new_version.outputs.version }}.
140+
Bump type: ${{ needs.check-for-changes.outputs.bump_type }}"
141+
142+
- name: Push changes
143+
run: |
144+
git push origin ${{ env.branch }}
145+
146+
- name: Create Pull Request
147+
uses: peter-evans/create-pull-request@v5
148+
with:
149+
token: ${{ secrets.GITHUB_TOKEN }}
150+
branch: ${{ env.branch }}
151+
base: main
152+
title: "chore: bump version to ${{ steps.new_version.outputs.version }}"
153+
body: |
154+
## Automated Version Bump
155+
156+
This PR automatically bumps the version from `${{ steps.current_version.outputs.version }}` to `${{ steps.new_version.outputs.version }}`.
157+
158+
### Details
159+
- **Bump Type:** ${{ needs.check-for-changes.outputs.bump_type }}
160+
- **Triggered By:** ${{ github.event_name == 'workflow_dispatch' && 'Manual trigger' || 'Automated' }}
161+
162+
### Checklist
163+
- [ ] Review version bump changes
164+
- [ ] Verify pyproject.toml is updated
165+
- [ ] Confirm CI checks pass
166+
167+
### Next Steps
168+
After merging this PR, you can create a release by:
169+
1. Going to Actions → Create Release workflow
170+
2. Selecting the release channel (stable/preview)
171+
3. Running the workflow
172+
173+
---
174+
*This PR was automatically generated by the auto-bump workflow.*
175+
labels: |
176+
version-bump
177+
automated
178+
assignees: ${{ github.actor }}
179+
180+
- name: Summary
181+
run: |
182+
echo "## Version Bump PR Created" >> $GITHUB_STEP_SUMMARY
183+
echo "" >> $GITHUB_STEP_SUMMARY
184+
echo "- **Current Version:** ${{ steps.current_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
185+
echo "- **New Version:** ${{ steps.new_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
186+
echo "- **Bump Type:** ${{ needs.check-for-changes.outputs.bump_type }}" >> $GITHUB_STEP_SUMMARY
187+
echo "- **Branch:** ${{ env.branch }}" >> $GITHUB_STEP_SUMMARY
188+
echo "" >> $GITHUB_STEP_SUMMARY
189+
echo "✅ Pull request created successfully!" >> $GITHUB_STEP_SUMMARY

.github/workflows/python-release.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ on:
2929
options:
3030
- dry_run
3131
- release
32+
ref:
33+
description: 'The branch, tag or SHA to checkout'
34+
required: false
35+
type: string
3236

3337
jobs:
3438
publish:
@@ -39,6 +43,10 @@ jobs:
3943
steps:
4044
- name: Checkout code
4145
uses: actions/checkout@v4
46+
with:
47+
# When triggered by a release, use the release tag
48+
# When triggered manually, use the provided ref
49+
ref: ${{ github.event.release.tag_name || inputs.ref }}
4250

4351
- name: Set up Python
4452
uses: actions/setup-python@v5
@@ -52,9 +60,17 @@ jobs:
5260
run: |
5361
uv build
5462
63+
- name: Get package version
64+
id: get_version
65+
run: |
66+
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
67+
echo "version=$VERSION" >> $GITHUB_OUTPUT
68+
echo "Package version: $VERSION"
69+
5570
- name: Publish to PyPI
5671
if: |
5772
(github.event_name == 'release' && github.event.action == 'released') ||
5873
(github.event_name == 'workflow_dispatch' && github.event.inputs.mode == 'release')
5974
run: |
60-
uv publish --trusted-publishing always
75+
uv publish --trusted-publishing always
76+
echo "✅ Successfully published version ${{ steps.get_version.outputs.version }} to PyPI!"

0 commit comments

Comments
 (0)