Skip to content

Commit

Permalink
fix build package for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
welbon committed Feb 2, 2024
1 parent 0a9166b commit 2c3b0e3
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions scripts/build-windows-package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
#>

# Build windows package
flutter clean
flutter build windows
# # Build windows package
# flutter clean
# flutter build windows

$root_dir = "$(pwd)"
$work_dir = "$root_dir\publish"
$package_dir = "$work_dir\starcoin_node_gui"
$starcoin_node_url = "https://github.com/starcoinorg/starcoin/releases/download/v2.0.3-alpha/starcoin-windows-latest.zip"

if (Test-Path $work_dir -PathType Container) {
Expand All @@ -27,10 +28,40 @@ if (Test-Path $work_dir -PathType Container) {

New-Item -Path $work_dir -ItemType Directory

# Download the starcoin latest version
Invoke-WebRequest -Uri $starcoin_node_url -OutFile "$work_dir\starcoin-windows-latest.zip"
## Download the starcoin latest version
$starcoin_zip = "$work_dir\starcoin-windows-latest.zip"
Invoke-WebRequest -Uri $starcoin_node_url -OutFile $starcoin_zip

$retryCount = 0
$maxRetries = 4

while ($retryCount -lt $maxRetries -and -not (Test-Path -Path $starcoin_zip)) {
$retryCount ++

Write-Host "File download failed, try to download again, retry times: $retryCount ..."
Invoke-WebRequest -Uri $starcoin_node_url -OutFile $starcoin_zip

Start-Sleep -Seconds 5
}

# Check file is exist
if (!(Test-Path -Path $starcoin_zip)) {
Write-Error "File download failed, the maximum number of retries has been reached: $maxRetries"
exit 1
}

Expand-Archive -Path "$work_dir\starcoin-windows-latest.zip" -DestinationPath "$work_dir\starcoin" -Force
Remove-Item -Path "$work_dir\starcoin-windows-latest.zip" -Force

# Compress zip
Compress-Archive -Path ("$root_dir\build\windows\runner\Release", "$work_dir\starcoin") -DestinationPath "$work_dir\starcoin_node_gui_windows.zip"

# Copy files
New-Item -Path "$package_dir" -ItemType Directory
Copy-Item -Path "$root_dir\build\windows\runner\Release\*" -Destination "$package_dir" -Recurse -Force

New-Item -Path "$package_dir\starcoin" -ItemType Directory
Copy-Item -Path "$work_dir\starcoin\starcoin-artifacts\*" -Destination "$package_dir\starcoin"

# Compress zip
Compress-Archive -Path $package_dir -DestinationPath "${package_dir}_windows.zip"

Write-Output "Done!! Output dir: ${package_dir}_windows.zip"

0 comments on commit 2c3b0e3

Please sign in to comment.