Technology
We moved our kiosk installer build into one cmd step and nothing after npm ever ran
Source: Dev Community|
2 min read
Our depot kiosks run a small Electron application, and its Windows installer used to be built by Jenkins on a Windows agent. The job had three bat steps: npm run dist, then signtool sign with our code signing certificate and a timestamp, then signtool verify /pa on the result. In September we moved it to GitHub Actions on a Windows runner. To keep the commands exactly as they were, we put all three lines into one step with shell: cmd. The workflow was green, the installer was uploaded to the release, and we moved on. Five weeks later a depot manager setting up a new kiosk sent us a screenshot of a blue box: Windows protected your PC, publisher unknown. Every installer we had published since the move was unsigned. npm on Windows is not a program. It is npm.cmd, a batch file. In a batch script, running another batch file by name hands control to it, and when it finishes, control does not come back to the line after it. The script simply ends there, with the exit code of the batch file it handed over to. You need call npm run dist to return. Jenkins had hidden this from us for years, because each bat step was its own script with one line in it. Our new step ran npm run dist, which succeeded, and stopped. The signing line never ran. Neither did the line that was there to verify the signing, which is the part that stung. The fix for that night was the word call. The fix we kept was structural. Each command now has its own step, so each has its own exit status, and the steps use the default pwsh shell instead of cmd. Verification is a separate step that runs Get-AuthenticodeSignature on every file we are about to publish and fails unless the status is Valid and the signer is our certificate. The release job only uploads what that step has checked. A short lint runs on every workflow change and fails any cmd step with more than one line. We re-signed and republished the three installers, and asked the depots to reinstall them. The script did not fail. It ended early, politely, and reported the success of the last thing it had done. – Sergey Shinder