Skip to content

Commit 0b0345a

Browse files
authored
[SDK generation pipeline] fix version logic (Azure#40305)
* fix version * fix
1 parent a31440d commit 0b0345a

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

tools/azure-sdk-tools/packaging_tools/package_utils.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,6 @@ def next_version(self) -> str:
170170
self._next_version = self.calculate_next_version()
171171
return self._next_version
172172

173-
def get_private_package(self) -> List[str]:
174-
return self.package_info["artifacts"]
175-
176-
@property
177-
def get_whl_package(self) -> str:
178-
return [package for package in self.get_private_package() if package.endswith(".whl")][0]
179-
180173
# Use the template to update readme and setup by packaging_tools
181174
@return_origin_path
182175
def check_file_with_packaging_tool(self):
@@ -369,5 +362,8 @@ def run(self):
369362
self.check_pyproject_toml()
370363

371364

372-
def check_file(package_info: Dict[str, Any]):
373-
CheckFile(package_info).run()
365+
def check_file(package: Dict[str, Any]):
366+
client = CheckFile(package)
367+
client.run()
368+
if not client.has_invalid_next_version:
369+
package["version"] = client.next_version

tools/azure-sdk-tools/packaging_tools/sdk_package.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,8 @@ def main(generate_input, generate_output):
5959
package["version"] = last_version
6060

6161
_LOGGER.info(f"[PACKAGE]({package_name})[CHANGELOG]:{md_output}")
62-
# Built package
63-
create_package(prefolder, package_name)
64-
folder_name = package["path"][0]
65-
dist_path = Path(sdk_folder, folder_name, package_name, "dist")
66-
package["artifacts"] = [str(dist_path / package_file) for package_file in os.listdir(dist_path)]
67-
package["result"] = "succeeded"
6862
# Generate api stub File
63+
folder_name = package["path"][0]
6964
try:
7065
package_path = Path(sdk_folder, folder_name, package_name)
7166
check_call(
@@ -87,22 +82,31 @@ def main(generate_input, generate_output):
8782
package["apiViewArtifact"] = str(Path(package_path, file))
8883
except Exception as e:
8984
_LOGGER.debug(f"Fail to generate ApiView token file for {package_name}: {e}")
85+
86+
# check generated files and update package["version"]
87+
if package_name.startswith("azure-mgmt-"):
88+
try:
89+
check_file(package)
90+
except Exception as e:
91+
_LOGGER.error(f"Fail to check generated files for {package_name}: {e}")
92+
93+
# Built package
94+
create_package(prefolder, package_name)
95+
dist_path = Path(sdk_folder, folder_name, package_name, "dist")
96+
package["artifacts"] = [str(dist_path / package_file) for package_file in os.listdir(dist_path)]
97+
for artifact in package["artifacts"]:
98+
if ".whl" in artifact:
99+
package["language"] = "Python"
100+
break
90101
# Installation package
91102
package["installInstructions"] = {
92103
"full": "You can install the use using pip install of the artifacts.",
93104
"lite": f"pip install {package_name}",
94105
}
95-
for artifact in package["artifacts"]:
96-
if ".whl" in artifact:
97-
package["language"] = "Python"
98-
break
106+
package["result"] = "succeeded"
99107
package["packageFolder"] = package["path"][0]
100108
result["packages"].append(package)
101109

102-
# check generated files
103-
if package_name.startswith("azure-mgmt-"):
104-
check_file(package)
105-
106110
with open(generate_output, "w") as writer:
107111
json.dump(result, writer)
108112

0 commit comments

Comments
 (0)