diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index 72189d79..c1142e58 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -83,7 +83,7 @@ extends: displayName: Update telemetry in package.json - script: python ./build/update_ext_version.py --for-publishing - displayName: Update build number + displayName: Validate version number - bash: | mkdir -p $(Build.SourcesDirectory)/python-env-tools/bin diff --git a/build/test_update_ext_version.py b/build/test_update_ext_version.py index 1a2fdb0e..8aa05942 100644 --- a/build/test_update_ext_version.py +++ b/build/test_update_ext_version.py @@ -9,10 +9,6 @@ TEST_DATETIME = "2022-03-14 01:23:45" -# The build ID is calculated via: -# "1" + datetime.datetime.strptime(TEST_DATETIME,"%Y-%m-%d %H:%M:%S").strftime('%j%H%M') -EXPECTED_BUILD_ID = "10730123" - def create_package_json(directory, version): """Create `package.json` in `directory` with a specified version of `version`.""" @@ -71,7 +67,7 @@ def test_invalid_args(tmp_path, version, args): ["--build-id", "999999999999"], ("1", "1", "999999999999", "rc"), ), - ("1.1.0-rc", [], ("1", "1", EXPECTED_BUILD_ID, "rc")), + ("1.1.0-rc", [], ("1", "1", "0", "rc")), ( "1.0.0-rc", ["--release"], @@ -80,7 +76,7 @@ def test_invalid_args(tmp_path, version, args): ( "1.1.0-rc", ["--for-publishing"], - ("1", "1", EXPECTED_BUILD_ID, ""), + ("1", "1", "0", ""), ), ( "1.0.0-rc", @@ -95,7 +91,7 @@ def test_invalid_args(tmp_path, version, args): ( "1.1.0-rc", [], - ("1", "1", EXPECTED_BUILD_ID, "rc"), + ("1", "1", "0", "rc"), ), ], ) diff --git a/build/update_ext_version.py b/build/update_ext_version.py index b284163b..25b5c7f4 100644 --- a/build/update_ext_version.py +++ b/build/update_ext_version.py @@ -79,6 +79,18 @@ def main(package_json: pathlib.Path, argv: Sequence[str]) -> None: ) print(f"Updating build FROM: {package['version']}") + + # Pre-release without --build-id: version is managed by the CI template + # (standardizedVersioning). Just strip suffix if publishing. + if not args.release and not args.build_id: + if args.for_publishing and len(suffix): + package["version"] = ".".join((major, minor, micro)) + print(f"Updating build TO: {package['version']}") + package_json.write_text( + json.dumps(package, indent=4, ensure_ascii=False) + "\n", encoding="utf-8" + ) + return + if args.build_id: # If build id is provided it should fall within the 0-INT32 max range # that the max allowed value for publishing to the Marketplace. @@ -88,9 +100,6 @@ def main(package_json: pathlib.Path, argv: Sequence[str]) -> None: package["version"] = ".".join((major, minor, str(args.build_id))) elif args.release: package["version"] = ".".join((major, minor, micro)) - else: - # micro version only updated for pre-release. - package["version"] = ".".join((major, minor, micro_build_number())) if not args.for_publishing and not args.release and len(suffix): package["version"] += "-" + suffix