Skip to content

Fix Windows release pipeline and add PHAR fallback for all platformsFeature/fix win release 4#149

Merged
jasdeepkhalsa merged 3 commits intomasterfrom
feature/fix-win-release-4
Mar 7, 2026
Merged

Fix Windows release pipeline and add PHAR fallback for all platformsFeature/fix win release 4#149
jasdeepkhalsa merged 3 commits intomasterfrom
feature/fix-win-release-4

Conversation

@jasdeepkhalsa
Copy link
Copy Markdown
Member

Fix Windows release pipeline and add PHAR fallback for all platforms

Problem

Three issues were blocking a clean release:

  1. GitHub Release upload failing with Error: Not Found — all six Unix binaries share the filename dbdiff. softprops/action-gh-release uploads by basename, so they collide to a single asset. On re-runs it tried to delete all six duplicates by ID, but by the 3rd–6th deletion the prior ones were already gone, causing a 404 that aborted the step. Previously uploaded assets were being silently deleted each re-run without replacement.

  2. Windows had no working binary — the SPC Windows build fails with 14 unresolved zlib linker symbols on x64, and SPC v2.8.2 hardcodes phpsdk-vs17-x64.bat (which passes x64_amd64 to vcvarsall.bat) making ARM64 builds impossible on ARM64 runners.

  3. @dbdiff/cli-win32-arm64 was silently unpublished — the platform package skeleton existed but was being skipped during npm publish because it had no binary, leaving ARM64 Windows users with a failed install.

Changes

release.yml

  • Rename binaries before GitHub Release upload — adds a step after npm publish that renames each binary to include its platform (e.g. dbdiffdbdiff-linux-x64, dbdiff.exedbdiff-win32-x64.exe). Every release asset now has a unique name; re-runs delete and re-upload cleanly.
  • Bundle PHAR into @dbdiff/cli — copies dbdiff.phar into packages/@dbdiff/cli/ before npm publish so it ships with every npm install -g @dbdiff/cli.
  • Publish @dbdiff/cli-win32-arm64 as a PHAR-fallback skeleton — adds a PHAR_FALLBACK_PKGS list to the publish loop; packages in that list are published without a native binary rather than skipped.

packages/@dbdiff/cli/package.json

  • Add dbdiff.phar to the files array so it is included in the published npm package.

packages/@dbdiff/cli/bin/dbdiff.js

  • When getBinaryPath() returns null (no native binary installed), fall back to running the bundled dbdiff.phar via system php/php.exe.
  • If php is not in PATH, print a clear actionable error: "Install PHP 8.1+ from https://www.php.net/downloads and add it to your PATH".

Result

Platform Before After
Linux x64/arm64 + musl ✅ native binary ✅ native binary
macOS x64/arm64 ✅ native binary ✅ native binary
Windows x64 ❌ no binary, unhelpful error ✅ PHP PHAR fallback
Windows ARM64 ❌ package not published ✅ PHP PHAR fallback
GitHub Release assets ❌ 404 on re-run ✅ unique names, idempotent

Windows users (npm install -g @dbdiff/cli) get a working dbdiff command immediately as long as PHP 8.1+ is in their PATH — which is expected for the PHP developers this tool targets. When native Windows static builds become possible (upstream SPC fix), they will automatically take priority over the fallback with no changes required.

… upload

All six Unix binaries share the basename 'dbdiff'. softprops/action-gh-release
uploads by basename, so they all collide to a single asset. On re-runs the action
queries existing assets, gets 6 records all named 'dbdiff', and tries to delete
them by ID — but by the time it deletes #3-6 the prior ones are already gone,
causing 'Error: Not Found' and aborting the step.

Fix: add a rename step before the GH Release upload that moves each binary to
include its platform:
  binaries/dbdiff-linux-x64/dbdiff        → dbdiff-linux-x64
  binaries/dbdiff-darwin-arm64/dbdiff     → dbdiff-darwin-arm64
  binaries/dbdiff-win32-x64/dbdiff.exe   → dbdiff-win32-x64.exe
  binaries/dbdiff-phar/dbdiff.phar       (untouched, already unique)

Update the files glob to match the renamed assets:
  binaries/dbdiff-*/dbdiff-*
  binaries/dbdiff-phar/dbdiff.phar

The rename step runs AFTER the npm copy step so npm packages still receive the
original 'dbdiff'/'dbdiff.exe' names that bin/dbdiff.js expects.
On Windows (and any future unsupported platform) where no native static
binary is available, bin/dbdiff.js now automatically falls back to running
the bundled dbdiff.phar with system PHP instead of printing an error.

Changes:
- packages/@dbdiff/cli/package.json: add dbdiff.phar to 'files' so it
  ships with every npm install -g @dbdiff/cli
- packages/@dbdiff/cli/bin/dbdiff.js: when getBinaryPath() returns null,
  check for dbdiff.phar alongside the script; if present, exec php/php.exe
  with the phar; clear error if php is not in PATH
- release.yml: add 'Bundle PHAR into @dbdiff/cli' step that copies
  binaries/dbdiff-phar/dbdiff.phar into the package directory before npm
  publish (mirrors how Composer and WP-CLI ship on Windows via npm)

Result: Windows users get a working 'dbdiff' command immediately after
'npm install -g @dbdiff/cli' as long as PHP 8.1+ is in their PATH —
which is always true for the PHP developers this tool targets.
@dbdiff/cli-win32-arm64 was being skipped during npm publish because
SPC doesn't support building a native Windows ARM64 binary. Now that
@dbdiff/cli bundles dbdiff.phar and bin/dbdiff.js falls back to
'php dbdiff.phar' when no native binary is present, publishing the
skeleton package is meaningful — npm installs it, bin/dbdiff.js finds
it, sees no dbdiff.exe, and falls through to the PHAR fallback.

Add PHAR_FALLBACK_PKGS list to the publish loop. Packages in that list
are published even without a binary; all other packages without a binary
are still skipped with a warning (indicating a build failure).
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 7, 2026

@jasdeepkhalsa jasdeepkhalsa merged commit 722e713 into master Mar 7, 2026
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant