I don’t know if you’re aware but one simple way to achieve what you’re after might be to use the second option e.g. Use the version number from an included package. and then have your package version include the channel name as a pre-release version e.g. like so:
You can also design package version rules which ensures you can’t deploy a package to a channel where it’s not allowed.
The other option available to you today, is to use number 1 e.g. Generate version numbers using a template (default) and to use the special variables supported in the template for Channel (prefixed with Octopus.Version.Channel e.g:
This option is simpler than the package step option, but does mean you’d need to keep your Octopus release versions in general sync with your package versions.
Thanks for replying. Both options have their pros and cons.
#1 With Template option
It does provide the channel name out-of-the-box but like you said it can disconnect with the actual package version and we have to ensure every time that the two remain in sync.
(Sometimes, it could happen that our CI jumps a few versions and Octopus increments from the last release it created).
#2 With included package option
While it remains tightly coupled with included version, it does not provide pre-release names based on Octopus channels. We have a case where the pre-release version is not the same as the Octopus channel name.
Precuisely the reason why we wanted to have the best of both options - TemplateOfSecondOption-#{Octopus.Release.Channel.Name}.
Is it the case that #2 template is not available on the release level and is created by bespoke code hidden inside and not exposed via system variables?
That’s correct, if you choose the second option (Use the version number from an included package) Octopus doesn’t let you change the release template, it’ll always match the package version selected from the step chosen in the release template.
The other alternative, and this will depend if you’re always creating releases outside of Octopus e.g. within your CI is to specify the release version up-front by writing a script to determine the version before you create the release.