@@ -581,6 +581,9 @@ def build_images(
581
581
The container build engine.
582
582
platforms (list[str]):
583
583
List of platforms to build for if not the same as the Docker host.
584
+ base_version (str):
585
+ The base version string (before '.git'), used when useChartVersion is True
586
+ instead of the tag found via `git describe`.
584
587
"""
585
588
values_file_modifications = {}
586
589
for name , options in images .items ():
@@ -782,9 +785,22 @@ def build_chart(
782
785
if use_chart_version :
783
786
# avoid adding .git... to chart version multiple times!
784
787
base_version = _trim_version_suffix (chart ["version" ])
785
- # TODO: trim -set.by.chartpress?
786
- # if base_version.endswith("-set.by.chartpress"):
787
- # base_version = base_version.rsplit("-", 1)[0]
788
+ # check for default placeholder tags
789
+ # avoid making weird combination of `1.0.0-set.by.chartpress.git.1.habc`
790
+ if "set.by.chartpress" in chart ["version" ]:
791
+ raise ValueError (
792
+ f"Chart { chart_file } has placeholder version { chart ['version' ]} , with `useChartVersion: true`."
793
+ f"Set the version in the { chart_file } to a base pre-release tag,"
794
+ " e.g. `1.0.0-0.dev` or `1.0.0-alpha.1` and run chartpress again."
795
+ )
796
+
797
+ # require starting from a prerelease tag, to ensure correct ordering
798
+ if "-" not in chart ["version" ]:
799
+ raise ValueError (
800
+ f"Chart { chart_file } has non-prerelease version { chart ['version' ]} with `useChartVersion: true`"
801
+ f"Set the version in the { chart_file } to a base pre-release tag,"
802
+ " e.g. `1.0.0-0.dev` or `1.0.0-alpha.1` and run chartpress again."
803
+ )
788
804
else :
789
805
base_version = None
790
806
if reset :
@@ -1093,6 +1109,10 @@ def main(args=None):
1093
1109
)
1094
1110
1095
1111
if "images" in chart :
1112
+ if use_chart_version :
1113
+ base_version = _trim_version_suffix (chart_version )
1114
+ else :
1115
+ base_version = None
1096
1116
# build images
1097
1117
values_file_modifications = build_images (
1098
1118
prefix = args .image_prefix or chart .get ("imagePrefix" , "" ),
@@ -1104,6 +1124,7 @@ def main(args=None):
1104
1124
force_push = args .force_push ,
1105
1125
force_build = args .force_build ,
1106
1126
skip_build = args .no_build or args .reset ,
1127
+ base_version = base_version ,
1107
1128
long = args .long ,
1108
1129
builder = args .builder ,
1109
1130
platforms = args .platform ,
0 commit comments