-
Notifications
You must be signed in to change notification settings - Fork 80
versioning
Package versioning is an important topic.
- goxc has been designed to support semantic versioning.
- goxc supports branch naming (use a local config override file - e.g. .goxc.local.json - to store your branch info)
- goxc can interpolate your version number at build time (it uses a build flag for this)
The version number has been split into four optional variables.
The reason for this is to allow for branches and local versions to be labelled appropriately.
When all four variables are used, the version number would be:
<PackageVersion>-<BranchName>.<PrereleaseInfo>+b<BuildName>
Treat the package version as the semantic versioning major.minor.patch
e.g. 0.0.1
Typically you could use 'snapshot', 'alpha' or 'rc.1' here.
This is where you'd put the name of your fork, if you've forked someone's goxc project
'Branch name' isn't part of the semantic versioning standard, so we have just subsumed it into the prerelease info part of the version.
Here you can put the build number as often used in semantic versioning.
- -pv = Package Version
- -pr = Prerelease Info
- -br = Branch name
- -bu = Build name
It's easiest to provide an example, as follows. In this imaginary example we have forked an existing go project which already used goxc.
The .goxc.json file contains the following version information:
{
"ConfigVersion": "0.9",
"PackageVersion": "0.0.1",
"PrereleaseInfo": "alpha"
}
.goxc.local.json has been 'git-ignored', so you create one yourself, and here you put the Branch Name.
Here you can also overrdie the prerelease info, and add a build name, without affecting the
{
"ConfigVersion": "0.9",
"PrereleaseInfo": "snapshot",
"BranchName": "laher",
"BuildName": "123"
}
This will produce a version number 0.0.1-laher.snapshot+b123
Please see config for more details about .goxc config files.
goxc uses a build flag - -ldflags "-X main.VERSION 0.0.1-laher.snapshot+b123" - to interpolate your version number. This allows you to build a version number into your executable.
If you have defined a variable 'main.VERSION', then this will be populated at compile time.