From 481e0836539dbee001926d92ace301b296888c37 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 19 Nov 2026 18:30:21 +0000 Subject: [PATCH 1/3] Name the Windows zips after the release tag PIE downloads a Windows zip by a name that has the package version in it, for example php_maxminddb-v1.15.0-8.4-nts-vs17-x86_64.zip. It then loads the DLL in the zip by the same name. php-windows-builder puts its extension-ref in both names. We passed the submodule commit SHA as that ref, so PIE could not install v1.14.0 or v1.15.0 on Windows. Tag the submodule commit on the runner and pass the checked-out submodule as extension-url with the tag as extension-ref. The builder still builds the same commit as the Linux and macOS lanes, and the zip, DLL and PDB now have the tag in their names. The windows-matrix job uses a pinned PHP version list, so it needs neither input. STF-2465 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 42 ++++++++++------------------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a5b5ee1..e6536f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,7 +40,6 @@ jobs: outputs: release: ${{ steps.resolve.outputs.release }} tag: ${{ steps.resolve.outputs.tag }} - ext-ref: ${{ steps.resolve.outputs.ext-ref }} php-versions: ${{ steps.resolve.outputs.php-versions }} ts-modes: ${{ steps.resolve.outputs.ts-modes }} linux-arches: ${{ steps.resolve.outputs.linux-arches }} @@ -125,24 +124,6 @@ jobs: exit 1 fi - # The Windows lane builds maxmind/MaxMind-DB-Reader-php directly -- - # a different repository from this packaging shim -- so it needs a ref - # there rather than a checkout here. The submodule pointer is that - # ref on every run, including a release. - # - # It used to be the tag on a release, which meant the Windows assets - # came from upstream's $TAG while Linux, macOS and the tarball came - # from the submodule pointer, with nothing asserting the two were the - # same commit. They agree only if the releaser happened to tag - # upstream at exactly the pointer, and the MMDB_VERSION check cannot - # notice when they do not: it compares libmaxminddb's PACKAGE_VERSION, - # not the extension's own C sources. This is the same "mixture - # published under the tag's name" the checkout_ref below fixed. - # - # The submodule pointer is also the better answer on its own terms -- - # it is what this repository says the release contains. - ext_ref="$(git rev-parse HEAD:MaxMind-DB-Reader-php)" - # Single source of truth for every lane's matrix *and* for the # asset-count assertion, so the two cannot drift. php='["8.2","8.3","8.4","8.5"]' @@ -202,7 +183,6 @@ jobs: { echo "release=$release" echo "tag=$TAG" - echo "ext-ref=$ext_ref" echo "php-versions=$php" echo "ts-modes=$ts" echo "linux-arches=$arches" @@ -792,11 +772,6 @@ jobs: id: matrix uses: php/php-windows-builder/extension-matrix@29352c0ef9e8ce65264ea9e287881a6f7758a953 # 1.9.0 with: - # The C sources and config.w32 live in the main repository; this repo - # is only the PIE packaging shim and keeps them in a submodule, which - # the action's own checkout would not initialise. - extension-url: https://github.com/maxmind/MaxMind-DB-Reader-php - extension-ref: ${{ needs.setup.outputs.ext-ref }} # Pinned rather than derived from composer.json so the Windows lane # covers the same PHP versions as every other lane. php-version-list: ${{ join(fromJSON(needs.setup.outputs.php-versions), ', ') }} @@ -848,12 +823,22 @@ jobs: submodules: recursive persist-credentials: false + # The build action names the zip, and the DLL and PDB in it, after + # extension-ref, and PIE finds them by the release tag. A tag on the + # submodule commit gives the action that name and builds the same commit + # as the Linux and macOS lanes. The tag is local to this runner. + - name: Tag the submodule commit + shell: bash + env: + TAG: ${{ needs.setup.outputs.tag }} + run: git -C MaxMind-DB-Reader-php tag --force "$TAG" + - name: Build the extension id: build uses: php/php-windows-builder/extension@29352c0ef9e8ce65264ea9e287881a6f7758a953 # 1.9.0 with: - extension-url: https://github.com/maxmind/MaxMind-DB-Reader-php - extension-ref: ${{ needs.setup.outputs.ext-ref }} + extension-url: ${{ github.workspace }}/MaxMind-DB-Reader-php + extension-ref: ${{ needs.setup.outputs.tag }} build-directory: ext php-version: ${{ matrix.php-version }} arch: ${{ matrix.arch }} @@ -867,9 +852,6 @@ jobs: # config.w32 to accept the lib-prefixed name the archive actually # ships (maxmind/MaxMind-DB-Reader-php#263). args: --with-maxminddb --with-maxminddb-bundled - # The action stages its own artifact; PIE resolves Windows assets - # through a separate windows-binary mechanism with its own name format, - # which php/php-windows-builder produces by default. # What the Linux and macOS lanes get from gate-extension.sh and their # load-and-query steps. Uploading the artifact is the action's own last From eabbf0e4201112eb94ec05981b597c3d2b63fad3 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 19 Nov 2026 18:30:28 +0000 Subject: [PATCH 2/3] Fail the release if a Windows zip lacks PIE's name verify-assets and publish counted the Windows zips but did not check their names, so the v1.14.0 and v1.15.0 releases shipped zips that PIE cannot find. collect-assets.sh now requires one zip for each leg of the Windows matrix, named as PIE expects, with a DLL of the same name in it. PIE loads the DLL by that name. The check accepts any compiler, because the matrix does not give it. php-windows-builder drops a PHP version it does not support from the matrix without a message. The script now also requires the matrix to build exactly the PHP versions from setup. STF-2465 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 2 ++ dev-bin/collect-assets.sh | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e6536f1..a387583 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -953,6 +953,7 @@ jobs: TS_MODES: ${{ needs.setup.outputs.ts-modes }} LINUX_ARCHES: ${{ needs.setup.outputs.linux-arches }} WINDOWS_COUNT: ${{ needs.windows-matrix.outputs.count }} + WINDOWS_MATRIX: ${{ needs.windows-matrix.outputs.matrix }} run: dev-bin/collect-assets.sh dist assets publish: @@ -989,6 +990,7 @@ jobs: TS_MODES: ${{ needs.setup.outputs.ts-modes }} LINUX_ARCHES: ${{ needs.setup.outputs.linux-arches }} WINDOWS_COUNT: ${{ needs.windows-matrix.outputs.count }} + WINDOWS_MATRIX: ${{ needs.windows-matrix.outputs.matrix }} run: dev-bin/collect-assets.sh dist assets - name: Upload the assets to the draft release diff --git a/dev-bin/collect-assets.sh b/dev-bin/collect-assets.sh index 6d6604b..f616bcd 100755 --- a/dev-bin/collect-assets.sh +++ b/dev-bin/collect-assets.sh @@ -7,7 +7,8 @@ # # Usage: collect-assets.sh # -# Reads TAG, PHP_VERSIONS, TS_MODES, LINUX_ARCHES and WINDOWS_COUNT. +# Reads TAG, PHP_VERSIONS, TS_MODES, LINUX_ARCHES, WINDOWS_COUNT and +# WINDOWS_MATRIX. set -euo pipefail @@ -66,3 +67,29 @@ find "$assets" -maxdepth 1 -type f -printf ' %f\n' | sort # this one file. [ -f "$assets/maxminddb-${TAG}.tgz" ] || fail "$assets/maxminddb-${TAG}.tgz is missing." + +# php-windows-builder drops a PHP version it does not support from the matrix +# without a message, and the checks below trust the matrix. +jq -e --argjson want "$PHP_VERSIONS" \ + '[.include[]."php-version"] | unique == ($want | unique)' \ + <<<"${WINDOWS_MATRIX:?}" >/dev/null || + fail "The Windows matrix does not build exactly the PHP versions $PHP_VERSIONS." + +# PIE downloads a Windows zip only by its exact name, which has the tag in it. +# It then loads the DLL in the zip by the same name. The matrix does not give +# the compiler, so accept any. +legs="$(jq -r '.include[] | [."php-version", .ts, .arch] | @tsv' <<<"$WINDOWS_MATRIX")" +while IFS=$'\t' read -r php ts arch; do + if [ "$arch" = x64 ]; then + arch=x86_64 + fi + name="php_maxminddb-${TAG}-${php}-${ts}-vs*-${arch}.zip" + matches=("$assets"/php_maxminddb-"$TAG"-"$php"-"$ts"-vs[0-9][0-9]-"$arch".zip) + zip="${matches[0]}" + [ -f "$zip" ] || + fail "No Windows asset has the name that PIE expects: $name." + dll="$(basename "$zip" .zip).dll" + listing="$(unzip -Z1 "$zip")" || fail "Could not list the files in $zip." + grep -qxF "$dll" <<<"$listing" || + fail "$zip does not contain $dll, which PIE loads." +done <<<"$legs" From d890c59489e08c5c9893e34b5726b1616ef0e90d Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 19 Nov 2026 18:49:37 +0000 Subject: [PATCH 3/3] Count the Windows assets from the matrix collect-assets.sh now reads the Windows matrix, so it can count the legs itself. This removes the count step from windows-matrix, its output, and WINDOWS_COUNT from verify-assets and publish. The count step also accepted a bare-array matrix, which strategy.matrix does not allow. The PHP-version check moves above the count, because the count trusts the matrix too. An empty or unset matrix now fails that check. STF-2465 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 27 ------------------------ dev-bin/collect-assets.sh | 39 ++++++++++++++--------------------- 2 files changed, 15 insertions(+), 51 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a387583..c91eabe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -766,7 +766,6 @@ jobs: contents: read outputs: matrix: ${{ steps.matrix.outputs.matrix }} - count: ${{ steps.count.outputs.count }} steps: - name: Get the extension matrix id: matrix @@ -776,30 +775,6 @@ jobs: # covers the same PHP versions as every other lane. php-version-list: ${{ join(fromJSON(needs.setup.outputs.php-versions), ', ') }} - - name: Count the expected Windows assets - id: count - env: - MATRIX: ${{ steps.matrix.outputs.matrix }} - run: | - count="$(jq 'if type == "array" then length else (.include | length) end' <<<"$MATRIX")" - # Shape before magnitude: `set -e` is suspended inside an `if`, so - # `[ "$count" -lt 1 ]` on a non-integer exits 2 and makes the whole - # condition false -- the guard passes and collect-assets.sh then - # coerces the value to 0, silently dropping the Windows legs from the - # expected asset count. - case "$count" in - '' | *[!0-9]*) - echo "::error::Could not count the Windows matrix; jq returned '$count'." - exit 1 - ;; - esac - if [ "$count" -lt 1 ]; then - echo "::error::The Windows matrix is empty." - exit 1 - fi - echo "Windows will produce $count assets." - echo "count=$count" >> "$GITHUB_OUTPUT" - windows: name: Windows ${{ matrix.arch }} PHP ${{ matrix.php-version }} ${{ matrix.ts }} needs: [setup, windows-matrix] @@ -952,7 +927,6 @@ jobs: PHP_VERSIONS: ${{ needs.setup.outputs.php-versions }} TS_MODES: ${{ needs.setup.outputs.ts-modes }} LINUX_ARCHES: ${{ needs.setup.outputs.linux-arches }} - WINDOWS_COUNT: ${{ needs.windows-matrix.outputs.count }} WINDOWS_MATRIX: ${{ needs.windows-matrix.outputs.matrix }} run: dev-bin/collect-assets.sh dist assets @@ -989,7 +963,6 @@ jobs: PHP_VERSIONS: ${{ needs.setup.outputs.php-versions }} TS_MODES: ${{ needs.setup.outputs.ts-modes }} LINUX_ARCHES: ${{ needs.setup.outputs.linux-arches }} - WINDOWS_COUNT: ${{ needs.windows-matrix.outputs.count }} WINDOWS_MATRIX: ${{ needs.windows-matrix.outputs.matrix }} run: dev-bin/collect-assets.sh dist assets diff --git a/dev-bin/collect-assets.sh b/dev-bin/collect-assets.sh index f616bcd..bbe9b9f 100755 --- a/dev-bin/collect-assets.sh +++ b/dev-bin/collect-assets.sh @@ -7,8 +7,7 @@ # # Usage: collect-assets.sh # -# Reads TAG, PHP_VERSIONS, TS_MODES, LINUX_ARCHES, WINDOWS_COUNT and -# WINDOWS_MATRIX. +# Reads TAG, PHP_VERSIONS, TS_MODES, LINUX_ARCHES and WINDOWS_MATRIX. set -euo pipefail @@ -31,15 +30,14 @@ collected="$(find "$assets" -maxdepth 1 -type f | wc -l)" [ "$staged" -eq "$collected" ] || fail "Two artifacts contain the same filename ($staged staged, $collected collected)." -# set -u does not fire on a set-but-empty variable, and arithmetic coerces one -# to 0 -- so an empty WINDOWS_COUNT would quietly mean "expect no Windows -# assets", and a release missing all of them would match the expectation and -# ship. Require a count before using it as one. -case "${WINDOWS_COUNT:-}" in -'' | *[!0-9]*) - fail "WINDOWS_COUNT is '${WINDOWS_COUNT:-}', which is not a count." - ;; -esac +# php-windows-builder drops a PHP version it does not support from the matrix +# without a message, and the checks below trust the matrix. +jq -e --argjson want "$PHP_VERSIONS" \ + '[.include[]."php-version"] | unique == ($want | unique)' \ + <<<"${WINDOWS_MATRIX:?}" >/dev/null || + fail "The Windows matrix does not build exactly the PHP versions $PHP_VERSIONS." + +windows_count="$(jq '.include | length' <<<"$WINDOWS_MATRIX")" php_count="$(jq 'length' <<<"$PHP_VERSIONS")" ts_count="$(jq 'length' <<<"$TS_MODES")" @@ -47,12 +45,12 @@ arch_count="$(jq 'length' <<<"$LINUX_ARCHES")" # Linux (php x ts x arch) + macOS (php x ts). binary_count=$((php_count * ts_count * arch_count + php_count * ts_count)) -# 1 source tarball + the binary lanes + whatever the Windows matrix said it -# would produce. Everything but WINDOWS_COUNT comes from setup, which is also -# what each matrix expands, so the expectation cannot drift from what was built -# -- including when setup hands out the reduced pull-request lists. WINDOWS_COUNT -# comes from windows-matrix, which derives it from the matrix it emits. -expected=$((1 + binary_count + WINDOWS_COUNT)) +# 1 source tarball + the binary lanes + one zip for each leg of the Windows +# matrix. The other lists come from setup, which is also what each matrix +# expands, so the expectation cannot drift from what was built -- including when +# setup hands out the reduced pull-request lists. The Windows matrix comes from +# windows-matrix, and the check above holds it to setup's PHP versions. +expected=$((1 + binary_count + windows_count)) echo "Expecting $expected assets, found $collected:" find "$assets" -maxdepth 1 -type f -printf ' %f\n' | sort @@ -68,13 +66,6 @@ find "$assets" -maxdepth 1 -type f -printf ' %f\n' | sort [ -f "$assets/maxminddb-${TAG}.tgz" ] || fail "$assets/maxminddb-${TAG}.tgz is missing." -# php-windows-builder drops a PHP version it does not support from the matrix -# without a message, and the checks below trust the matrix. -jq -e --argjson want "$PHP_VERSIONS" \ - '[.include[]."php-version"] | unique == ($want | unique)' \ - <<<"${WINDOWS_MATRIX:?}" >/dev/null || - fail "The Windows matrix does not build exactly the PHP versions $PHP_VERSIONS." - # PIE downloads a Windows zip only by its exact name, which has the tag in it. # It then loads the DLL in the zip by the same name. The matrix does not give # the compiler, so accept any.