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

How to use distance_to_latest_tag to automate pre-release numbers? #193

Open
hcording opened this issue May 23, 2024 · 3 comments
Open

How to use distance_to_latest_tag to automate pre-release numbers? #193

hcording opened this issue May 23, 2024 · 3 comments

Comments

@hcording
Copy link

  • bump-my-version version: 0.21.1
  • Python version: 3.10
  • Operating System: Linux Mint 21.3

Description

I checked the README and existing issues, trying to automate the bump of pre-release numbers (alpha0, alpha1, ...) whenever I commit. However, the version doesn't change when I do git commit.

What I Did

This is my .bumpmyversion.toml

[tool.bumpversion]
current_version = "1.0.0-alpha0"
parse = """(?x)
    (?P<major>0|[1-9]\\d*)\\.
    (?P<minor>0|[1-9]\\d*)\\.
    (?P<patch>0|[1-9]\\d*)
    (?:
        -                             # dash separator for pre-release section
        (?P<pre_l>[a-zA-Z-]+)         # pre-release label
        (?P<pre_n>0|[1-9]\\d*)        # pre-release version number
    )?                                # pre-release section is optional
"""
serialize = [
    "{major}.{minor}.{patch}-{pre_l}{distance_to_latest_tag}",
    "{major}.{minor}.{patch}",
]
search = "{current_version}"
replace = "{new_version}"
regex = false
ignore_missing_version = true
ignore_missing_files = false
tag = false
sign_tags = false
tag_name = "v{new_version}"
tag_message = "Bump version: {current_version} → {new_version}"
allow_dirty = false
commit = false
message = "Bump version: {current_version} → {new_version}"
commit_args = ""

[tool.bumpversion.parts.pre_l]
values = ["alpha", "beta", "rc", "final"]
optional_value = "final"

[[tool.bumpversion.files]]
filename = "versions.json"

Did I miss something obvious? I couldn't find any detailed instructions on how to use this feature, the README just says "Release candidate versions increase automatically with each commit." - but this isn't the case for me. Or is this entirely meant as a GitHub Actions / CICD feature?

@coordt
Copy link
Member

coordt commented May 23, 2024

Yea the docs may be a bit misleading here. Either manual or automation is required to call bump-my-version.

If you want to automate pre-releases I would use branches and github actions. Take a look at the automation in this repo for ideas.

I'll try to do a more complete write up soon, but feel free to ask follow-up questions.

@hcording
Copy link
Author

Yea the docs may be a bit misleading here. Either manual or automation is required to call bump-my-version.

If you want to automate pre-releases I would use branches and github actions. Take a look at the automation in this repo for ideas.

I'll try to do a more complete write up soon, but feel free to ask follow-up questions.

Yeah I think clarifying this in the docs would be super helpful. I'll take a look at the actions in this repo for inspiration, thanks!

@hcording
Copy link
Author

Okay I've taken a look, but still unsure how to actually bump the version automatically with a pre-commit hook for example. I thought it would be something like bump-my-version bump pre_n, but this doesn't work for me, it's bumping e.g. 0.2.0-alpha0 to 0.2.0. Is there a command to bump the pre-release version number when using distance_to_latest_tag? I'd only want this automation to increase pre_n when there actually is a pre-release version number to bump, otherwise do nothing. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants