2424class VersionType (Enum ):
2525 MAJOR = (1 ,)
2626 MINOR = (2 ,)
27- PATCH = 3
27+ PATCH = (3 ,)
28+ SNAPSHOT = (4 ,)
2829
2930
3031@click .group (invoke_without_command = False )
@@ -49,7 +50,7 @@ def main(ctx):
4950 default = "patch" ,
5051 type = str ,
5152 help = """
52- The type of version bump, one of major, minor or patch.
53+ The type of version bump, one of major, minor, patch.
5354 """ ,
5455)
5556@click .option (
@@ -61,7 +62,14 @@ def main(ctx):
6162 The path to the versions.txt.
6263 """ ,
6364)
65+
66+ def bump_snapshot_version (artifact_ids : str , versions : str ) -> None :
67+ bump_version (artifact_ids , "snapshot" , versions )
68+
6469def bump_released_version (artifact_ids : str , version_type : str , versions : str ) -> None :
70+ bump_version (artifact_ids , version_type , versions )
71+
72+ def bump_version (artifact_ids : str , version_type : str , versions : str ) -> None :
6573 target_artifact_ids = set (artifact_ids .split ("," ))
6674 version_enum = _parse_type_or_raise (version_type )
6775 newlines = []
@@ -88,15 +96,19 @@ def bump_released_version(artifact_ids: str, version_type: str, versions: str) -
8896 major , minor , patch = [
8997 int (ver_num ) for ver_num in released_version .split ("." )
9098 ]
99+ suffix = ""
91100 match version_enum :
92101 case VersionType .MAJOR :
93102 major += 1
94103 case VersionType .MINOR :
95104 minor += 1
96105 case VersionType .PATCH :
97106 patch += 1
107+ case VersionType .SNAPSHOT :
108+ minor += 1
109+ suffix = "-SNAPSHOT"
98110 newlines .append (
99- f"{ artifact_id } :{ major } .{ minor } .{ patch } :{ major } .{ minor } .{ patch } "
111+ f"{ artifact_id } :{ major } .{ minor } .{ patch } { suffix } :{ major } .{ minor } .{ patch } { suffix } "
100112 )
101113 with open (versions , "w" ) as versions_file :
102114 versions_file .writelines ("\n " .join (newlines ))
0 commit comments