mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-08-07 05:19:15 -04:00

Former-commit-id: 8611343e39b1cfc61f37da3fe0b716a42e55723d [formerly f7eede55dfca8430553bd1d729fb19cbd1cac7c8 [formerly 52d9b5ddeba4e0593ec7e1184e023bcfcbbdd9e4]] Former-commit-id: fb656d995de21e545aed8ca698a0d970b6cb57cf Former-commit-id: fbe2f14c33a46db5084e4f6f3b1a4df8837f9620
83 lines
3.4 KiB
PowerShell
83 lines
3.4 KiB
PowerShell
param (
|
|
[switch]$only32bit = $false
|
|
)
|
|
$builds = @("win-ia32", "win-xp")
|
|
if (-Not $only32bit) {
|
|
$builds += "win-x64"
|
|
"Caller requested 32bit and 64bit build"
|
|
} else {
|
|
"Caller requested 32bitonly build"
|
|
}
|
|
$version10 = "0.55.0" # <<< value updated automatically from package.json if launched from Create-DraftRelease
|
|
$versionXP = "0.14.7"
|
|
$appBuild = "1.7.2N" # <<< value updated auotmatically from package.json if launched form Create-DraftRelease
|
|
$ZIMbase = "wikipedia_en_100_maxi"
|
|
foreach ($build in $builds) {
|
|
$version = $version10
|
|
$OBuild = $build
|
|
$sep = '-'
|
|
if ($build -eq "win-xp") {
|
|
$build = "win-ia32"
|
|
$version = $versionXP
|
|
$sep = '-XP-'
|
|
}
|
|
"`nBuilding $build $version..."
|
|
$folderTarget = "$PSScriptRoot\..\bld\nwjs\$build-$version"
|
|
$target = "$folderTarget\kiwix_js_windows$sep$appBuild"
|
|
$fullTarget = "$target-$build"
|
|
$ZipLocation = "$PSScriptRoot\..\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
|
|
$root = $PSScriptRoot -replace 'scripts.*$', ''
|
|
cp $root\package.json, $root\pwabuilder-sw.js, $root\index.html, $root\CHANGELOG.md, $root\LICENSE, $root\www $fullTarget -Recurse
|
|
"Copying archive..."
|
|
md $archiveFolder
|
|
cp "$root\archives\$ZIMbase*.*", "$root\archives\README.md" $archiveFolder
|
|
"Creating launchers..."
|
|
$launcherStub = $PSScriptRoot -replace 'scripts.*$', "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 = "$PSScriptRoot\..\bld\nwjs\$foldername.zip"
|
|
if (Test-Path $ZipBuild -PathType Leaf) {
|
|
"Deleting old Zip build $ZipBuild..."
|
|
del $ZipBuild
|
|
}
|
|
"Compressing folder..."
|
|
Compress-Archive "$PSScriptRoot\..\bld\nwjs\$build-$version\*" "$PSScriptRoot\..\bld\nwjs\$foldername.zip" -Force
|
|
"Build $OBuild finished.`n"
|
|
}
|
|
|