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

Question: how to use parse to deal only with major version? #113

Closed
padamstx opened this issue Jan 6, 2020 · 5 comments · Fixed by #115
Closed

Question: how to use parse to deal only with major version? #113

padamstx opened this issue Jan 6, 2020 · 5 comments · Fixed by #115

Comments

@padamstx
Copy link
Contributor

padamstx commented Jan 6, 2020

Hi, after discovering this more up-to-date fork of the original bumpversion project, I'm in the process of switching over to it and I have a question.

I already use bumpversion to maintain version #'s in a few files, where the version # is the full version # (e.g. 3.2.5). I have a scenario where I want to maintain only the major version # within a go.mod file. Within this file I have a module directive like this:

module github.com/IBM/go-sdk-core/v3

where "3" represents the current major version of the package. I'd like to be able to configure bumpversion to bump this to "v4" when the next major version is created.
It looks like I could maybe use a combination of the "parse" and "search" directives within a [bumpversion:file:...] section in my cfg file. Anyone done this before?
It would be great if the README contained an example of this (after figuring this out, I would be happy to submit a PR for that).
Thanks in advance!

@ekohl
Copy link
Collaborator

ekohl commented Jan 6, 2020

I think you should be using parse and serialize and set those on for a specific file.

@florisla
Copy link
Collaborator

florisla commented Jan 6, 2020

I just wrote an example config that does exactly this in #43 .

Here it is, adapted to your situation and verified to work...
If you make the pull request you promised ;-)

.bumpversion.cfg:

[bumpversion]
current_version = 4.1.0

[bumpversion:file:version.txt]

[bumpversion:file:go-sdk.txt]
parse = (?P<major>\d+)
serialize = {major}
search = module github.com/IBM/go-sdk-core/v{current_version}
replace = module github.com/IBM/go-sdk-core/v{new_version}

version.txt:

4.1.0

go-sdk.txt:

module github.com/IBM/go-sdk-core/v4

Testing it out:

>>> bumpversion --verbose minor
current_version=4.1.0
new_version=4.2.0
>>> bumpversion --verbose major
current_version=4.2.0
new_version=5.0.0
>>> bumpversion --verbose minor
current_version=5.0.0
new_version=5.1.0
>>> cat go-sdk.txt
module github.com/IBM/go-sdk-core/v5

@padamstx
Copy link
Contributor Author

padamstx commented Jan 8, 2020

Here it is, adapted to your situation and verified to work...
If you make the pull request you promised ;-)

Thanks a bunch for working up this example! I will do the README PR, later this week. I promise! :)

@padamstx
Copy link
Contributor Author

padamstx commented Jan 9, 2020

@florisla I'm ready to add a "go.mod" example to the project's README file. I think there are two options for this:

  1. add a brief example as part of the discussion around the parse option
  2. add a new paragraph underneath Using bumpversion in a script with heading something like Using bumpversion to maintain a go.mod file

I'm sort of leaning toward #2. Do you have a preference?

@florisla
Copy link
Collaborator

I would go for #2 and move the examples to a separate file (or a repository folder) once we have more of them.

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

Successfully merging a pull request may close this issue.

3 participants