Repository navigation
ci: wire native Windows MSI build into CI with build_native_windows opt-in (1/2) #9370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -184,6 +184,28 @@ jobs: | |||||||||||||||||
| contents: read | ||||||||||||||||||
| id-token: write | ||||||||||||||||||
|
|
||||||||||||||||||
| # Build the native Windows MSI installer(s) from this run's artifacts. In CI | ||||||||||||||||||
| # the MSI is produced and uploaded to the run's artifacts bucket (a build | ||||||||||||||||||
| # artifact) to exercise the packaging path; it is not published to a release | ||||||||||||||||||
| # bucket here (that happens only in the release workflow). | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment is not necessary. All CI workflows are designed in this way. See:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in b0f3450 — removed the comment. |
||||||||||||||||||
| build_native_msi_packages: | ||||||||||||||||||
| needs: [build_multi_arch_stages] | ||||||||||||||||||
| name: Build Native MSI Packages | ||||||||||||||||||
| if: ${{ !failure() && !cancelled() && !contains(needs.*.result, 'cancelled') && fromJSON(inputs.build_config).build_native_windows == true }} | ||||||||||||||||||
| uses: ./.github/workflows/multi_arch_build_native_windows_packages.yml | ||||||||||||||||||
| with: | ||||||||||||||||||
| artifact_run_id: ${{ github.run_id }} | ||||||||||||||||||
| rocm_version: ${{ inputs.rocm_package_version }} | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the version you want to pass? Native Linux packaging workflows pass the deb/rpm version here: TheRock/.github/workflows/multi_arch_ci_linux.yml Lines 169 to 176 in 0e75336
I would suggest passing both the user-facing version and the build version as two separate inputs.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in b0f3450 — now passing two separate inputs: |
||||||||||||||||||
| # Only the runtime package is published in nightly artifacts today; core's | ||||||||||||||||||
| # Windows artifacts (core-amdsmi, core-runtime) are not yet available. | ||||||||||||||||||
| packages: runtime | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a CI workflow. Why does it mention "nightly" artifacts? Dev -> Nightly -> Prod. This is dev.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in b0f3450 — reworded from "nightly" to "CI" artifacts (this is the dev/CI path). |
||||||||||||||||||
| release_type: ${{ inputs.release_type }} | ||||||||||||||||||
| repository: ${{ inputs.repository }} | ||||||||||||||||||
| ref: ${{ inputs.ref }} | ||||||||||||||||||
| permissions: | ||||||||||||||||||
| contents: read | ||||||||||||||||||
| id-token: write | ||||||||||||||||||
|
|
||||||||||||||||||
| test_python_packages_per_family: | ||||||||||||||||||
| needs: [build_python_packages] | ||||||||||||||||||
| name: Test Python | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,6 +91,10 @@ on: | |
| description: "Build native Linux packages (deb/rpm) and run their install tests." | ||
| type: boolean | ||
| default: true | ||
| build_native_windows: | ||
| description: "Build native Windows packages (MSI)." | ||
| type: boolean | ||
| default: true | ||
|
Comment on lines
+94
to
+97
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that we may want to set this explicitly in repositories that use TheRock CI, as is done for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point — noted. This PR keeps the default |
||
| python_version: | ||
| description: "Single Python version for wheel builds; empty uses the default matrix." | ||
| type: string | ||
|
|
@@ -246,6 +250,7 @@ jobs: | |
| BUILD_PYTORCH: ${{ inputs.build_pytorch }} | ||
| BUILD_JAX: ${{ inputs.build_jax }} | ||
| BUILD_NATIVE_LINUX: ${{ inputs.build_native_linux }} | ||
| BUILD_NATIVE_WINDOWS: ${{ inputs.build_native_windows }} | ||
| PYTHON_VERSION: ${{ inputs.python_version }} | ||
| LINUX_AMDGPU_FAMILIES: ${{ inputs.linux_amdgpu_families }} | ||
| WINDOWS_AMDGPU_FAMILIES: ${{ inputs.windows_amdgpu_families }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,18 +6,20 @@ | |
| """Computes a ROCm package version with an appropriate suffix for a given release type. | ||
|
|
||
| For usage from other Python scripts, call the `compute_version()` function | ||
| directly. When used from GitHub Actions, this writes all three version outputs | ||
| to GITHUB_OUTPUT: | ||
| directly. When used from GitHub Actions, this writes all version outputs to | ||
| GITHUB_OUTPUT: | ||
| - 'rocm_package_version' for wheel packages | ||
| - 'rocm_deb_package_version' for deb packages | ||
| - 'rocm_rpm_package_version' for rpm packages | ||
| - 'rocm_msi_package_version' for Windows MSI packages | ||
|
|
||
| Sample usage: | ||
|
|
||
| python compute_rocm_package_version.py --release-type=dev | ||
| # rocm_package_version=7.10.0.dev0+f689a8ea40232f3f6be1ec958354b108349023ff | ||
| # rocm_deb_package_version=7.10.0~dev20251203 | ||
| # rocm_rpm_package_version=7.10.0~20251203gf689a8e | ||
| # rocm_msi_package_version=7.10.3929.0 (major.minor.<days-since-2016-04-01>.0) | ||
|
|
||
| python compute_rocm_package_version.py --release-type=prerelease --prerelease-version=2 | ||
| # rocm_package_version=7.10.0rc2 | ||
|
|
@@ -43,7 +45,7 @@ | |
|
|
||
| import argparse | ||
| from collections.abc import Mapping | ||
| from datetime import datetime | ||
| from datetime import date, datetime | ||
| from pathlib import Path | ||
| import json | ||
| import os | ||
|
|
@@ -56,6 +58,16 @@ | |
| THIS_SCRIPT_DIR = Path(__file__).resolve().parent | ||
| THEROCK_DIR = THIS_SCRIPT_DIR.parent | ||
|
|
||
| # Epoch for the MSI ProductVersion build field: the first ROCm release (ROCm 1.0, | ||
| # April 2016). The MSI version's third field is the number of days since this | ||
| # date, giving a strictly increasing, WiX-legal integer. See compute_msi_build_field. | ||
| MSI_EPOCH = date(2016, 4, 1) | ||
|
|
||
| # Windows Installer compares only the first three ProductVersion fields and caps | ||
| # the third (build) field at 65535. days-since-MSI_EPOCH stays under this until | ||
| # ~year 2195, after which a build would raise rather than silently wrap. | ||
| MSI_BUILD_FIELD_MAX = 65535 | ||
|
|
||
|
|
||
| def _log(*args, **kwargs): | ||
| print(*args, **kwargs) | ||
|
|
@@ -137,6 +149,27 @@ def get_current_date(): | |
| return datetime.today().strftime("%Y%m%d") | ||
|
|
||
|
|
||
| def compute_msi_build_field(today: date | None = None) -> int: | ||
| """Return the MSI ProductVersion build field: days since MSI_EPOCH. | ||
|
|
||
| This is the third field of the four-field MSI version. It increases by one | ||
| per day, so a later build always outranks an earlier one within its | ||
| major.minor line (Windows Installer compares only the first three fields). | ||
| Raises if it would exceed the installer's 65535 limit. | ||
| """ | ||
| if today is None: | ||
| today = date.today() | ||
| days = (today - MSI_EPOCH).days | ||
| if days < 0: | ||
| raise ValueError(f"build date {today} precedes the MSI epoch {MSI_EPOCH}") | ||
| if days > MSI_BUILD_FIELD_MAX: | ||
| raise ValueError( | ||
| f"MSI build field {days} exceeds the Windows Installer limit of " | ||
| f"{MSI_BUILD_FIELD_MAX} (third ProductVersion field)" | ||
| ) | ||
| return days | ||
|
|
||
|
|
||
| def compute_version( | ||
| package_type: str = "wheel", | ||
| release_type: str | None = None, | ||
|
|
@@ -149,7 +182,7 @@ def compute_version( | |
| """Compute package version based on package type and release type. | ||
|
|
||
| Args: | ||
| package_type: Type of package ("wheel", "deb", or "rpm") | ||
| package_type: Type of package ("wheel", "deb", "rpm", or "msi") | ||
| release_type: Release type ("ci", "dev", "dev-bkc", "nightly", | ||
| "nightly-bkc", "prerelease", or "release") | ||
| custom_version_suffix: Custom suffix to override automatic suffix | ||
|
|
@@ -183,6 +216,32 @@ def compute_version( | |
| f"for release type '{release_type}'" | ||
| ) | ||
|
|
||
| # Handle Windows MSI packages (WiX ProductVersion: numeric major.minor.build.0). | ||
| # | ||
| # Unlike the other package types, the MSI version does NOT carry a dev/nightly | ||
| # suffix: Windows Installer versions must be numeric #.#.#.# and it compares | ||
| # only the first three fields. We keep major.minor from version.json visible | ||
| # and put the build DATE (days since the ROCm 1.0 epoch) in the third field, | ||
| # so every build outranks the previous one within its major.minor line. The | ||
| # marketing patch (e.g. 10.2.0) is surfaced separately via the MSI's | ||
| # ARPDISPLAYVERSION property, not here. Cross-line coexistence (10.2 vs 10.3) | ||
| # is handled by a per-major.minor UpgradeCode in the generator, so this field | ||
| # never has to order across lines. All release types share one shape; a | ||
| # release simply has the highest build field in its line because it is built | ||
| # last (no further nightlies follow a major.minor's release). | ||
| if package_type == "msi": | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than add msi before python packages and native linux packages, can you sort this as:
matching what we have in the versioning.md and releases.md docs? So something like this in code: if package_type == "wheel":
...
elif package_type == "deb" or package_type == "rpm":
...
elif package_type == "msi":
...
else:
raise AssertionError(f"Unexpected package type: {package_type}")
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in b0f3450 — reordered the branches to wheel → deb/rpm → msi and added an explicit |
||
| parts = base_version.split(".") | ||
| if len(parts) < 2 or not parts[0] or not parts[1]: | ||
| raise ValueError( | ||
| f"base version must be at least major.minor for msi (got " | ||
| f"{base_version!r})" | ||
| ) | ||
| major, minor = parts[0], parts[1] | ||
| build_field = compute_msi_build_field() | ||
| rocm_package_version = f"{major}.{minor}.{build_field}.0" | ||
| _log(f"Full version : '{rocm_package_version}'") | ||
| return rocm_package_version | ||
|
|
||
| # Handle wheel packages (Python packaging standards) | ||
| if package_type == "wheel": | ||
| if custom_version_suffix: | ||
|
|
@@ -315,9 +374,9 @@ def main(argv): | |
|
|
||
| version_data = load_version_file() | ||
|
|
||
| # Compute versions for all three package types: wheel, deb, and rpm | ||
| # Compute versions for all package types: wheel, deb, rpm, and msi. | ||
| outputs = {} | ||
| for pkg_type in ["wheel", "deb", "rpm"]: | ||
| for pkg_type in ["wheel", "deb", "rpm", "msi"]: | ||
| version = compute_version( | ||
| package_type=pkg_type, | ||
| release_type=args.release_type, | ||
|
|
@@ -331,7 +390,7 @@ def main(argv): | |
| # Set appropriate output variable based on package type | ||
| if pkg_type == "wheel": | ||
| outputs["rocm_package_version"] = version | ||
| else: # deb or rpm | ||
| else: # deb, rpm, or msi | ||
| outputs[f"rocm_{pkg_type}_package_version"] = version | ||
|
|
||
| gha_set_output(outputs) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -225,6 +225,7 @@ class CIInputs: | |
| build_pytorch: bool = True | ||
| build_jax: bool = False | ||
| build_native_linux: bool = True | ||
| build_native_windows: bool = True | ||
| python_versions: list[str] = field(default_factory=list) | ||
|
|
||
| # Labels from the PR event payload or workflow_dispatch pr_labels input. | ||
|
|
@@ -330,6 +331,9 @@ def from_environ() -> "CIInputs": | |
| build_native_linux = ( | ||
| os.environ.get("BUILD_NATIVE_LINUX", "true").lower() != "false" | ||
| ) | ||
| build_native_windows = ( | ||
| os.environ.get("BUILD_NATIVE_WINDOWS", "true").lower() != "false" | ||
| ) | ||
| python_version = os.environ.get("PYTHON_VERSION", "").strip() | ||
|
|
||
| pr_labels: list[str] = [] | ||
|
|
@@ -414,6 +418,7 @@ def from_environ() -> "CIInputs": | |
| build_pytorch=build_pytorch, | ||
| build_jax=build_jax, | ||
| build_native_linux=build_native_linux, | ||
| build_native_windows=build_native_windows, | ||
| python_versions=[python_version] if python_version else [], | ||
| pr_labels=pr_labels, | ||
| pr_base_ref=pr_base_ref, | ||
|
|
@@ -720,6 +725,7 @@ class BuildConfig: | |
| build_variant_suffix: str | ||
| build_variant_cmake_preset: str | ||
| build_native_linux: bool | ||
| build_native_windows: bool | ||
| build_python_packages: bool | ||
| build_pytorch: bool | ||
| build_jax: bool | ||
|
|
@@ -1752,6 +1758,8 @@ def _expand_build_config_for_platform( | |
| else [] | ||
| ) | ||
| build_native_linux = ci_inputs.build_native_linux | ||
| # Native Windows (MSI) packages are built only on the windows platform. | ||
| build_native_windows = ci_inputs.build_native_windows and platform == "windows" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like Then I don't think the comment is useful
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in b0f3450 — |
||
|
|
||
| # PR labels can override packaging build decisions. | ||
| pr_labels = ci_inputs.pr_labels | ||
|
|
@@ -1760,6 +1768,12 @@ def _expand_build_config_for_platform( | |
| elif "ci:skip-native-linux" in pr_labels: | ||
| build_native_linux = False | ||
|
|
||
| if platform == "windows": | ||
| if "ci:build-native-windows" in pr_labels: | ||
| build_native_windows = True | ||
| elif "ci:skip-native-windows" in pr_labels: | ||
| build_native_windows = False | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should also check
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in b0f3450 — the native-linux overrides are now wrapped in |
||
|
|
||
| if "ci:build-python-packages" in pr_labels: | ||
| build_python_packages = True | ||
| elif "ci:skip-python-packages" in pr_labels: | ||
|
|
@@ -1785,6 +1799,7 @@ def _expand_build_config_for_platform( | |
| build_pytorch = False | ||
| build_jax = False | ||
| build_native_linux = False | ||
| build_native_windows = False | ||
| pytorch_build_matrix = [] | ||
| jax_build_matrix = [] | ||
| test_python_packages_matrix = [] | ||
|
|
@@ -1797,6 +1812,7 @@ def _expand_build_config_for_platform( | |
| build_variant_suffix=suffix, | ||
| build_variant_cmake_preset=variant_config["build_variant_cmake_preset"], | ||
| build_native_linux=build_native_linux, | ||
| build_native_windows=build_native_windows, | ||
| build_python_packages=build_python_packages, | ||
| build_pytorch=build_pytorch, | ||
| build_jax=build_jax, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relating to my other comment - no logic in workflow files! ESPECIALLY inline python like this, that is significantly worse than inline bash. Follow the style guide: https://github.com/ROCm/TheRock/blob/main/docs/development/style_guides/github_actions_style_guide.md#prefer-python-scripts-over-inline-bash
The versions are already computed at the start of the CI pipeline, just pass them through to this workflow. No need to say "well you passed me a python version so now I'll convert it to the version I actually want" - just pass the versions that the script wants directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in b0f3450 — removed the inline-python step entirely. The WiX-legal MSI ProductVersion is now computed once upstream (
setup_multi_arch.ymlalready runscompute_rocm_package_version.py, which emitsrocm_msi_package_version) and threaded throughmulti_arch_ci.yml→multi_arch_ci_windows.yml→ the build workflow as a newmsi_versioninput, mirroring how the deb/rpm versions are passed. The build workflow now receives both the display version (rocm_version) and the numeric ProductVersion (msi_version) directly.