chia-blockchain/build_scripts/build_windows-2-installer.ps1
Patrick Maslana 3a2dc484b5
Generate a license directory that contains licenses missing from the installers (#15146)
* Add scripts to build a tree of licenses that are missing from the installers

* Add a line that was accidentally removed

* add steps in the build_license_directory script to install pip-licenses and license-checker

* Pip install pip-license

* Added commands to check the working dir in the build_license_direcotory.sh

* Fix the path for the npm commands

* Copy the library dir over

* Add a line to cd back to the previous dir in the build_licenses_directory.sh file

* Fix path to go back to "build_scripts"

* Fixing a typo with a path in the build_license_directory.sh file

* Troubleshoot path

* Change word from library to licenses

* Add a command to list contents of "dist/$CLI_DEB_BASE/opt/chia/" for troubleshooting

* Copy the license file to the "GUI" directory

* Fix the last for loop

* Move the step to change directory back to build scripts in the build_license_directory.sh file

* Add some more steps to troubleshoot the path and license-checker usage

* Fix a typo

* Add an "npm install ." before running the license-checker

* Fix a typo

* Change back to the build_scripts dir before the first loop in build_license_directory.sh file

* Revert "Change back to the build_scripts dir before the first loop in build_license_directory.sh file"

This reverts commit a3e88a2583.

* Fix the path for moving the license file

* Change the first loop for printing licenses from npm license-checker

* Add steps to copy the license file over to the builds and comment out the "npm install ." step out of the build_license_firectory script

* Add npm ci to the build_license_directory file

* Adding a dir for troubleshooting

* Fix errors in the scripts

* Fix a path to the licenses file

* Remove a dir from the windows installer script

* Remove a copy command

* Remove a few more copy commands

* Adding a ps1 script for usage in the windows installer build script

* Replace the powershell script

* Made a couple changes to the ps1 script for building the license directory

* Remove the ps1 script for building the license dir

* Add a new script for the windows installer to build the license dir

* Fix issues with the code for windows

* Remove the -1 from NF

* Changing the script for windows to test

* Remove filename=$(basename "$i")

* Remove some ls command lines

* Add "cp -r dist/daemon ../chia-blockchain-gui/packages/gui" to the RPM installer script

* Remove "|| 'exit" or "cd' || return" from when CD'ing in the license creation scripts

* Remove extra set of ||
2023-06-21 16:51:05 -05:00

98 lines
3.1 KiB
PowerShell

# $env:path should contain a path to editbin.exe and signtool.exe
$ErrorActionPreference = "Stop"
mkdir build_scripts\win_build
git status
git submodule
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 "Creating a directory of licenses from pip and npm packages"
Write-Output " ---"
bash ./build_win_license_dir.sh
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
If ($env:HAS_SECRET) {
$env:CSC_LINK = Join-Path "." "win_code_sign_cert.p12" -Resolve
}
Write-Output " ---"
Write-Output "Prepare Electron packager"
Write-Output " ---"
$Env:NODE_OPTIONS = "--max-old-space-size=3000"
# Change to the GUI directory
Set-Location -Path "chia-blockchain-gui\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-builder"
electron-builder build --win --x64 --config.productName="Chia"
Get-ChildItem dist\win-unpacked\resources
Write-Output " ---"
If ($env:HAS_SECRET) {
Write-Output " ---"
Write-Output "Verify signature"
Write-Output " ---"
signtool.exe verify /v /pa .\dist\ChiaSetup-$packageVersion.exe
} Else {
Write-Output "Skipping verify signatures - no authorization to install certificates"
}
Write-Output " ---"
Write-Output "Moving final installers to expected location"
Write-Output " ---"
Copy-Item ".\dist\win-unpacked" -Destination "$env:GITHUB_WORKSPACE\chia-blockchain-gui\Chia-win32-x64" -Recurse
mkdir "$env:GITHUB_WORKSPACE\chia-blockchain-gui\release-builds\windows-installer" -ea 0
Copy-Item ".\dist\ChiaSetup-$packageVersion.exe" -Destination "$env:GITHUB_WORKSPACE\chia-blockchain-gui\release-builds\windows-installer"
Write-Output " ---"
Write-Output "Windows Installer complete"
Write-Output " ---"