kiwix-js-pwa/scripts/Build-NWJS.ps1
Jaifroid 04b02186a3 Update release scripts
Former-commit-id: 07220fde35e57bc5e103f088d06db967ab4af717 [formerly d7191623c1bdbdd177e288b341d77147418fe168 [formerly bf4d11ef3e3ed2bed7146718f2b379536fd66368]]
Former-commit-id: 1f90922a5a62cd910dd9e099c910dc7e6242e9c9
Former-commit-id: d6f8b5ced3f3b5d8000428dd89b6a0d916299084
2021-04-20 16:09:27 +01:00

73 lines
2.9 KiB
PowerShell

$builds = @("win-x64", "win-ia32", "win-xp")
$version = "0.52.2"
$versionXP = "0.14.7"
$appBuild = "1.2.5N"
$ZIMbase = "wikipedia_en_100_maxi"
cd $PSScriptRoot
cd ..
foreach ($build in $builds) {
"Building $build $version..."
$OBuild = $build
$sep = '-'
if ($build -eq "win-xp") {
$build = "win-ia32"
$version = $versionXP
$sep = '-XP-'
}
$folderTarget = "bld\nwjs\$build-$version"
$target = "$folderTarget\kiwix_js_windows$sep$appBuild"
$fullTarget = "$target-$build"
$ZipLocation = "node_modules\nwjs-builder-phoenix\caches\nwjs-v$version-$build.zip"
$UnzipLocation = "$ZipLocation-extracted\"
$buildLocation = "$ZipLocation-extracted\nwjs-v$version-$build\"
if (-Not (Test-Path $buildLocation -PathType Container)) {
# We need to download and/or unzip the release, as it is not available
if (-Not (Test-Path $ZipLocation -PathType Leaf)) {
$serverFile = "https://dl.nwjs.io/v$version/nwjs-v$version-$build.zip"
"Downloading $serverFile"
Invoke-WebRequest -Uri $serverFile -OutFile $ZipLocation
}
"Unzipping archive $ZipLocation"
Expand-Archive $ZipLocation $UnzipLocation
if (-Not (Test-Path $buildLocation -PathType Container)) {
"There was an error! The unzipped folder $buildLocation could not be found!"
return
}
}
$archiveFolder = "$fullTarget\archives"
if (Test-Path $folderTarget -PathType Container) {
"Removing directory $folderTarget..."
rm $folderTarget\* -Recurse
rm $folderTarget
}
md $fullTarget
# Copy latest binary x64
cp $buildLocation\* $fullTarget -Recurse
cp .\package.json, .\pwabuilder-sw.js, .\index.html, .\CHANGELOG.md, .\LICENSE, .\www $fullTarget -Recurse
"Copying archive..."
md $archiveFolder
cp "archives\$ZIMbase*.*", "archives\README.md" $archiveFolder
"Creating launchers..."
$launcherStub = ".\bld\nwjs\$build-$version\Start Kiwix JS Windows"
$foldername = "kiwix_js_windows$sep$appBuild-$build"
# Batch file
$batch = '@cd "' + $foldername + '"' + "`r`n" + '@start "Kiwix JS Windows" "nw.exe"' + "`r`n"
$batch > "$launcherStub.bat"
# Shortcut
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$launcherStub.lnk")
$Shortcut.TargetPath = '%windir%\explorer.exe'
$Shortcut.Arguments = "$foldername\nw.exe"
$Shortcut.IconLocation = '%windir%\explorer.exe,12'
$Shortcut.Save()
# Zip everything up
$ZipBuild = "bld\nwjs\$foldername.zip"
if (Test-Path $ZipBuild -PathType Leaf) {
"Deleting old Zip build $ZipBuild..."
del $ZipBuild
}
"Compressing folder..."
Compress-Archive "bld\nwjs\$build-$version\*" "bld\nwjs\$foldername.zip" -Force
"Build $OBuild finished.`n"
}