I've been recently using this library/tool for managing versions on our apps, but there are still some aspects that are not fully clear to me.
Right now, we are using a very simplistic, automatic versioning, just so we have versioning at all, by having a version.json file like this:
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.0",
"publicReleaseRefSpec": [ "^refs/heads/master$" ],
"cloudBuild": {
"buildNumber": {
"enabled": true
}
}
}
For now, this generates version numbers such as 1.0.14.51447, which work well enough for the current purpose.
However, this is obviously not how it was really intended to be used. For one, we never actually touch the version attribute in the version.json file, which is something that, as far as I understand, one is supposed to be doing every time there is an intent of releasing a new version.
Second, our number there is obviously not following semantic versioning (after all, we are never updating major or minor components), which is something I would like to start using, if we can do it without too much maintenance overhead.
But my main question really is in regards to our simpler branching structure. We currently try to use trunk-based development as much as possible, meaning we don't use "release branches" anymore. Instead, we just tag the commit with the release number and keep going on the master branch. The only time a release branch is created is when a hotfix is needed: then, a branch is created from the release tag, changes are performed there, and a new deployment pipeline is fired for the hotfix.
With these constraints/facts in mind, I'm a bit lost as to how I should be using nbgv to improve the way we are doing versioning. I don't really want the overhead of manually updating the version every time we have a new feature or a bug fix, since that would be basically every single change we make. Most of our projects are not libraries, but APIs, web apps, CLI apps, etc. Still, it would be very nice to have semantic versioning in place, so we could compare version numbers and know exactly what types of changes are involved (especially if there are breaking changes).
The first thing I was thinking about was using the prepare-release command with a computed versionIncrement value, based on "the commits since the last release", which would then give me an automatic way to compute the version number and remove the burden of manually setting that. But then I found out that prepare-release requires a release branch in the first place.
There is nbgv tag command which only creates tags, but that one doesn't have the versionIncrement argument, which makes it impossible to use for this purpose.
I feel like I must be missing something here considering how flexible and widely used this tool is. Surely trunk-based development with versioned API/Web projects is not that outlandish to not be doable properly?
In my mind, the ideal configuration would be to not have any version number declared on version.json, and have nbgv tag with support for versionIncrement as the main mechanism for "bumping the version". If this existed, and I could somehow compute what type of increment I needed given the list of commits since the previous release (this is not something I've done yet, but I'd like to automate it), then I could run this command after my deployment step and have that trigger a Github Release entry.
Apologies if this seems a bit confusing, it's just that I feel like I'm using this tool the wrong way at the moment, and I don't really know how to use it the right way considering our simplified deployment/release strategy.
I've been recently using this library/tool for managing versions on our apps, but there are still some aspects that are not fully clear to me.
Right now, we are using a very simplistic, automatic versioning, just so we have versioning at all, by having a
version.jsonfile like this:{ "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", "version": "1.0", "publicReleaseRefSpec": [ "^refs/heads/master$" ], "cloudBuild": { "buildNumber": { "enabled": true } } }For now, this generates version numbers such as
1.0.14.51447, which work well enough for the current purpose.However, this is obviously not how it was really intended to be used. For one, we never actually touch the
versionattribute in theversion.jsonfile, which is something that, as far as I understand, one is supposed to be doing every time there is an intent of releasing a new version.Second, our number there is obviously not following semantic versioning (after all, we are never updating major or minor components), which is something I would like to start using, if we can do it without too much maintenance overhead.
But my main question really is in regards to our simpler branching structure. We currently try to use trunk-based development as much as possible, meaning we don't use "release branches" anymore. Instead, we just tag the commit with the release number and keep going on the
masterbranch. The only time a release branch is created is when a hotfix is needed: then, a branch is created from the release tag, changes are performed there, and a new deployment pipeline is fired for the hotfix.With these constraints/facts in mind, I'm a bit lost as to how I should be using
nbgvto improve the way we are doing versioning. I don't really want the overhead of manually updating the version every time we have a new feature or a bug fix, since that would be basically every single change we make. Most of our projects are not libraries, but APIs, web apps, CLI apps, etc. Still, it would be very nice to have semantic versioning in place, so we could compare version numbers and know exactly what types of changes are involved (especially if there are breaking changes).The first thing I was thinking about was using the
prepare-releasecommand with a computedversionIncrementvalue, based on "the commits since the last release", which would then give me an automatic way to compute the version number and remove the burden of manually setting that. But then I found out thatprepare-releaserequires a release branch in the first place.There is
nbgv tagcommand which only creates tags, but that one doesn't have theversionIncrementargument, which makes it impossible to use for this purpose.I feel like I must be missing something here considering how flexible and widely used this tool is. Surely trunk-based development with versioned API/Web projects is not that outlandish to not be doable properly?
In my mind, the ideal configuration would be to not have any version number declared on
version.json, and havenbgv tagwith support forversionIncrementas the main mechanism for "bumping the version". If this existed, and I could somehow compute what type of increment I needed given the list of commits since the previous release (this is not something I've done yet, but I'd like to automate it), then I could run this command after my deployment step and have that trigger a Github Release entry.Apologies if this seems a bit confusing, it's just that I feel like I'm using this tool the wrong way at the moment, and I don't really know how to use it the right way considering our simplified deployment/release strategy.