Skip to content

Commit 5a39efd

Browse files
authored
chore: fix preview release bump logic and always publish java (#4973)
Ensure the preview release also bump version to preview version number instead of staying at the stable release version number. Example situation today: 0.38.3-beta.1 has version 0.38.2 on all files: https://github.com/lancedb/lance/blob/v0.38.3-beta.1/Cargo.toml#L25 This should make the version bump experience consistent between lance and lancedb
1 parent 85d44b6 commit 5a39efd

4 files changed

Lines changed: 130 additions & 71 deletions

File tree

.bumpversion.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
[tool.bumpversion]
22
current_version = "0.32.1"
3-
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
4-
serialize = ["{major}.{minor}.{patch}"]
3+
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(-(?P<prerelease>.+))?"
4+
serialize = [
5+
"{major}.{minor}.{patch}-{prerelease}",
6+
"{major}.{minor}.{patch}"
7+
]
58
search = "{current_version}"
69
replace = "{new_version}"
710
regex = false

.github/workflows/java-publish.yml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
name: Build and publish Java packages
22
on:
33
release:
4-
# Use released instead of published, since we don't publish preview/beta
5-
# versions
6-
types: [released]
4+
# Trigger on published to include both stable and preview/beta releases
5+
types: [published]
76
pull_request:
87
paths:
98
- .github/workflows/java-publish.yml
109
workflow_dispatch:
1110
inputs:
1211
mode:
13-
description: 'Release mode'
12+
description: "Release mode"
1413
required: true
1514
type: choice
1615
default: dry_run
1716
options:
1817
- dry_run
1918
- release
2019
ref:
21-
description: 'The branch, tag or SHA to checkout'
20+
description: "The branch, tag or SHA to checkout"
2221
required: false
2322
type: string
2423

@@ -39,14 +38,14 @@ jobs:
3938
- name: Build and run in Debian 10 Arm64 container
4039
run: |
4140
docker run --platform linux/arm64 -v ${{ github.workspace }}:/workspace -w /workspace debian:10 bash -c "
42-
41+
4342
set -ex
4443
# Update sources.list to use archive repositories for Debian 10 (EOL)
4544
echo 'deb http://archive.debian.org/debian/ buster main' > /etc/apt/sources.list
4645
echo 'deb http://archive.debian.org/debian-security buster/updates main' >> /etc/apt/sources.list
4746
echo 'deb http://archive.debian.org/debian/ buster-updates main' >> /etc/apt/sources.list
4847
apt-get update
49-
48+
5049
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --assume-yes \
5150
apt-transport-https \
5251
ca-certificates \
@@ -74,20 +73,20 @@ jobs:
7473
libhidapi-dev \
7574
zip \
7675
unzip
77-
76+
7877
# https://github.com/databendlabs/databend/issues/8035
7978
PROTOC_ZIP=protoc-3.15.0-linux-aarch_64.zip
8079
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.15.0/\$PROTOC_ZIP
8180
unzip -o \$PROTOC_ZIP -d /usr/local
8281
rm -f \$PROTOC_ZIP
8382
protoc --version
84-
83+
8584
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable
8685
source \$HOME/.cargo/env
8786
cargo --version
88-
87+
8988
cd java/lance-jni
90-
89+
9190
# https://github.com/rustls/rustls/issues/1967
9291
export CC=clang
9392
export CXX=clang++
@@ -117,14 +116,14 @@ jobs:
117116
- name: Build and run in Debian 10 X86-64 container
118117
run: |
119118
docker run --platform linux/amd64 -v ${{ github.workspace }}:/workspace -w /workspace debian:10 bash -c "
120-
119+
121120
set -ex
122121
# Update sources.list to use archive repositories for Debian 10 (EOL)
123122
echo 'deb http://archive.debian.org/debian/ buster main' > /etc/apt/sources.list
124123
echo 'deb http://archive.debian.org/debian-security buster/updates main' >> /etc/apt/sources.list
125124
echo 'deb http://archive.debian.org/debian/ buster-updates main' >> /etc/apt/sources.list
126125
apt-get update
127-
126+
128127
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --assume-yes \
129128
apt-transport-https \
130129
ca-certificates \
@@ -152,20 +151,20 @@ jobs:
152151
libhidapi-dev \
153152
zip \
154153
unzip
155-
154+
156155
# https://github.com/databendlabs/databend/issues/8035
157156
PROTOC_ZIP=protoc-3.15.0-linux-x86_64.zip
158157
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.15.0/\$PROTOC_ZIP
159158
unzip -o \$PROTOC_ZIP -d /usr/local
160159
rm -f \$PROTOC_ZIP
161160
protoc --version
162-
161+
163162
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable
164163
source \$HOME/.cargo/env
165164
cargo --version
166-
165+
167166
cd java/lance-jni
168-
167+
169168
# https://github.com/rustls/rustls/issues/1967
170169
export CC=clang
171170
export CXX=clang++
@@ -181,7 +180,7 @@ jobs:
181180
if-no-files-found: error
182181
macos-arm64:
183182
name: Build on MacOS Arm64 and release
184-
runs-on: macos-14
183+
runs-on: warp-macos-14-arm64-6x
185184
timeout-minutes: 60
186185
needs:
187186
- linux-arm64
@@ -252,4 +251,4 @@ jobs:
252251
- uses: ./.github/actions/create-failure-issue
253252
with:
254253
job-results: ${{ toJSON(needs) }}
255-
workflow-name: ${{ github.workflow }}
254+
workflow-name: ${{ github.workflow }}

.github/workflows/make-release-commit.yml

Lines changed: 57 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,44 @@ jobs:
8181
run: |
8282
CURRENT="${{ steps.current_version.outputs.version }}"
8383
TYPE="${{ inputs.release_type }}"
84-
85-
IFS='.' read -r major minor patch <<< "$CURRENT"
86-
87-
case "$TYPE" in
88-
major)
89-
NEW_VERSION="$((major + 1)).0.0"
90-
;;
91-
minor)
92-
NEW_VERSION="${major}.$((minor + 1)).0"
93-
;;
94-
patch)
95-
NEW_VERSION="${major}.${minor}.$((patch + 1))"
96-
;;
97-
esac
98-
84+
CHANNEL="${{ inputs.release_channel }}"
85+
86+
# Strip any prerelease suffix to get base version
87+
BASE_VERSION=$(echo "$CURRENT" | sed 's/-.*$//')
88+
IFS='.' read -r major minor patch <<< "$BASE_VERSION"
89+
90+
# Determine if we need to bump the base version
91+
if [[ "$CHANNEL" == "stable" && "$CURRENT" =~ -beta\. ]]; then
92+
# Stable release from beta: use base version without bumping
93+
NEW_VERSION="$BASE_VERSION"
94+
elif [[ "$CHANNEL" == "preview" && "$CURRENT" =~ -beta\. ]]; then
95+
# Preview from preview: keep the same base version, only beta number changes
96+
NEW_VERSION="$BASE_VERSION"
97+
else
98+
# All other cases: bump according to type
99+
case "$TYPE" in
100+
major)
101+
NEW_VERSION="$((major + 1)).0.0"
102+
;;
103+
minor)
104+
NEW_VERSION="${major}.$((minor + 1)).0"
105+
;;
106+
patch)
107+
NEW_VERSION="${major}.${minor}.$((patch + 1))"
108+
;;
109+
esac
110+
fi
111+
99112
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
100113
echo "New version will be: $NEW_VERSION"
101114
102-
- name: Determine tag name
115+
- name: Determine tag name and prerelease suffix
103116
id: tag_name
104117
run: |
105118
if [ "${{ inputs.release_channel }}" == "stable" ]; then
106119
VERSION="${{ steps.new_version.outputs.version }}"
107120
TAG="v${VERSION}"
121+
PRERELEASE=""
108122
else
109123
# For preview releases, base the beta tag on the next release version
110124
VERSION="${{ steps.new_version.outputs.version }}"
@@ -118,26 +132,34 @@ jobs:
118132
BETA_NUM=$((LAST_NUM + 1))
119133
fi
120134
TAG="v${VERSION}-beta.${BETA_NUM}"
135+
PRERELEASE="beta.${BETA_NUM}"
121136
fi
122-
137+
123138
echo "tag=$TAG" >> $GITHUB_OUTPUT
139+
echo "prerelease=$PRERELEASE" >> $GITHUB_OUTPUT
124140
echo "Tag will be: $TAG"
125-
126-
- name: Update version (stable releases only)
127-
if: inputs.release_channel == 'stable'
141+
142+
- name: Update version
128143
run: |
129-
python ci/bump_version.py ${{ inputs.release_type }}
144+
if [ "${{ inputs.release_channel }}" == "stable" ]; then
145+
python ci/bump_version.py --new-version "${{ steps.new_version.outputs.version }}"
146+
else
147+
python ci/bump_version.py --new-version "${{ steps.new_version.outputs.version }}-${{ steps.tag_name.outputs.prerelease }}"
148+
fi
130149
131150
- name: Configure git identity
132151
run: |
133152
git config user.name 'Lance Release Bot'
134153
git config user.email 'lance-dev@lancedb.com'
135-
136-
- name: Create release commit (stable releases only)
137-
if: inputs.release_channel == 'stable'
154+
155+
- name: Create release commit
138156
run: |
139157
git add -A
140-
git commit -m "chore: release version ${{ steps.new_version.outputs.version }}"
158+
if [ "${{ inputs.release_channel }}" == "stable" ]; then
159+
git commit -m "chore: release version ${{ steps.new_version.outputs.version }}"
160+
else
161+
git commit -m "chore: release version ${{ steps.tag_name.outputs.tag }}"
162+
fi
141163
142164
- name: Create tag
143165
run: |
@@ -146,11 +168,9 @@ jobs:
146168
- name: Push changes (if not dry run)
147169
if: ${{ !inputs.dry_run }}
148170
run: |
149-
if [ "${{ inputs.release_channel }}" == "stable" ]; then
150-
# Push the commit for stable releases
151-
git push origin main
152-
fi
153-
# Always push the tag
171+
# Push the commit to main
172+
git push origin main
173+
# Push the tag
154174
git push origin "${{ steps.tag_name.outputs.tag }}"
155175
156176
- name: Create GitHub Release (if not dry run)
@@ -164,12 +184,14 @@ jobs:
164184
generate_release_notes: true
165185
token: ${{ secrets.LANCE_RELEASE_TOKEN }}
166186

167-
- name: Prepare for next development cycle (stable releases only)
168-
if: inputs.release_channel == 'stable' && !inputs.dry_run
187+
- name: Next steps
188+
if: ${{ !inputs.dry_run }}
169189
run: |
170-
# After a stable release, bump to the next patch version with -dev suffix
171-
# This will be handled in a follow-up PR
172-
echo "Next steps: Create a PR to bump version for next development cycle"
190+
if [ "${{ inputs.release_channel }}" == "stable" ]; then
191+
echo "Stable release complete. Version bumped to ${{ steps.new_version.outputs.version }}"
192+
else
193+
echo "Preview release complete. Version bumped to ${{ steps.new_version.outputs.version }}-${{ steps.tag_name.outputs.prerelease }}"
194+
fi
173195
174196
- name: Summary
175197
run: |

ci/bump_version.py

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,41 @@ def get_current_version() -> str:
3535
raise ValueError("Could not find version in Cargo.toml")
3636

3737

38-
def parse_version(version: str) -> Tuple[int, int, int]:
39-
"""Parse a version string into major, minor, patch components."""
40-
match = re.match(r"(\d+)\.(\d+)\.(\d+)", version)
38+
def parse_version(version: str) -> Tuple[int, int, int, Optional[str]]:
39+
"""Parse a version string into major, minor, patch, and optional prerelease components."""
40+
match = re.match(r"(\d+)\.(\d+)\.(\d+)(?:-(.+))?", version)
4141
if not match:
4242
raise ValueError(f"Invalid version format: {version}")
43-
return int(match.group(1)), int(match.group(2)), int(match.group(3))
43+
return int(match.group(1)), int(match.group(2)), int(match.group(3)), match.group(4)
4444

4545

46-
def bump_version(current: str, bump_type: str) -> str:
47-
"""Calculate the new version based on bump type."""
48-
major, minor, patch = parse_version(current)
49-
46+
def bump_version(current: str, bump_type: str, prerelease: Optional[str] = None) -> str:
47+
"""Calculate the new version based on bump type.
48+
49+
Args:
50+
current: Current version string
51+
bump_type: Type of bump (major, minor, patch)
52+
prerelease: Optional prerelease suffix (e.g., "beta.1")
53+
54+
Returns:
55+
New version string
56+
"""
57+
major, minor, patch, _ = parse_version(current)
58+
5059
if bump_type == "major":
51-
return f"{major + 1}.0.0"
60+
new_version = f"{major + 1}.0.0"
5261
elif bump_type == "minor":
53-
return f"{major}.{minor + 1}.0"
62+
new_version = f"{major}.{minor + 1}.0"
5463
elif bump_type == "patch":
55-
return f"{major}.{minor}.{patch + 1}"
64+
new_version = f"{major}.{minor}.{patch + 1}"
5665
else:
5766
raise ValueError(f"Invalid bump type: {bump_type}")
5867

68+
if prerelease:
69+
new_version = f"{new_version}-{prerelease}"
70+
71+
return new_version
72+
5973

6074
def update_cargo_lock_files():
6175
"""Update all Cargo.lock files after version change."""
@@ -105,7 +119,20 @@ def main():
105119
parser.add_argument(
106120
"bump_type",
107121
choices=["major", "minor", "patch"],
108-
help="Type of version bump to perform"
122+
nargs='?',
123+
help="Type of version bump to perform (not needed with --new-version)"
124+
)
125+
parser.add_argument(
126+
"--new-version",
127+
type=str,
128+
default=None,
129+
help="Set exact new version (e.g., '0.38.3' or '0.38.3-beta.1')"
130+
)
131+
parser.add_argument(
132+
"--prerelease",
133+
type=str,
134+
default=None,
135+
help="Prerelease suffix (e.g., 'beta.1')"
109136
)
110137
parser.add_argument(
111138
"--dry-run",
@@ -117,12 +144,20 @@ def main():
117144
action="store_true",
118145
help="Skip version consistency validation"
119146
)
120-
147+
121148
args = parser.parse_args()
122-
149+
123150
# Get current version
124151
current_version = get_current_version()
125-
new_version = bump_version(current_version, args.bump_type)
152+
153+
if args.new_version:
154+
# Use exact version provided
155+
new_version = args.new_version
156+
else:
157+
# Calculate new version from bump type
158+
if not args.bump_type:
159+
parser.error("Either bump_type or --new-version must be provided")
160+
new_version = bump_version(current_version, args.bump_type, args.prerelease)
126161

127162
print(f"Current version: {current_version}")
128163
print(f"New version: {new_version}")

0 commit comments

Comments
 (0)