Hi Joe,
Firstly, I suspect you already know this but just in case, a release can take it’s version from an included NuGet package. This is great if one your packages is already versioned as you would like your release to be. This can be done via Project -> Settings -> Release Versioning
.
Assuming you don’t want to take the version from an included package, then unfortunately you can’t currently achieve exactly what you want, as the version template is defined at the Project level, rather than at the Channel level.
However, that wasn’t the answer I wanted to give you, and we have a hunch that with a small change you would be able to do the following:
- Define a variable scoped to your Default channel, e.g.
IsProd
and set it’s value to True
.
- Define a variable scoped to your Dev channel, e.g.
IsPreRelease
and set it’s value to True
.
- Enter the following in the
Project ->Settings -> Version Template
field:
#{if IsProd}
#{Octopus.Version.Channel.LastMajor}.#{Octopus.Version.Channel.LastMinor}.#{Octopus.Version.Channel.NextPatch}
#{/if}
#{if IsPreRelease}
#{Octopus.Version.Channel.LastMajor}.#{Octopus.Version.Channel.LastMinor}.#{Octopus.Version.Channel.LastPatch}#{Octopus.Version.Channel.NextSuffix}
#{/if}
The above template is using different values depending on which of the IsProd
or IsPreRelease
variables are set.
You can follow the issue above. If all goes well, it should be released in the next few days. Either way, I will update this ticket.
In the meantime (or if that change can’t be completed for any reason), I think your best option may be to set the Version template to:
#{Octopus.Version.Channel.LastMajor}.#{Octopus.Version.Channel.LastMinor}.#{Octopus.Version.Channel.LastPatch}#{Octopus.Version.Channel.NextSuffix}
This will work for the pre-release channel, but you will need to manually increment the version number for releases to the production channel. I’m assuming these happen less frequently.
With either approach you will also want to set the Package Version Rules for each channel, to select only packages without a pre-release suffix for the prod channel (and vice-versa for the dev channel). Details of doing so can be found in the “Version Rules” section of the Channels document.
I hope this helps,
Michael