chia-blockchain/build_scripts/build_windows-2-installer.ps1
Izumi Hoshino b3b56a64d1
Replace electron-packager with electron-builder (#12953)
* Install electron-builder

* Replaced electron-packager with electron-builder for windows

* Upgraded electron-builder version for mac

* Replaced electron-packager with electron-builder for Linux and integreated deb/rpm dir

* Updated mac installer job

* Fixed app.asar location

* Fixed dmg name for arm64 mac

* Updated installer-version.py

* Updated Linux(deb) installer CI job

* Updated Linux(rpm) installer CI job

* Fixed Linux(rpm) install CI issue

* Revert to use `electron-packager` instead of `electron-builder` for arm64 .deb installer

* Fixed lint errors

* Fixed rpm installer job issue

* Updated Windows installer CI job

* Fixed rpm installer CI job

* Simplified arm64 build

* Added -y option to `apt install` command

* Added `dmg-license` as npm build dependency for MacOS

* Attempt to set product name appropriately for each platform

* Specified productNames in commands

* Fixed arm64 installer issue

* Stopped to create link '/opt/chia/daemon'

* Updated desktop app name for linux installers

* Updated packageName for linux installers

* Abort build jobs when 'cd' fails

* Updated the GUI submodule ref (main:5e52b7f53478d4f39b4a0f0203f41e31dd53aee9)

Co-authored-by: Jeff Cruikshank <jeff@chia.net>
2022-08-24 20:13:40 -05:00

93 lines
2.9 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 "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 " ---"