Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/azure-pipeline.pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions build/test_update_ext_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`."""
Expand Down Expand Up @@ -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"],
Expand All @@ -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",
Expand All @@ -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"),
),
],
)
Expand Down
15 changes: 12 additions & 3 deletions build/update_ext_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
Loading