Skip to content

Commit 18d0a59

Browse files
authored
Merge pull request #221 from blink1073/allow-next
Add 'next' convenience for tbump
2 parents b6ade2e + a3b96c5 commit 18d0a59

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

docs/source/get_started/making_first_release.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ already uses Jupyter Releaser.
4141
4242
![Draft Changelog Workflow Dialog](../images/draft_changelog.png)
4343
44-
- The "New Version Spec" will usually be the full version (e.g. 0.7.1)
44+
- The "New Version Spec" will usually be the full version (e.g. 0.7.1). Repos using `tbump` can also use the "next"
45+
option, which will bump the micro version (or the build version in the case of a prerelease).
4546
- Use the "since" field to select PRs prior to the latest tag to include in the release
4647
- Type "true" in the "since the last stable git tag" if you would like to include PRs since the last non-prerelease version tagged on the target repository and branch.
4748
- The workflow will use the GitHub API to find the relevant pull requests and make an appropriate changelog entry.

jupyter_releaser/tests/test_functions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ def test_bump_version(py_package):
175175
util.bump_version(spec)
176176
util.run("git commit -a -m 'bump version'")
177177
assert util.get_version() == spec
178+
util.bump_version("1.0.2")
179+
util.bump_version("next")
180+
assert util.get_version() == "1.0.3"
181+
util.bump_version("patch")
182+
assert util.get_version() == "1.0.4"
183+
util.bump_version("1.0.3a5")
184+
util.bump_version("next")
185+
assert util.get_version() == "1.0.3a6"
178186

179187

180188
def test_get_config_python(py_package):

jupyter_releaser/util.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,24 @@ def bump_version(version_spec, version_cmd=""):
217217
if not version_cmd: # pragma: no cover
218218
raise ValueError("Please specify a version bump command to run")
219219

220-
# Assign default values if not version spec was given
220+
# Assign default values if no version spec was given
221221
if not version_spec:
222222
if "tbump" in version_cmd:
223-
version = parse_version(get_version())
224-
version_spec = f"{version.major}.{version.minor}.{version.micro + 1}"
223+
version_spec = "next"
225224
else:
226225
version_spec = "patch"
227226

227+
# Add some convenience options on top of "tbump"
228+
if "tbump" in version_cmd:
229+
v = parse_version(get_version())
230+
if version_spec == "next":
231+
if v.is_prerelease:
232+
version_spec = f"{v.major}.{v.minor}.{v.micro}{v.pre[0]}{v.pre[1] + 1}"
233+
else:
234+
version_spec = f"{v.major}.{v.minor}.{v.micro + 1}"
235+
elif version_spec == "patch":
236+
version_spec = f"{v.major}.{v.minor}.{v.micro + 1}"
237+
228238
# Bump the version
229239
run(f"{version_cmd} {version_spec}")
230240

0 commit comments

Comments
 (0)