Skip to content

Commit f411d05

Browse files
authored
Fix unsafe recommended calver release expression (#3231)
1 parent 857a331 commit f411d05

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: src/layouts/Default.astro
33
pubDate: 2023-01-01
4-
modDate: 2024-05-20
4+
modDate: 2026-07-02
55
title: Release versioning
66
description: Select how the next release number is generated when creating a release.
77
icon: fa-solid fa-code-commit
@@ -22,72 +22,72 @@ Within a project, click **Settings ➜ Release Versioning**:
2222

2323
You can use variables from the project (un-scoped or scoped only to a channel). In addition, some special variables are provided - example:
2424

25-
```
25+
```text
2626
1.2.#{Octopus.Version.NextPatch}-pre
2727
```
2828

2929
These special variables take the form:
3030

31-
```
31+
```text
3232
Octopus.Version.(Last|Next)(Major|Minor|Patch|Build|Revision|Suffix)
3333
```
3434

3535
If you are using channels, channel-specific special variables are also available:
3636

37-
```
37+
```text
3838
Octopus.Version.Channel.(Last|Next)(Major|Minor|Patch|Build|Revision|Suffix)
3939
```
4040

4141
Version components from other channels in the project can be referenced using the channel name as the index:
4242

43-
```
43+
```text
4444
Octopus.Version.Channel[ChannelName].(Last|Next)(Major|Minor|Patch|Build|Revision|Suffix)
4545
```
4646

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

49-
```
49+
```text
5050
Octopus.Release.Channel.Name
5151
```
5252

5353
The version can also include Octopus *semantic version mask* characters i and c referring to the **incremented** and **current** values of the version, respectively. For example:
5454

55-
```
55+
```text
5656
2.1.c.i
5757
```
5858

5959
Finally, date fields can be also be used, for example:
6060

61-
```
61+
```text
6262
#{Octopus.Date.Year}.#{Octopus.Date.Month}.#{Octopus.Date.Day}
6363
```
6464

6565
These take the form:
6666

67-
```
67+
```text
6868
Octopus.Date.(Day|Month|Year|DayOfYear)
6969
Octopus.Time.(Hour|Minute|Second)
7070
```
7171

7272
## Complex expressions
7373

74-
The full power of the [Octopus variable syntax](/docs/projects/variables/variable-substitutions/#complex-syntax) (powered by [Octostache](https://github.com/OctopusDeploy/Octostache)) is available in version templates. In particular, [conditional expressions](/docs/projects/variables/variable-substitutions/#conditionals) can be used to model some complex scenarios.
74+
The full power of the [Octopus variable syntax](/docs/projects/variables/variable-substitutions/#complex-syntax) (powered by [Octostache](https://github.com/OctopusDeploy/Octostache)) is available in version templates. In particular, [conditional expressions](/docs/projects/variables/variable-substitutions/#conditionals) can be used to model some complex scenarios.
7575

7676
### Example: Date with incrementing revision
7777

78-
A relatively common versioning scheme is:
78+
A relatively common versioning scheme is:
7979

80-
```
80+
```text
8181
YEAR.MONTH.DAY.REVISION
8282
```
8383

84-
where `REVISION` starts at 0 each day and increments with each release. i.e. The releases on one day might be `2020.10.2.0`, `2020.10.2.1`, `2020.10.2.2` ... and the following day may be: `2020.10.3.0`, `2020.10.3.1` etc.
84+
where `REVISION` starts at 0 each day and increments with each release. i.e. The releases on one day might be `2020.10.2.0`, `2020.10.2.1`, `2020.10.2.2` ... and the following day may be: `2020.10.3.0`, `2020.10.3.1` etc.
8585

8686
This can be achieved using the following expression:
8787

88-
```
88+
```text
8989
#{Octopus.Date.Year}.#{Octopus.Date.Month}.#{Octopus.Date.Day}.
90-
#{if Octopus.Date.Day==Octopus.Version.LastPatch}
90+
#{if Octopus.Date.Day==Octopus.Version.LastPatch | Format Int32 D2}
9191
#{Octopus.Version.NextRevision}
9292
#{else}
9393
#{if Octopus.Version.LastRevision!=0}
@@ -97,10 +97,15 @@ This can be achieved using the following expression:
9797
#{/if}#{/if}
9898
```
9999

100-
The expression above is equivalent to:
100+
:::div{.warning}
101+
This example is no longer recommended for production workloads due to the potential for unexpected version
102+
conflicts arising from inconsistencies between date formats. The mask-based alternative provided below
103+
should be preferred.
104+
:::
101105

102-
```
106+
```text
103107
#{Octopus.Date.Year}.#{Octopus.Date.Month}.#{Octopus.Date.Day}.i
104108
```
105109

106-
The difference is that the `i` is not replaced until the release is saved where the complex expression will show the next increment number before it is saved.
110+
The `i` mask character increments the previous release's revision component by one on every release. Note
111+
that the revision component will reset whenever any part of the date changes from the previous release.

0 commit comments

Comments
 (0)