Skip to content

Commit 2c3b0e3

Browse files
committed
fix build package for windows
1 parent 0a9166b commit 2c3b0e3

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

scripts/build-windows-package.ps1

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
1414
#>
1515

16-
# Build windows package
17-
flutter clean
18-
flutter build windows
16+
# # Build windows package
17+
# flutter clean
18+
# flutter build windows
1919

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

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

2829
New-Item -Path $work_dir -ItemType Directory
2930

30-
# Download the starcoin latest version
31-
Invoke-WebRequest -Uri $starcoin_node_url -OutFile "$work_dir\starcoin-windows-latest.zip"
31+
## Download the starcoin latest version
32+
$starcoin_zip = "$work_dir\starcoin-windows-latest.zip"
33+
Invoke-WebRequest -Uri $starcoin_node_url -OutFile $starcoin_zip
34+
35+
$retryCount = 0
36+
$maxRetries = 4
37+
38+
while ($retryCount -lt $maxRetries -and -not (Test-Path -Path $starcoin_zip)) {
39+
$retryCount ++
40+
41+
Write-Host "File download failed, try to download again, retry times: $retryCount ..."
42+
Invoke-WebRequest -Uri $starcoin_node_url -OutFile $starcoin_zip
43+
44+
Start-Sleep -Seconds 5
45+
}
46+
47+
# Check file is exist
48+
if (!(Test-Path -Path $starcoin_zip)) {
49+
Write-Error "File download failed, the maximum number of retries has been reached: $maxRetries"
50+
exit 1
51+
}
52+
3253
Expand-Archive -Path "$work_dir\starcoin-windows-latest.zip" -DestinationPath "$work_dir\starcoin" -Force
3354
Remove-Item -Path "$work_dir\starcoin-windows-latest.zip" -Force
3455

35-
# Compress zip
36-
Compress-Archive -Path ("$root_dir\build\windows\runner\Release", "$work_dir\starcoin") -DestinationPath "$work_dir\starcoin_node_gui_windows.zip"
56+
57+
# Copy files
58+
New-Item -Path "$package_dir" -ItemType Directory
59+
Copy-Item -Path "$root_dir\build\windows\runner\Release\*" -Destination "$package_dir" -Recurse -Force
60+
61+
New-Item -Path "$package_dir\starcoin" -ItemType Directory
62+
Copy-Item -Path "$work_dir\starcoin\starcoin-artifacts\*" -Destination "$package_dir\starcoin"
63+
64+
# Compress zip
65+
Compress-Archive -Path $package_dir -DestinationPath "${package_dir}_windows.zip"
66+
67+
Write-Output "Done!! Output dir: ${package_dir}_windows.zip"

0 commit comments

Comments
 (0)