@@ -25,22 +25,27 @@ Chartpress will infer chart versions and image tags using a few key pieces of
25
25
information.
26
26
27
27
1 . ` tag ` : If not directly set by ` --tag ` , it will be inferred from most recent
28
- commit that is tagged in the _ current branch_ , or be set to 0.0.1 if no
29
- commit is tagged.
28
+ commit that is tagged in the _ current branch_
29
+ (as determined by ` git describe ` )
30
+ or be set to 0.0.1 if no commit is tagged.
30
31
1 . If the ` tag ` has a leading ` v ` but is otherwise a valid
31
- [ SemVer2] ( https://semver.org ) version, it will be stripped from Chart.yaml
32
+ [ SemVer2] ( https://semver.org ) version, the ` v ` will be stripped from Chart.yaml
32
33
before its set as Helm 3 requires Helm chart versions to be SemVer2
33
34
compliant.
34
35
1 . The latest commit modifying content in a _ relevant path_ since ` tag ` .
35
- 1 . ` n ` : The latest commit's distance to the tagged commit, described as 3 or
36
- more numbers, prefixed with n.
37
- 1 . ` h ` : The latest commit's abbreviated hash. which is often 7-8 characters,
38
- prefixed with h.
39
- 1 . If ` tag ` (like ` 0.10.0 ` or ` 0.10.0-beta.1 ` ) contains a ` - ` , a ` tag.n.h `
40
- format will be used instead of a ` tag-n.h ` format to be SemVer 2 compliant.
36
+ 1 . ` n ` : The number of commits since the latest tagged commit on the branch, as an integer.
37
+ 1 . ` hash ` : The latest commit's abbreviated hash, which is often 7-8 characters,
38
+ prefixed with ` h ` .
39
+ 1 . If ` tag ` (like ` 0.10.0 ` or ` 0.10.0-beta.1 ` ) contains a ` - ` , a ` tag.git.n.hash `
40
+ format will be used, and otherwise a ` tag-0.dev.git.n.hash ` format will be used.
41
41
1 . If ` --long ` is specified or not. If ` --long ` is specified, tagged commits
42
- will be written out with the ` n.h ` part appended to it, looking something
43
- like ` n000.gabcd123 `
42
+ will always be written out with the ` .git.n.hash ` part appended to it, looking something
43
+ like ` 1.0.0-0.dev.git.0.habcd123 `
44
+
45
+ When producing a development version (with ` .git.n.hash ` on the end),
46
+ The _ base_ version can come from one of two places,
47
+ depending on your configuration.
48
+ See [ Controlling development version] ( #controlling-development-versions-in-chart.yaml ) for more info.
44
49
45
50
### Examples chart versions and image tags
46
51
@@ -49,13 +54,13 @@ order that could come from using chartpress.
49
54
50
55
```
51
56
0.8.0
52
- 0.8.0-n004 .hasdf123
53
- 0.8.0-n010 .hsdfg234
57
+ 0.8.0-0.dev.git.4 .hasdf123
58
+ 0.8.0-0.dev.git.10 .hsdfg234
54
59
0.9.0-beta.1
55
- 0.9.0-beta.1.n001 .hdfgh345
56
- 0.9.0-beta.1.n005 .hfghj456
60
+ 0.9.0-beta.1.git.1 .hdfgh345
61
+ 0.9.0-beta.1.git.5 .hfghj456
57
62
0.9.0-beta.2
58
- 0.9.0-beta.2.n001 .hghjk567
63
+ 0.9.0-beta.2.git.1 .hghjk567
59
64
0.9.0-beta.3
60
65
0.9.0
61
66
```
@@ -167,6 +172,12 @@ charts:
167
172
# --reset flag. It defaults to "0.0.1-set.by.chartpress". This is a valid
168
173
# SemVer 2 version, which is required for a helm lint command to succeed.
169
174
resetVersion : 1.2.3
175
+ # Use the version in Chart.yaml for the base version,
176
+ # instead of the latest tag from `git describe`
177
+ # This gives you more control over development version tags
178
+ # and lets you ensure prerelease tags are always sorted in the right order
179
+ useChartVersion : true
180
+
170
181
# The git repo whose gh-pages contains the charts. This can be a local
171
182
# path such as "." as well but if matching <organization>/<repo> will be
172
183
# assumed to be a separate GitHub repository.
@@ -228,6 +239,83 @@ charts:
228
239
- linux/arm64
229
240
` ` `
230
241
242
+ ### Controlling development versions in Chart.yaml
243
+
244
+ Like some "package version in version control" tools,
245
+ you don't need to manage versions at all in chartpress except by tagging commits.
246
+
247
+ However, relying only on tags results in "development versions" (versions published from commits after a release)
248
+ having somewhat confusing prerelease versions.
249
+
250
+ After publishing e.g. ` 1.2.3`, the next version will be `1.2.3-0.dev.git.1.habc`.
251
+ According to Semantic Versioning,
252
+ this is a "pre release" (good, it should be excluded from default installation),
253
+ but it means it comes _before_ 1.2.3 (wrong! it's 1 commit _newer_ than 1.2.3).
254
+ This is because prereleases should be defined relative to the _next_ release,
255
+ not the _last_ release. But git tags only store the _last_ release!
256
+
257
+ Chartpress 2.0 adds an option `chart.useChartVersion`,
258
+ which changes the base version to use when setting the chart version.
259
+ Instead of using the version of the last tag found via `git describe`,
260
+ it uses the version found in Chart.yaml.
261
+
262
+ The main benefits of this are :
263
+
264
+ 1. ensuring that published prerelease versions show up in the right order, and
265
+ 2. giving you control over the version of a prerelease chart (is it 2.0.0-0.dev or 1.3.1-0.dev?)
266
+
267
+ Instead of publishing the sequence :
268
+
269
+ - 1.2.3
270
+ - 1.2.3-0.dev.git.1.habc (later than 1.2.3, but sorts _before_ 1.2.3!)
271
+
272
+ You can publish
273
+
274
+ - 1.2.3
275
+ - 1.3.0-0.dev.git.1.habc (prerelease based on the _next_ version, not _last_)
276
+
277
+ where chartpress will use the version in your Chart.yaml as the base version,
278
+ instead of the last tag on the branch.
279
+
280
+ This takes some extra configuration, and steps in your release process
281
+ to update the version in your Chart.yaml.
282
+
283
+ 1. You must set `useChartVersion : true` in your chartpress.yaml:
284
+
285
+ ` ` ` yaml
286
+ charts:
287
+ - name: mychart
288
+ useChartVersion: true
289
+ ` ` `
290
+
291
+ 2. You must control the version in Chart.yaml, especially after making a release.
292
+
293
+ A release process would generally look like this :
294
+
295
+ ` ` ` bash
296
+ V=1.2.3
297
+ chartpress --reset --tag "$V"
298
+ git commit -am "release $V"
299
+ git tag -am "release $V" "$V"
300
+ git push --atomic --follow-tags
301
+
302
+ # back to development
303
+ NEXT_V=1.3.0-0.dev
304
+ chartpress --reset --tag "$NEXT_V"
305
+ git commit -am "Back to $NEXT_V"
306
+ git push --atomic
307
+ ` ` `
308
+
309
+ Any prerelease fields (such as `-0.dev` above, or `-alpha.1`)
310
+ will be left as-is, with the `.git.n.hash` suffix added.
311
+
312
+ If the version in Chart.yaml is not a prerelease,
313
+ a prelease version will be constructed with `-0.dev.git.n.hash`.
314
+
315
+ When you use this configuration,
316
+ ` chartpress --reset` strips the `.git...` suffix from the chart version,
317
+ ignoring the `resetVersion` config.
318
+
231
319
# # Caveats
232
320
233
321
# ## Shallow clones
0 commit comments