@@ -38,12 +38,20 @@ def main(ctx):
3838@main .command ()
3939@click .option (
4040 "--artifact-ids" ,
41- required = True ,
41+ required = False ,
4242 type = str ,
4343 help = """
4444 Artifact IDs whose version needs to update, separated by comma.
4545 """ ,
4646)
47+ @click .option (
48+ "--sdk-platform-java" ,
49+ is_flag = True ,
50+ default = False ,
51+ help = """
52+ If set, bump versions for all modules in sdk-platform-java.
53+ """ ,
54+ )
4755@click .option (
4856 "--versions" ,
4957 required = False ,
@@ -53,18 +61,29 @@ def main(ctx):
5361 The path to the versions.txt.
5462 """ ,
5563)
56- def bump_snapshot_version (artifact_ids : str , versions : str ) -> None :
64+ def bump_snapshot_version (artifact_ids : str , sdk_platform_java : bool , versions : str ) -> None :
65+ if sdk_platform_java :
66+ artifact_ids = _get_sdk_platform_java_artifacts (artifact_ids )
5767 bump_version (artifact_ids , "snapshot" , versions )
5868
69+
5970@main .command ()
6071@click .option (
6172 "--artifact-ids" ,
62- required = True ,
73+ required = False ,
6374 type = str ,
6475 help = """
6576 Artifact IDs whose version needs to update, separated by comma.
6677 """ ,
6778)
79+ @click .option (
80+ "--sdk-platform-java" ,
81+ is_flag = True ,
82+ default = False ,
83+ help = """
84+ If set, bump versions for all modules in sdk-platform-java.
85+ """ ,
86+ )
6887@click .option (
6988 "--version-type" ,
7089 required = False ,
@@ -83,9 +102,45 @@ def bump_snapshot_version(artifact_ids: str, versions: str) -> None:
83102 The path to the versions.txt.
84103 """ ,
85104)
86- def bump_released_version (artifact_ids : str , version_type : str , versions : str ) -> None :
105+ def bump_released_version (
106+ artifact_ids : str , sdk_platform_java : bool , version_type : str , versions : str
107+ ) -> None :
108+ if sdk_platform_java :
109+ artifact_ids = _get_sdk_platform_java_artifacts (artifact_ids )
87110 bump_version (artifact_ids , version_type , versions )
88111
112+
113+ def _get_sdk_platform_java_artifacts (artifact_ids : str ) -> str :
114+ sdk_artifacts = [
115+ "gapic-generator-java" ,
116+ "api-common" ,
117+ "gax" ,
118+ "gax-grpc" ,
119+ "gax-httpjson" ,
120+ "proto-google-common-protos" ,
121+ "grpc-google-common-protos" ,
122+ "proto-google-iam-v1" ,
123+ "grpc-google-iam-v1" ,
124+ "proto-google-iam-v2beta" ,
125+ "grpc-google-iam-v2beta" ,
126+ "proto-google-iam-v2" ,
127+ "grpc-google-iam-v2" ,
128+ "proto-google-iam-v3" ,
129+ "grpc-google-iam-v3" ,
130+ "proto-google-iam-v3beta" ,
131+ "grpc-google-iam-v3beta" ,
132+ "google-cloud-core" ,
133+ "google-cloud-shared-dependencies" ,
134+ "google-iam-policy" ,
135+ "gapic-showcase" ,
136+ "proto-gapic-showcase-v1beta1" ,
137+ "grpc-gapic-showcase-v1beta1" ,
138+ ]
139+ if artifact_ids :
140+ return "," .join (sdk_artifacts + artifact_ids .split ("," ))
141+ return "," .join (sdk_artifacts )
142+
143+
89144def bump_version (artifact_ids : str , version_type : str , versions : str ) -> None :
90145 target_artifact_ids = set (artifact_ids .split ("," ))
91146 version_enum = _parse_type_or_raise (version_type )
@@ -130,7 +185,8 @@ def bump_version(artifact_ids: str, version_type: str, versions: str) -> None:
130185 f"{ artifact_id } :{ major } .{ minor } .{ patch } :{ major } .{ minor } .{ patch } "
131186 )
132187 with open (versions , "w" ) as versions_file :
133- versions_file .writelines ("\n " .join (newlines ))
188+ for line in newlines :
189+ versions_file .write (f"{ line } \n " )
134190
135191
136192def _parse_type_or_raise (version_type : str ) -> VersionType :
0 commit comments