-
Notifications
You must be signed in to change notification settings - Fork 664
Description
One of the values that the configuration option assembly-versioning-scheme can be set to is MajorMinorPatchTag. This is great except that that 'tag' does not really encode the full information form PreReleaseTag. Instead of it, it is replaced by PreReleaseNumber, which carries only a subset of information from PreReleaseTag: it ignores PreReleaseLabel. As a consequence, versions 1.2.3-unstable.1 and 1.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 to PreReleaseNumber to form PreReleaseTagNumber. This PreReleaseTagNumber will be used as the fourth number (revision) in AssemblyVersion when assembly-versioning-scheme is set to MajorMinorPatchTag.
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:
branches:
develop:
tag: alpha
tag-offset: 0
release:
tag: beta
tag-offset: 1000
master:
tag-offset: 2000
Then we get the following PreRelaseTagNumber:
- 1.2.3-alpha.1 on develop is 1
- 1.2.3-beta.1 on release/1.2 is 1001
- 1.2.3 on master is 2000
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.