Skip to content

Commit

Permalink
Merge pull request #1253 from mrpalide/fix/windows-installer-script
Browse files Browse the repository at this point in the history
Improve Windows Installer Script
  • Loading branch information
ersonp authored Jun 21, 2022
2 parents 5d723a0 + 49b7055 commit 419e836
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 40 deletions.
2 changes: 0 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ builds:
- amd64
- 386
ignore:
- goos: darwin
goarch: 386
- goos: windows
goarch: arm64
tags:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- remove transports cache from visor initialization and check them before make route
- `run-source` makefile directive write config to stdout & read config from stdin
- fixed skywire-visor uses skywire-config.json (default config name) without needing to specify
- `make win-installer` need new argument `CUSTOM_VERSION` to get make installer for this version, use for pre-releases
- changed the log levels of most of the logs making info level clutter free

### Added
Expand Down Expand Up @@ -54,6 +55,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `run-vpnsrv-dmsghttp` makefile directive
- `run-vpnsrv -dmsghttp-test` makefile directive
- `install-system-linux` and `install-system-linux-systray` makefile directives
- `skywire-cli dmsgpty list` to view of connected remote visor to hypervisor
- `skywire-cli dmsgpty start <pk>` to connect through dmsgpty to remote visor
- `make win-installer-latest` to create installer for latest version of released, not pre-release.
- `trace` log level is added
- `--log-lever` flag to generate and update config by `skywire-cli`

Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,11 @@ mac-installer-release: mac-installer ## Upload created signed and notarized appl
gh release upload --repo skycoin/skywire ${GITHUB_TAG} ./skywire-installer-${GITHUB_TAG}-darwin-amd64.pkg
gh release upload --repo skycoin/skywire ${GITHUB_TAG} ./skywire-installer-${GITHUB_TAG}-darwin-arm64.pkg

win-installer-latest:
@powershell '.\scripts\win_installer\script.ps1 latest'

win-installer:
@powershell '.\scripts\win_installer\script.ps1'
@powershell '.\scripts\win_installer\script.ps1 $(CUSTOM_VERSION)'

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand Down
111 changes: 81 additions & 30 deletions scripts/win_installer/script.ps1
Original file line number Diff line number Diff line change
@@ -1,30 +1,81 @@
echo "Building Systray Windows Binaries..."
if (Test-Path ".\skywire.msi") { Remove-Item ".\skywire.msi" -Recurse -Force}
if (Test-Path ".\wintun.zip") { Remove-Item ".\wintun.zip" -Recurse -Force}
make build-systray-windows BUILDTAG="Windows" > $null
echo "Build Complete!"
echo "Setting go-msi configuration..."
cd .\scripts\win_installer
if (Test-Path ".\build") { Remove-Item ".\build" -Recurse -Force}
mkdir -p ".\build\amd64\apps" > $null
mv ..\..\skywire-visor.exe .\build\amd64\skywire-visor.exe
mv ..\..\skywire-cli.exe .\build\amd64\skywire-cli.exe
mv ..\..\apps\vpn-client.exe .\build\amd64\apps\vpn-client.exe
cp ..\..\dmsghttp-config.json .\build\amd64\dmsghttp-config.json
rm ..\..\setup-node.exe
rm -r -fo ..\..\apps
cp skywire.bat .\build\amd64\skywire.bat
ni new.update
mv new.update .\build\amd64\new.update
curl "https://www.wintun.net/builds/wintun-0.14.1.zip" -o wintun.zip
tar -xf wintun.zip
cp .\wintun\bin\amd64\wintun.dll .\build\amd64\wintun.dll
rm -r -fo wintun
rm wintun.zip
echo "Configuration complete!"
echo "Building msi..."
go-msi make --msi skywire.msi --version 1.0.0 --arch amd64
mv skywire.msi ../../skywire.msi
Remove-Item ".\build" -Recurse -Force
cd ../../
echo "Build Complete!"

$ErrorActionPreference = "Stop"
$version = $args[0]
function CleanStage
{
if (Test-Path ".\archive.zip") { Remove-Item ".\archive.zip" -Recurse -Force}
if (Test-Path ".\archive") { Remove-Item ".\archive" -Recurse -Force}
if (Test-Path ".\scripts\win_installer\build") { Remove-Item ".\scripts\win_installer\build" -Recurse -Force}
if (Test-Path ".\scripts\win_installer\wintun.zip") { Remove-Item ".\scripts\win_installer\wintun.zip" -Recurse -Force}
if (Test-Path ".\scripts\win_installer\wintun") { Remove-Item ".\scripts\win_installer\wintun" -Recurse -Force}
if (Test-Path ".\scripts\win_installer\skywire.msi") { Remove-Item ".\scripts\win_installer\skywire.msi" -Recurse -Force}
}

function BuildInstaller($arch)
{
if ($arch -eq "386") {
$wintun_arch="x86"
$arch_title="386 "
} else {
$wintun_arch="amd64"
$arch_title="amd64"
}

Write-Output "# #"
Write-Output "# => Create Installer for $arch_title #"
Write-Output "# 1. Preparing Stage... #"
CleanStage

Write-Output "# 2. Fetching Archive from GitHub... #"
if ($version -eq "latest") {
$url = 'https://github.com/skycoin/skywire/releases/latest'
$request = [System.Net.WebRequest]::Create($url)
$response = $request.GetResponse()
$realTagUrl = $response.ResponseUri.OriginalString
$version = $realTagUrl.split('/')[-1].Trim('v')
$fileName = "skywire-systray-v$version-windows-$arch"
$downloadURL = "https://github.com/skycoin/skywire/releases/download/v$version/$filename.zip"
Invoke-WebRequest $downloadURL -o archive.zip -ErrorAction Stop
} else {
$fileName = "skywire-systray-$version-windows-$arch"
$downloadURL = "https://github.com/skycoin/skywire/releases/download/$version/$filename.zip"
Invoke-WebRequest $downloadURL -o archive.zip
}

Write-Output "# 3. Extracing Downloaded Archive File... #"
Expand-Archive -Path archive.zip

Write-Output "# 4. Preparing Environment for Go-MSI... #"
Set-Location .\scripts\win_installer
mkdir -p ".\build\apps" > $null
Move-Item ..\..\archive\skywire-visor.exe .\build\skywire-visor.exe
Move-Item ..\..\archive\skywire-cli.exe .\build\skywire-cli.exe
Move-Item ..\..\archive\apps\vpn-client.exe .\build\apps\vpn-client.exe
Copy-Item ..\..\archive\dmsghttp-config.json .\build\dmsghttp-config.json
Copy-Item skywire.bat .\build\skywire.bat
New-Item new.update > $null
Move-Item new.update .\build\new.update
Invoke-WebRequest "https://www.wintun.net/builds/wintun-0.14.1.zip" -o wintun.zip
Expand-Archive wintun.zip
Copy-Item .\wintun\wintun\bin\$wintun_arch\wintun.dll .\build\wintun.dll

Write-Output "# 5. Building MSI Installer... #"
go-msi make --msi skywire.msi --version 1.0.0 --arch $arch > $null
Move-Item skywire.msi ../../$fileName.msi -Force

Write-Output "# ==> Build Completed for $arch_title! #"

Write-Output "# 6. Cleaning Stage... #"
Set-Location ../../
CleanStage

Write-Output "# 7. Done! #"
}

Write-Output "`n##########################################################"
Write-Output "# #"
Write-Output "# .:::: Create MSI Installer Package ::::. #"
BuildInstaller("amd64")
BuildInstaller("386")
Write-Output "# #"
Write-Output "##########################################################`n"
14 changes: 7 additions & 7 deletions scripts/win_installer/wix.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"files": {
"guid": "",
"items": [
"build/amd64/skywire-cli.exe",
"build/amd64/skywire-visor.exe",
"build/amd64/apps/vpn-client.exe",
"build/amd64/skywire.bat",
"build/skywire-cli.exe",
"build/skywire-visor.exe",
"build/apps/vpn-client.exe",
"build/skywire.bat",
"ico.ico",
"build/amd64/wintun.dll",
"build/amd64/dmsghttp-config.json",
"build/amd64/new.update"
"build/wintun.dll",
"build/dmsghttp-config.json",
"build/new.update"
]
},
"env": {
Expand Down

0 comments on commit 419e836

Please sign in to comment.