[Question] How can I publish nightly version e.g. 4.8.0-nightly.{height}.{ciJobNumber}?
rwoll opened this issue · 2 comments
I want to setup a cron-job that runs nightly and always builds tip-of-tree (on main
) of our package and then pushes it to a preview NuGet feed. The main motivation here is to ensure that our end-to-end build, package, publish, consume pipeline is always in working order (even when days or weeks go by w/out new commits).
The Nerbank versions.json
gets me close:
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "4.8.0-nightly.{height}",
"publicReleaseRefSpec": [
"^refs/heads/release/v\\d+\\.\\d+\\.\\d+$"
],
"release": {
"branchName": "release/v{version}"
}
}
but if a day goes by w/out any new commits on main
, it will produce two duplicate package versions. I'd like to incorporate the the ciJobNumber
into the version (maybe 2.3.0-nightly.{height}.{ciJobNumber}
). Is it possible to do this with Nerdbank? I looked through https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/cloudbuild.md, but it looks like that's about having Nerbank set your CI environment's variables, not CI environment's variables influencing Nerdbank. Is that correct?
that's about having Nerbank set your CI environment's variables, not CI environment's variables influencing Nerdbank. Is that correct?
Correct.
If you really want to do this, you'll have to customize the package version yourself. NB.GV won't help you create non-deterministic versions. But it is customizeable. Check out the doc at https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/msbuild.md#custom-build-authoring
The property you'll want to override is PackageVersion
, and you can just set it to itself, appending the ciJobNumber
that you mentioned.
Awesome - thanks for the additional information. Closing!