-
Notifications
You must be signed in to change notification settings - Fork 647
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
Introduce PreRelaseTagNumber variable to encode complete PreReleaseTag in a number #1145
Comments
I like the idea. I wonder if we could capture this as guidance rather than adding into GitVersion itself. The reason I say that is because this could be a confusing feature to explain unless you have a specific problem. I feel you with the conversion to the |
Sounds good. Having a numeric variable would already help a lot. How do you see it working with |
That sounds reasonable |
OK, so just to check my understanding with examples: Example GitVersion.yml: assembly-versioning-scheme: MajorMinorPatchNumericTag
branches:
develop:
tag: alpha
numeric-only-tag-offset: 0
release:
tag: beta
numeric-only-tag-offset: 1000
master:
numeric-only-tag-offset: 2000 Then we get the following:
|
How about we just use |
If what I describe in #1157 (comment) sounds like a fitting solution to this problem, I propose that we close this as a duplicate of #1157. |
Unfortunately, the proposal in #1157 (comment) does not solve this problem, although it has a potential to address a part of it. More specifically, it addresses the But for this problem, this is the last part. Before that, we need a way of converting the tag (label) to a numeric format and making it available through a variable. Even if we forget (or solve) the assembly versioning scheme problems, this is still needed. Part of the difficulty here is inconsistent terminology already implemented, which needs to stay to prevent breaking changes. Following the documentation, if we have a semantic version 1.2.3-beta.4, then 1 is The latest proposal by @JakeGinnivan is to introduce a new variable, say, So, the bottom line is that both issues can be implemented in parallel and fairly independently form each other as they address different goals. |
What do you think about the term "weight", so This approach would also solve our issue with Windows Installer, see #1366. |
Setting The term “weight” and related names as proposed by @jbaehr would work. |
@BCSharp GitVersion already provides the Now that the PR #1385 is merged, you can use an env var in the format string to provide a // Note the /nocache switch! it is required in order to bypass the cache;
// else the GitVersionTask via MsBuild won't evaluate the format string again and only see the fallback value from this call here
// Also not that it *must* be "/output buildserver /nocache"; the other way round "/nocache /output buildserver" won't write the properties file!
bat '\\path\\to\\GitVersion\\4.0.0-beta0013custom1\\GitVersion.exe /output buildserver /nocache'
def props = readProperties file: 'gitversion.properties'
def preReleaseWeight = [alpha:0, beta:30000, '':60000] // no prerelease-label means final release
def currentWeight = preReleaseWeight.get(props.GitVersion_PreReleaseLabel, 0) // default: 0 for everything else not in the mapping
def toIntOrZero = { try { Integer.parseInt(it) } catch (NumberFormatException) { 0 }} // GitVersion_PreReleaseNumber may be an empty string
def weightedPreReleaseNumber = toIntOrZero(props.GitVersion_PreReleaseNumber) + currentWeight
withEnv(["WeightedPreReleaseNumber=${weightedPreReleaseNumber}"]) {
// calling msbuild....
} So basically call gitversion, use The downside is that gitversion is executed twice and the gotcha with the order of the CLI parameters and the requirement for |
Yes, there are workarounds possible. I have mine too, all done in MSBuild scripts, using GitVersionTask; I do not use Jenkins. Not that the workarounds are nice. Having #1385 helps, though. |
#1433 Waiting for this PR to get merged |
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions. |
One of the values that the configuration option
assembly-versioning-scheme
can be set to isMajorMinorPatchTag
. This is great except that that 'tag' does not really encode the full information formPreReleaseTag
. Instead of it, it is replaced byPreReleaseNumber
, which carries only a subset of information fromPreReleaseTag
: it ignoresPreReleaseLabel
. As a consequence, versions1.2.3-unstable.1
and1.2.3-beta.1
will produce identical assembly version 1.2.3.1, causing version collision.It is often desirable to encode complete semantic version information in numbers. It is nice to have for assembly version, but essential for e.g Android apps, which have to have unique
android:codeVersion
values in their manifests. Therefore, for those of us who need it, I propose the following scheme of encoding pre-relase label into the number used in MajorMinorPatchTag versioning:Each branch configuration can specify
tag-offset
value, being a number (0 by default). This number will be added toPreReleaseNumber
to formPreReleaseTagNumber
. ThisPreReleaseTagNumber
will be used as the fourth number (revision) inAssemblyVersion
whenassembly-versioning-scheme
is set toMajorMinorPatchTag
.By default, each tag offset is 0, which will maintain the currently implemented behaviour. However, the user can set it to different values together with custom tag labels and in this way differenciate between pre-release tags. For completeness, tag offset has to be applied (if specified) even on branches that do not have pre-release tags, e.g. master. For master,
PreReleaseNumber
is empty, revision number in assembly version defaults to 0, but adding a tag offset allows for proper ordering of revisions in assembly versions:Example GitVersion.yml:
Then we get the following
PreRelaseTagNumber
:This is just a proposal. I am interested in other ideas of handling the problem. Basically my requirement is to be able to uniquely encode the complete semantic version information in a sequence of numbers, in a flexible enough way such that the ordering is controllable.
The text was updated successfully, but these errors were encountered: