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

Previous version gives Next version #84

Open
DJViking opened this issue May 26, 2021 · 8 comments
Open

Previous version gives Next version #84

DJViking opened this issue May 26, 2021 · 8 comments
Labels

Comments

@DJViking
Copy link
Contributor

DJViking commented May 26, 2021

Have version 1.5.0 in build.gradle

> jx-release-version -previous-version from-file
1.5.1
> jx-release-version -next-version from-file
1.5.0

Is this the alternate universe where things are reversed?

On branch master, where the latest git tag is v1.6.3

> jx-release-version -next-version
1.6.4
> jx-release-version -previous-version from-tag
1.6.4

There is no previous tag v1.6.4
Expected output:
1.6.4 and 1.6.3

@vbehar
Copy link
Collaborator

vbehar commented May 26, 2021

Hi,

so, as explained in the README, the -previous-version flag control the strategy used to read the previous version - and just that. and the -next-version control the strategy used to bump the previous version to the next one.

  • jx-release-version -previous-version from-file => with 1.5.0 in your build.gradle, it will use 1.5.0 as the previous version, and then bump it using the semantic strategy (by default), which will produce 1.5.1 (unless you have a "feat" commit for example)
  • jx-release-version -next-version from-file => with 1.5.0 in your build.gradle, it will use 1.5.0 as the next version, and print it. I agree that it's not really useful, unless if you need to format the version...
  • jx-release-version -next-version => the strategy is empty, so it will uses the default, which is the same as just jx-release-version. with a latest tag of 1.6.3, it will retrieve this tag, bump it using the semantic strategy, and print 1.6.4
  • jx-release-version -previous-version from-tag => from-tag is also the default strategy to read the previous version, so it's once again equivalent to jx-release-version, and will read 1.6.3, bump it, and print 1.6.4.

@DJViking
Copy link
Contributor Author

so, as explained in the README, the -previous-version flag control the strategy used to read the previous version - and just that

But it gave me the next version, not the previous one.

@DJViking
Copy link
Contributor Author

DJViking commented May 27, 2021

Let me see if I understand this one now.

The -previous-version, will use the previous version to increment and give you the next version?
It takes the previous version, v1.5.5, and produces 1.5.6.

jx-release-version == jx-release-version -previous-version from-tag?

@DJViking
Copy link
Contributor Author

DJViking commented May 27, 2021

The rewrite makes it a little more difficult to support automatic versioning.
Where you have the base version in build.gradle or some other file, use that version to find the latest git tag, and increment it to give the next version.

version = '1.5.0'
latest git tag = v1.5.5
jx-release-version = 1.5.6

@vbehar
Copy link
Collaborator

vbehar commented May 27, 2021

so, as explained in the README, the -previous-version flag control the strategy used to read the previous version - and just that

But it gave me the next version, not the previous one.

yes, it's the whole purpose of this project ;-) if you just want to get the "previous" (or current) version, you can just read it from your file ;-) or if you want to use this tool, we can introduce a new no-op strategy to bump the version which does nothing, and so return the previous version

@vbehar
Copy link
Collaborator

vbehar commented May 27, 2021

Let me see if I understand this one now.

The -previous-version, will use the previous version to increment and give you the next version?
It takes the previous version, v1.5.5, and produces 1.5.6.

jx-release-version == jx-release-version -previous-version from-tag?

yes. well in fact the default strategy to read the previous version is bit smarter than "from-tag", because it knows how to handle a git repo with no tags, but you get the idea. by default it finds the latest git tag, increment it, and print the next version.

@vbehar
Copy link
Collaborator

vbehar commented May 27, 2021

The rewrite makes it a little more difficult to support automatic versioning.
Where you have the base version in build.gradle or some other file, use that version to find the latest git tag, and increment it to give the next version.

version = '1.5.0'
latest git tag = v1.5.5
jx-release-version = 1.5.6

that's because you don't follow the "trunk-based development" practice, and you want to support multiple release branches - which is not the main goal of this tool.

however, as I explained, you can use the git tag filter feature to achieve what you want. right now in each release branch you keep what you call the "base version" in your build.gradle file. Instead (or in addition), you can update your release script to include the right prefix - something like jx-release-version -previous-version=from-tag:v1.5 and it will produce the right next version for you.

an alternative would be to add a new strategy - release-branch or something similar - that tries to read the previous version from a file, keep only the "base version" based on a specific pattern, and then use this base version as a filter to read the last git tag, and increment it.
so jx-release-version -previous-version=release-branch:v{{.Major}}.{{.Minor}} would read v1.5.0 from your gradle file, keep v1.5, list all git tag matching the v1.5 prefix, keep the latest one v1.5.5, and increment it to produce v1.5.6 at the end.

@lemeurherve
Copy link
Contributor

lemeurherve commented Aug 11, 2023

I'd like to be able to specify the previous version manually with jx-release-version -previous-version=manual:1.0.0 so I could get a next semantic based version from the current commit, without requiring an existing (and valid) tag.

It does not seem possible ATM, the default -next-version value auto/semantic (that I want to use this tool for) is using in that mode the tags as source for the previous version, and not as I would have expected the specified -previous-version:

$ jx-release-version -debug -previous-version=manual:1.0.0         
DEBUG: jx-release-version 2.6.11 running in debug mode in /Users/veve/j-infra/helm-charts
DEBUG: Using "manual" version reader (with "1.0.0")
DEBUG: Using manual version 1.0.0
DEBUG: Previous version: 1.0.0
DEBUG: Using "auto" version bumper (with "")
DEBUG: Trying to bump the version using semantic release first...
DEBUG: The git repository has no tag for the previous version 1.0.0 - fallback to incrementing the patch component of the previous version
DEBUG: Next version: 1.0.1
1.0.1%

Opened #113 to allow generating a semantic next version without any tag, commits or even repository.

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

No branches or pull requests

3 participants