Skip to content

Commit b70f49f

Browse files
authored
Merge pull request #179 from minrk/chartpress-base-version
use baseVersion config to set the base version for development releases
2 parents 54e9325 + ff92d30 commit b70f49f

File tree

5 files changed

+247
-225
lines changed

5 files changed

+247
-225
lines changed

README.md

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,14 @@ charts:
171171
# version to use when resetting the Chart.yaml's version field with the
172172
# --reset flag. It defaults to "0.0.1-set.by.chartpress". This is a valid
173173
# SemVer 2 version, which is required for a helm lint command to succeed.
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`
174+
resetVersion: 1.2.3-dev
175+
176+
# baseVersion sets the base version for development tags,
177+
# instead of using the latest tag from `git describe`.
177178
# 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
179+
# and lets you ensure prerelease tags are always sorted in the right order.
180+
# Only useful when publishing development releases.
181+
baseVersion: 3.2.1-0.dev
180182

181183
# The git repo whose gh-pages contains the charts. This can be a local
182184
# path such as "." as well but if matching <organization>/<repo> will be
@@ -239,25 +241,24 @@ charts:
239241
- linux/arm64
240242
```
241243
242-
### Controlling development versions in Chart.yaml
244+
### Controlling development versions
243245
244246
Like some "package version in version control" tools,
245247
you don't need to manage versions at all in chartpress except by tagging commits.
246248
247249
However, relying only on tags results in "development versions" (versions published from commits after a release)
248250
having somewhat confusing prerelease versions.
249251
250-
After publishing e.g. `1.2.3`, the next version will be `1.2.3-0.dev.git.1.habc`.
252+
After publishing e.g. `1.2.3`, the next version will be `1.2.3-0.dev.git.10.habc`.
251253
According to Semantic Versioning,
252254
this is a "pre release" (good, it should be excluded from default installation),
253255
but it means it comes _before_ 1.2.3 (wrong! it's 1 commit _newer_ than 1.2.3).
254256
This is because prereleases should be defined relative to the _next_ release,
255257
not the _last_ release. But git tags only store the _last_ release!
256258

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.
259+
Chartpress 2.0 adds an option `chart.baseVersion`,
260+
which allows setting the base version of development tags explicitly,
261+
instead of using the version of the last tag found via `git describe`.
261262

262263
The main benefits of this are:
263264

@@ -267,55 +268,46 @@ The main benefits of this are:
267268
Instead of publishing the sequence:
268269

269270
- 1.2.3
270-
- 1.2.3-0.dev.git.1.habc (later than 1.2.3, but sorts _before_ 1.2.3!)
271+
- 1.2.3-0.dev.git.10.habc (later than 1.2.3, but sorts _before_ 1.2.3!)
271272

272273
You can publish
273274

274275
- 1.2.3
275-
- 1.3.0-0.dev.git.1.habc (prerelease based on the _next_ version, not _last_)
276+
- 1.3.0-0.dev.git.10.habc (prerelease based on the _next_ version, not _last_)
276277

277-
where chartpress will use the version in your Chart.yaml as the base version,
278+
where chartpress will use the version in your `baseVersion` config as the base version,
278279
instead of the last tag on the branch.
279280

280-
This takes some extra configuration, and steps in your release process
281-
to update the version in your Chart.yaml.
281+
This takes some extra configuration, and steps in your release process:
282282

283-
1. You must set `useChartVersion: true` in your chartpress.yaml:
283+
1. You must set `baseVersion: 1.2.3-0.dev` in your chartpress.yaml to your _next_ prerelease:
284284

285285
```yaml
286286
charts:
287287
- name: mychart
288-
useChartVersion: true
288+
baseVersion: 1.2.3-0.dev
289289
```
290290

291-
2. You must control the version in Chart.yaml, especially after making a release.
291+
2. You must update baseVersion, especially after making a release.
292292

293293
A release process would generally look like this:
294294

295295
```bash
296296
V=1.2.3
297-
chartpress --reset --tag "$V"
298-
git commit -am "release $V"
299297
git tag -am "release $V" "$V"
300298
git push --atomic --follow-tags
301299
302300
# 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"
301+
NEXT_V=1.2.4-0.dev
302+
# edit chartpress.yaml to set baseVersion: $NEXT_V
303+
git add chartpress.yaml
304+
git commit -m "Back to $NEXT_V"
306305
git push --atomic
307306
```
308307

309308
Any prerelease fields (such as `-0.dev` above, or `-alpha.1`)
310309
will be left as-is, with the `.git.n.hash` suffix added.
311310

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-
319311
## Caveats
320312

321313
### Shallow clones

0 commit comments

Comments
 (0)