From ca0a8b3fc375ae14ef6cfbb36cf75374bf588c6b Mon Sep 17 00:00:00 2001 From: Leonard Souza Date: Sun, 16 Aug 2026 12:00:42 -0700 Subject: [PATCH] Give the MSIX its own numeric version Every pull request has been failing the Windows job at makeappx, and never for a reason to do with the change under review: error C00CE169: The attribute 'Version' with value '1.0.0-pr4.0' failed to parse -- violates pattern constraint The manifest was built from the DISPLAY version, which is only ever clean on a tag. On anything else it carries a suffix -- "1.0.0-pr4" for a PR, "1.0.0-dev" locally -- and the MSIX schema admits four dot-separated integers and nothing else. A tagged release packed fine, so this stayed invisible until PRs started building Windows. MSIX_VERSION is now derived rather than borrowed: the project's numeric version with any pre-release suffix stripped, then the commit count. The commit count is there for the same reason CFBundleVersion uses it, and the reasoning is already written down in CMakeLists -- Windows compares these numbers to decide what counts as an upgrade, and two builds of 1.0.0 that both claimed 1.0.0.0 would be indistinguishable to it. Checked against the schema's own regex, which also turned up a case that had not bitten yet: a pre-release TAG like v1.1.0-beta.2 would have failed to pack in exactly the same way. The substitution step now fails if any placeholder survives it, since the previous failure was one substitution producing something invalid rather than not happening at all. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/release.yml | 36 +++++++++++++++++++++++++----- packaging/windows/AppxManifest.xml | 10 +++++++-- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 44aa09b..c8d0a01 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -75,16 +75,39 @@ jobs: - name: Work out the version shell: bash run: | + PROJECT="$(sed -n 's/^project(hyperbin VERSION \([0-9.]*\).*/\1/p' CMakeLists.txt)" if [[ "${{ github.ref }}" == refs/tags/v* ]]; then VERSION="${GITHUB_REF_NAME#v}" else - VERSION="$(sed -n 's/^project(hyperbin VERSION \([0-9.]*\).*/\1/p' CMakeLists.txt)-pr${{ github.event.number }}" + VERSION="${PROJECT}-pr${{ github.event.number }}" fi BUILD=$(git rev-list --count HEAD) - echo "VERSION=$VERSION" >> $GITHUB_ENV - echo "BUILD=$BUILD" >> $GITHUB_ENV + + # MSIX gets its own version, and it has to be built rather than + # borrowed. Its schema takes four dot-separated integers and + # NOTHING else, so the display version cannot be used: that is + # only ever clean on a tag, and every pull request packed as + # "1.0.0-pr4.0" and failed makeappx outright. + # + # The last field is the commit count for the same reason + # CFBundleVersion is — see CMakeLists. Windows compares these to + # decide what is an upgrade, so two builds of 1.0.0 that both + # said 1.0.0.0 would be indistinguishable to it. A commit count + # only ever goes up. + # + # Strip any pre-release suffix off a tag first: v1.1.0-beta.2 is + # a perfectly good tag and not a number. + MSIX_VERSION="${VERSION%%-*}.${BUILD}" + if [[ "$BUILD" -gt 65535 ]]; then + echo "::error::commit count $BUILD exceeds the 65535 an MSIX version field allows" + exit 1 + fi + + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "BUILD=$BUILD" >> $GITHUB_ENV + echo "MSIX_VERSION=$MSIX_VERSION" >> $GITHUB_ENV echo "$VERSION" > build-version.txt - echo "Version $VERSION, build $BUILD" + echo "Version $VERSION, build $BUILD, msix $MSIX_VERSION" - name: Install Qt uses: jurplel/install-qt-action@v4 @@ -215,8 +238,11 @@ jobs: Copy-Item packaging\windows\Assets dist\windows\Assets -Recurse -Force (Get-Content dist\windows\AppxManifest.xml) ` - -replace '\{\{VERSION\}\}', "$env:VERSION" ` + -replace '\{\{MSIX_VERSION\}\}', "$env:MSIX_VERSION" ` -replace '\{\{ARCH\}\}', 'x64' | Set-Content dist\windows\AppxManifest.xml + if (Select-String -Path dist\windows\AppxManifest.xml -Pattern '\{\{') { + throw "AppxManifest still has an unsubstituted placeholder" + } $makeappx = Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\bin\10.*\x64\makeappx.exe" | Sort-Object -Descending | Select-Object -First 1 diff --git a/packaging/windows/AppxManifest.xml b/packaging/windows/AppxManifest.xml index 5b1ed07..431a536 100644 --- a/packaging/windows/AppxManifest.xml +++ b/packaging/windows/AppxManifest.xml @@ -9,16 +9,22 @@