|
| 1 | +TestBuddy - Distribution & Signing Guide |
| 2 | +======================================== |
| 3 | + |
| 4 | +Purpose |
| 5 | +------- |
| 6 | +This guide explains exactly how to produce signed, installable Windows artifacts for TestBuddy and how to configure the CI pipeline to produce release builds and signed installers. |
| 7 | + |
| 8 | +What we added for you |
| 9 | +--------------------- |
| 10 | +- `build_windows.ps1` / `build_windows.bat` — build the EXE (PyInstaller) and compile NSIS installer (if `makensis` is available). |
| 11 | +- `testbuddy_installer.nsi` — NSIS installer script (references `dist/TestBuddy.exe`). |
| 12 | +- GitHub Actions workflow: `.github/workflows/windows_build.yml` that: |
| 13 | + - Installs dependencies |
| 14 | + - Runs tests |
| 15 | + - Builds EXE and runs NSIS (on Windows runner) |
| 16 | + - Generates `CHECKSUMS.txt` (SHA256) |
| 17 | + - Uploads artifacts |
| 18 | + - Optionally signs artifacts if signing secrets are present |
| 19 | + - Creates a GitHub Release and attaches artifacts |
| 20 | + |
| 21 | +Requirements before distribution |
| 22 | +-------------------------------- |
| 23 | +1. Windows code signing certificate (PFX) with private key. |
| 24 | + - Obtain from a CA (DigiCert, Sectigo, GlobalSign). EV certificates are recommended for broad trust. |
| 25 | +2. GitHub repo-level secrets (to enable automatic signing): |
| 26 | + - `SIGN_CERT_PFX` — base64-encoded contents of the PFX file |
| 27 | + - `SIGN_CERT_PASSWORD` — password for the PFX |
| 28 | + |
| 29 | +How to create the base64 PFX secret (PowerShell) |
| 30 | +------------------------------------------------ |
| 31 | +Run locally and copy the output into the `SIGN_CERT_PFX` secret value in GitHub: |
| 32 | + |
| 33 | +```powershell |
| 34 | +$bytes = [System.IO.File]::ReadAllBytes('C:\path\to\your-cert.pfx') |
| 35 | +$base64 = [Convert]::ToBase64String($bytes) |
| 36 | +# Save temporarily |
| 37 | +Set-Content -Path C:\tmp\cert.pfx.b64 -Value $base64 |
| 38 | +# Open the file and copy-paste the single-line content into the repo secret |
| 39 | +notepad C:\tmp\cert.pfx.b64 |
| 40 | +``` |
| 41 | + |
| 42 | +Add the PFX password as `SIGN_CERT_PASSWORD` in GitHub Secrets. |
| 43 | + |
| 44 | +Signing options supported in the workflow |
| 45 | +---------------------------------------- |
| 46 | +- `osslsigncode` (open-source): used on Windows runner (installed via Chocolatey). Works with PFX. |
| 47 | +- `signtool` (Microsoft): preferred for EV certs / MS recommended signing. If you prefer `signtool`, you can modify the workflow to call `signtool` instead; it requires the Windows SDK or a runner that has `signtool.exe` available. |
| 48 | + |
| 49 | +How to trigger a release build |
| 50 | +------------------------------ |
| 51 | +- Option A: Push a commit to `main` branch (workflow runs automatically) |
| 52 | +- Option B: Run `Build Windows` workflow manually from the Actions UI (workflow_dispatch) |
| 53 | + |
| 54 | +How the workflow produces artifacts |
| 55 | +----------------------------------- |
| 56 | +1. `pyinstaller` creates `dist/TestBuddy.exe` (one-file, windowed). |
| 57 | +2. NSIS compiles `TestBuddy-Setup.exe` if `makensis` is available on the runner. |
| 58 | +3. `CHECKSUMS.txt` is produced with SHA256 lines for each artifact. |
| 59 | +4. Optional signing step (if secrets present) produces `*-signed.exe` variants. |
| 60 | +5. The release flow creates a tag like `vYYYYMMDD-<run_number>` and publishes a Release, attaching artifacts and `CHECKSUMS.txt`. |
| 61 | + |
| 62 | +Manual verification steps (recommended) |
| 63 | +-------------------------------------- |
| 64 | +- Download artifacts from the workflow run or Release. |
| 65 | +- Verify SHA256 matches the values in `CHECKSUMS.txt`: |
| 66 | + ```powershell |
| 67 | + Get-FileHash .\TestBuddy-Setup.exe -Algorithm SHA256 |
| 68 | + Get-Content CHECKSUMS.txt |
| 69 | + ``` |
| 70 | +- Install on a clean VM (Windows 10/11) and verify: |
| 71 | + - App launches |
| 72 | + - Sessions load |
| 73 | + - Export features work (PDF, DOCX, CSV, HTML, Markdown, JSON, TXT) |
| 74 | + - Document Intelligence analyze works (with Tesseract installed) |
| 75 | + - Uninstall removes program files |
| 76 | + |
| 77 | +If you want to use `signtool` instead of `osslsigncode` |
| 78 | +------------------------------------------------------ |
| 79 | +- Upload PFX as repo secret as above. |
| 80 | +- Modify the workflow step `Optional: Sign artifacts` to call `signtool.exe sign /f cert.pfx /p <password> /tr http://timestamp.digicert.com /td sha256 /fd sha256 <file>` |
| 81 | +- On hosted runners, `signtool` may not be present. You'll need either to install Windows SDK in the runner (adds time), or use a self-hosted Windows runner that has `signtool` installed and your signing cert available. |
| 82 | + |
| 83 | +Recommended post-release steps |
| 84 | +------------------------------ |
| 85 | +- Sign all binaries and installer before publishing to avoid "Unknown Publisher" warnings. |
| 86 | +- Consider using an official code-signing service or HSM for private key security. |
| 87 | +- Publish checksums on the website and in the release notes. |
| 88 | +- For automated distribution, consider pushing artifacts to a CDN or S3 bucket and use the installer to fetch updates. |
| 89 | + |
| 90 | +Support and troubleshooting |
| 91 | +------------------------- |
| 92 | +If a workflow fails: |
| 93 | +- Open the Actions run and expand logs for the failing step. |
| 94 | +- For signing issues, ensure the PFX is valid and not password-protected with non-ASCII characters that could break environment handling. |
| 95 | +- For NSIS errors, ensure makensis is available and the path to the EXE referenced in `testbuddy_installer.nsi` matches the build output. |
| 96 | + |
| 97 | +Contact |
| 98 | +------- |
| 99 | +If you'd like, I can: |
| 100 | +- Switch the workflow to use `signtool` and/or a self-hosted signing runner. |
| 101 | +- Add automatic changelog generation using Conventional Commits or `release-drafter`. |
| 102 | +- Add an auto-update server or mechanism. |
| 103 | + |
| 104 | +*** End of guide *** |
0 commit comments