[Release Versioning] :: Generate Version number based on included package and channel name

Hi Team,

While defining Release Versioning of a project, we can either

  1. Generate version numbers using a template (default)
  2. Use the version number from an included package.

We need the best of both worlds where we can use #2 along with the channel name.

So if we create a release with ‘alpha’ channel and ‘Deploy package’ step is using ‘3.1.11’ then the release version would be 3.1.11-alpha

I tried various combos, nothing worked. :frowning:

What would be the template for this? or
If you can give me a template for #2 then we can create #2Template-#{Octopus.Release.Channel.Name}


Hi @Nikhil_Agrawal

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:

The channel name can also be used (generally as part of the suffix):


For the default channel this would result in:

For the Alpha channel, this would result in:

If you didn’t want the default channel to have -Default added to the release name, then you can omit it using some extended if syntax like so:

The complete version text is:

#{Octopus.Version.Channel.LastMajor}.#{Octopus.Version.Channel.LastMinor}.#{Octopus.Version.Channel.NextPatch}#{if Octopus.Release.Channel.Name != "Default"}-#{Octopus.Release.Channel.Name}#{/if}

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.

I hope that helps!

Hi Mark,

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?


Hi @Nikhil_Agrawal

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.

I hope that helps.


This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.