Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to bump my version #143

Merged
merged 4 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .bumpversion.cfg

This file was deleted.

1 change: 0 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ python:
path: .
extra_requirements:
- docs
system_packages: false
8 changes: 5 additions & 3 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,17 @@ Release a version

#. Update authors file
#. Merge ``develop`` on ``master`` branch
#. Bump release via task: ``inv tag-release (major|minor|patch)``
#. Bump release via task: ``inv tag-release --level=(major|minor|patch)``
#. Update changelog via towncrier: ``towncrier --yes``
#. Commit changelog with ``git commit --amend`` to merge with bumpversion commit
#. Commit changelog with ``git commit --amend`` to merge with bump-my-version commit
#. Create tag ``git tag <version>``
#. Push tag to github
#. Publish the release from the tags page
#. If pipeline succeeds, push ``master``
#. Merge ``master`` back on ``develop``
#. Bump developement version via task: ``inv tag-dev -l (major|minor|patch)``
#. Bump developement version via task: ``inv tag-dev --level=release``
#. Push ``develop``

To increment dev version use ``inv tag-dev --level=relver``` (e.g. to pass from ``1.2.0.dev1`` to ``1.2.0.dev2``)

.. _towncrier: https://pypi.org/project/towncrier/#news-fragments
1 change: 1 addition & 0 deletions changes/140.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Switch to bump-my-version
32 changes: 32 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,35 @@ target-version = "py310"

[tool.ruff.mccabe]
max-complexity = 10

[tool.bumpversion]
allow_dirty = false
commit = true
message = "Release {new_version}"
commit_args = "--no-verify"
tag = false
current_version = "1.2.0"
parse = """(?x)
(?P<major>[0-9]+)
\\.(?P<minor>[0-9]+)
\\.(?P<patch>[0-9]+)
(?:
.(?P<release>dev)
(?:(?P<relver>[0-9]+))?
)?
"""
serialize = [
"{major}.{minor}.{patch}.{release}{relver}",
"{major}.{minor}.{patch}"
]

[tool.bumpversion.parts.release]
values = [
"dev",
""
]
optional_value = "dev"

[[tool.bumpversion.files]]
filename = "taiga/__init__.py"
search = "{current_version}"
21 changes: 13 additions & 8 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def format(c): # NOQA
def towncrier_check(c): # NOQA
"""Check towncrier files."""
output = io.StringIO()
c.run("git branch --contains HEAD", out_stream=output)
skipped_branch_prefix = ["pull/", "develop", "master", "HEAD"]
c.run("git branch -a --contains HEAD", out_stream=output)
skipped_branch_prefix = ["pull/", "release/", "develop", "master", "HEAD"]
# cleanup branch names by removing PR-only names in local, remote and disconnected branches to ensure the current
# (i.e. user defined) branch name is used
branches = list(
Expand All @@ -52,10 +52,8 @@ def towncrier_check(c): # NOQA
),
)
)
print("Candidate branches", ", ".join(output.getvalue().split("\n")))
if not branches:
# if no branch name matches, we are in one of the excluded branches above, so we just exit
print("Skip check, branch excluded by configuration")
return
branch = branches[0]
towncrier_file = None
Expand Down Expand Up @@ -109,15 +107,22 @@ def coverage(c):


@task
def tag_release(c, level):
def tag_release(c, level, new_version=""):
"""Tag release version."""
c.run("bumpversion --list %s --no-tag" % level)
if new_version:
new_version = f" --new-version {new_version}"
c.run(f"bump-my-version bump {level}{new_version}")


@task
def tag_dev(c, level="patch"):
def tag_dev(c, level, new_version=""):
"""Tag development version."""
c.run("bumpversion --list %s --message='Bump develop version [ci skip]' --no-tag" % level)
if new_version:
new_version = f" --new-version {new_version}"
elif level == "release":
c.run("bump-my-version bump patch --no-commit")
level = "relver"
c.run(f"bump-my-version bump {level} --message='Bump develop version [ci skip]' {new_version} --allow-dirty")


@task(pre=[clean])
Expand Down
Loading