chia-blockchain/build_scripts/build_windows.ps1
Kyle Altendorf fd9ff115e3
tidy installer building (#11077)
* tidy installer building

* -d

* fix rpm build

* try for windows

* Install.ps1 -d

* move the install.ps1 call out to the workflow

* Update build_windows.ps1

* Update build_windows.ps1

* debug non-editable install on windows

* platlib and purelib in pyinstaller pathex

* Revert "debug non-editable install on windows"

This reverts commit 7c04168969.

* Revert "platlib and purelib in pyinstaller pathex"

This reverts commit c5c5cdcd81.

* debug

* debug not-editable

* Revert "debug not-editable"

This reverts commit d4373d8e82.

* a bit more similar

* git -C

* find dlls in site-packages?

* oops

* Revert "debug"

This reverts commit 88090f689f.

* consistently name installer github actions artifact zips

* leave SCM_VERSION here

* Update build-windows-installer.yml
2022-04-29 18:34:48 -07:00

119 lines
3.5 KiB
PowerShell

# $env:path should contain a path to editbin.exe and signtool.exe
$ErrorActionPreference = "Stop"
mkdir build_scripts\win_build
git status
if (-not (Test-Path env:CHIA_INSTALLER_VERSION)) {
$env:CHIA_INSTALLER_VERSION = '0.0.0'
Write-Output "WARNING: No environment variable CHIA_INSTALLER_VERSION set. Using 0.0.0"
}
Write-Output "Chia Version is: $env:CHIA_INSTALLER_VERSION"
Write-Output " ---"
Write-Output " ---"
Write-Output "Use pyinstaller to create chia .exe's"
Write-Output " ---"
$SPEC_FILE = (python -c 'import chia; print(chia.PYINSTALLER_SPEC_PATH)') -join "`n"
pyinstaller --log-level INFO $SPEC_FILE
Write-Output " ---"
Write-Output "Copy chia executables to chia-blockchain-gui\"
Write-Output " ---"
Copy-Item "dist\daemon" -Destination "..\chia-blockchain-gui\packages\gui\" -Recurse
Write-Output " ---"
Write-Output "Setup npm packager"
Write-Output " ---"
Set-Location -Path ".\npm_windows" -PassThru
npm ci
$Env:Path = $(npm bin) + ";" + $Env:Path
Set-Location -Path "..\" -PassThru
Set-Location -Path "..\chia-blockchain-gui" -PassThru
# We need the code sign cert in the gui subdirectory so we can actually sign the UI package
If ($env:HAS_SECRET) {
Copy-Item "win_code_sign_cert.p12" -Destination "packages\gui\"
}
git status
Write-Output " ---"
Write-Output "Prepare Electron packager"
Write-Output " ---"
$Env:NODE_OPTIONS = "--max-old-space-size=3000"
lerna clean -y
npm ci
# Audit fix does not currently work with Lerna. See https://github.com/lerna/lerna/issues/1663
# npm audit fix
git status
Write-Output " ---"
Write-Output "Electron package Windows Installer"
Write-Output " ---"
npm run build
If ($LastExitCode -gt 0){
Throw "npm run build failed!"
}
# Change to the GUI directory
Set-Location -Path "packages\gui" -PassThru
Write-Output " ---"
Write-Output "Increase the stack for chia command for (chia plots create) chiapos limitations"
# editbin.exe needs to be in the path
editbin.exe /STACK:8000000 daemon\chia.exe
Write-Output " ---"
$packageVersion = "$env:CHIA_INSTALLER_VERSION"
$packageName = "Chia-$packageVersion"
Write-Output "packageName is $packageName"
Write-Output " ---"
Write-Output "fix version in package.json"
choco install jq
cp package.json package.json.orig
jq --arg VER "$env:CHIA_INSTALLER_VERSION" '.version=$VER' package.json > temp.json
rm package.json
mv temp.json package.json
Write-Output " ---"
Write-Output " ---"
Write-Output "electron-packager"
electron-packager . Chia --asar.unpack="**\daemon\**" --overwrite --icon=.\src\assets\img\chia.ico --app-version=$packageVersion
Write-Output " ---"
Write-Output " ---"
Write-Output "node winstaller.js"
node winstaller.js
Write-Output " ---"
git status
If ($env:HAS_SECRET) {
Write-Output " ---"
Write-Output "Add timestamp and verify signature"
Write-Output " ---"
signtool.exe timestamp /v /t http://timestamp.comodoca.com/ .\release-builds\windows-installer\ChiaSetup-$packageVersion.exe
signtool.exe verify /v /pa .\release-builds\windows-installer\ChiaSetup-$packageVersion.exe
} Else {
Write-Output "Skipping timestamp and verify signatures - no authorization to install certificates"
}
git status
Write-Output " ---"
Write-Output "Moving final installers to expected location"
Write-Output " ---"
Copy-Item ".\Chia-win32-x64" -Destination "$env:GITHUB_WORKSPACE\chia-blockchain-gui\" -Recurse
Copy-Item ".\release-builds" -Destination "$env:GITHUB_WORKSPACE\chia-blockchain-gui\" -Recurse
Write-Output " ---"
Write-Output "Windows Installer complete"
Write-Output " ---"