Add Electron release to Create-DraftRelease

Former-commit-id: 9c42bcb8515a984d462f42cb01b00044b9fa8486 [formerly 13aa1b0786603c95dce0eada8b04ce0c823cc2e2] [formerly cb78197c38fba52307958c496b33ed8b5df419d3] [formerly 1e4166b00b318ae88fb6a73e7657f3f1764606ac [formerly f2107f468626f2696bd15f323923a185e1f013d9 [formerly 09ff7ca6e72692f68714e40dc44569bca8d05f92]]]
Former-commit-id: f2608c8bd19af007f1beb99988e7a3e86588ccb8 [formerly 3f13d752952f08ab9e9a7ef6312b045db4256360 [formerly dfba1786317d733fdf4ceda39ddad8d8d010e181]]
Former-commit-id: d7e65f23005bceac5a8972611572914e78f589cc [formerly 89e3d10b97221e5d753cc6c65a036ab9c242cd4f]
Former-commit-id: 7026581205ef63e6ced1f17a7f3e13c76d7cefb8
This commit is contained in:
Jaifroid 2021-01-17 10:14:40 +00:00
parent b6d3344dfc
commit 4f68fcdf21
2 changed files with 99 additions and 29 deletions

View File

@ -10,22 +10,43 @@ $github_token = Get-Content -Raw "$PSScriptRoot/github_token"
if ($tag_name -eq "") {
$tag_name = Read-Host "`nEnter the tag name to use for this release"
}
if ($tag_name -NotMatch '^v\d+\.\d+\.\d+') {
"`nTag name must be in the format " + '"v0.0.0[-text]"!' + "`n"
if ($tag_name -NotMatch '^v\d+\.\d+\.\d+([EN-]|$)') {
"`nTag name must be in the format " + '"v0.0.0[E][N][-text]"!' + "`n"
exit
}
"`nCreating release for $tag_name..."
$base_tag = $tag_name -replace '^v([\d.]+).*', '$1'
$text_tag = $tag_name -replace '^v[\d.]+-?(.*)$', '$1'
if ($text_tag -eq "") { $text_tag = "Windows" }
$base_tag = $tag_name -replace '^v([\d.EN]+).*', '$1'
$text_tag = $tag_name -replace '^v[\d.EN]+-?(.*)$', '$1'
if ($text_tag -eq '') { $text_tag = 'Windows' }
$branch = "master"
if ($text_tag -ne "Windows") { $branch = "Kiwix-JS-$text_tag" }
$release_title = "Kiwix JS $text_tag $base_tag UWP"
if ($text_tag -eq "Wikivoyage") { $release_title = "Wikivoyage by Kiwix $base_tage UWP" }
$text_tag
$release_title
$release_body = Get-Content -Raw ("$PSScriptRoot/Kiwix_JS_" + $text_tag + "_Release_Body.md")
$flavour = ''
$init_params = Get-Content -Raw "$PSScriptRoot\..\www\js\init.js"
$file_version = ''
if ($init_params -match 'params\[[''"]fileVersion[''"]]\s*=\s*[''"]([^''"]+)') {
$file_version = $matches[1]
}
$zim = ''
$date = ''
if ($file_version) {
$zim = ($file_version -replace '\s\([^(]+\)\s*$', '') + '.zim'
$date = $file_version -replace '^[^(]+\(([^(]+)\)\s*$', '$1'
}
"File Version: $file_version"
"Zim: $zim"
"Date: $date"
if ($base_tag -match 'E$') {
$release_title = $release_title -replace '([^\s]+)\sUWP$', 'Electron Edition for Win7/Win8/Win10 $1'
$flavour = '_E'
}
"Text tag: $text_tag"
"Release title: $release_title"
$release_body = Get-Content -Raw ("$PSScriptRoot/Kiwix_JS_" + $text_tag + $flavour + "_Release_Body.md")
$release_body = $release_body -replace '<<base_tag>>', "$base_tag"
$release_body = $release_body -replace '<<zim>>', "$zim"
$release_body = $release_body -replace '<<date>>', "$date"
# Set up release_params object - for API see https://docs.github.com/en/rest/reference/repos#releases
$release_params = @{
Uri = $release_uri
@ -45,32 +66,50 @@ $release_params = @{
}
# Post to the release server
if (-Not $dryrun) { $release = Invoke-RestMethod @release_params }
if (-Not $dryrun) {
$release = Invoke-RestMethod @release_params
} else {
"[DRYRUN] Release Body:`n$release_body"
}
# Check that we appear to have created a release
if ($dryrun -or $release.assets_url -imatch '^https:') {
"The draft release details were successfully created.`n"
"Searching for assets..."
$AppxBundle = dir "$PSScriptRoot/../AppPackages/*_$base_tag*_Test/*_$base_tag*.appx*"
# Check the file exists and it's of the right type
if ($AppxBundle -and ($AppxBundle.count -eq 1) -and (Test-Path $AppxBundle -PathType leaf) -and
($AppxBundle -imatch '(.*)\.(?:appx|appxbundle|appxupload)$')) {
"Setting main bundle file to $AppxBundle..."
} elseif ($AppxBundle.count -ge 2) {
"More than one file matches that tag!"
return
if ($flavour -eq '_E') {
# Package electron app
"Building Electron app"
if (-Not $dryrun) { npm run package-win }
"Compressing release package for Electron..."
$compressed_assets_dir = "$PSScriptRoot/../bld/electron/kiwix-js-windows-win32-ia32"
$base_dir = "$PSScriptRoot/../bld/electron/"
$compressed_archive = $base_dir + "Kiwix.JS.$text_tag.$base_tag.zip"
$AddAppPackage = $base_dir + "Start*.*"
"Compressing: $AddAppPackage, $compressed_assets_dir to $compressed_archive"
if (-Not $dryrun) { "$AddAppPackage", "$compressed_assets_dir" | Compress-Archive -DestinationPath $compressed_archive -Force }
$ReleaseBundle = ''
} else {
"No package matching that tag was found. Aborting."
return
$ReleaseBundle = dir "$PSScriptRoot/../AppPackages/*_$base_tag*_Test/*_$base_tag*.appx*"
# Check the file exists and it's of the right type
if ($ReleaseBundle -and ($ReleaseBundle.count -eq 1) -and (Test-Path $ReleaseBundle -PathType leaf) -and
($ReleaseBundle -imatch '(.*)\.(?:appx|ReleaseBundle|appxupload)$')) {
"Setting main bundle file to $ReleaseBundle..."
} elseif ($ReleaseBundle.count -ge 2) {
"More than one file matches that tag!"
return
} else {
"No package matching that tag was found. Aborting."
return
}
# ZIP the remaining assets
"Compressing remaining assets..."
$compressed_assets_dir = $ReleaseBundle -replace '[^/\\]+$', ''
$compressed_archive = $compressed_assets_dir + "PowerShell.Installation.Script.KiwixWebAppWikiMed_$base_tag.0_Test.zip"
$AddAppPackage = $compressed_assets_dir + "Add-AppDevPackage*.*"
$cert_file = $ReleaseBundle -replace '\.[^.]+$', '.cer'
"Compressing: $AddAppPackage, $cert_file"
if (-Not $dryrun) { "$AddAppPackage", "$cert_file" | Compress-Archive -DestinationPath $compressed_archive -Force }
}
# ZIP the remaining assets
"Compressing remaining assets..."
$compressed_assets_dir = $AppxBundle -replace '[^/\\]+$', ''
$compressed_archive = $compressed_assets_dir + "PowerShell.Installation.Script.KiwixWebAppWikiMed_$base_tag.0_Test.zip"
$AddAppPackage = $compressed_assets_dir + "Add-AppDevPackage*.*"
$cert_file = $AppxBundle -replace '\.[^.]+$', '.cer'
"Compressing: $AddAppPackage, $cert_file"
if (-Not $dryrun) { "$AddAppPackage", "$cert_file" | Compress-Archive -DestinationPath $compressed_archive -Force }
# Check the compressed file exists
if ($dryrun -or (Test-Path $compressed_archive -PathType leaf)) {
"Compression successful`n"
@ -78,12 +117,13 @@ if ($dryrun -or $release.assets_url -imatch '^https:') {
"There was an error compressing assets."
return
}
$upload_assets = @($compressed_archive, $AppxBundle)
# Upload the release
$upload_assets = @($compressed_archive, $ReleaseBundle)
$upload_uri = $release.upload_url -ireplace '\{[^{}]+}', ''
"Uploading assets to: $upload_uri..."
ForEach($asset in $upload_assets) {
if (-Not $asset) { Continue }
$asset_name = $asset -replace '^.*[\\/]([^\\/]+)$', '$1'
# Establish upload params
$upload_params = @{

View File

@ -0,0 +1,30 @@
## This is a portable build of Kiwix JS WikiMed Electron Edition for any 32bit or 64bit Windows 7/8/10
**Includes updated articles on COVID-19 current as of <<date>> (see screenshot)**
This is **not** the UWP/Microsoft Store build. If you are using Windows 10, you may prefer to use [the WikiMed release for the Microsoft Store](https://kiwix.github.io/kiwix-js-windows/wikimed-uwp.html), which will keep itself up-to-date automatically. This portable version runs on the included [Electron platform](https://www.electronjs.org/) version 10.3.0. This build will run on 32bit and 64bit editions of Windows. It is not compatible with Windows XP or Windows Vista. If you need an app compatible with those old platforms, get [Kiwix JS Windows reader](https://kiwix.github.io/kiwix-js-windows/kiwix-js-nwjs.html) and download the latest WikiMed archive from within the app.
There is no installation required: the app is fully portable. **Warning: the download is 1.2GB (it includes the full WikiMed archive).** See instructions for unzipping and launching below the screenshot.
![image](https://user-images.githubusercontent.com/4304337/98874889-03e35080-2473-11eb-9a0c-60a5ab3a2645.png)
If you intend to use this app with other archives than WikiMed, then download the generic [Kiwix JS Windows reader](https://kiwix.github.io/kiwix-js-windows/kiwix-js-nwjs.html), which is a much smaller download, or install the small functional [Store version of the reader](https://kiwix.github.io/kiwix-js-windows/kiwix-js-uwp.html) which keeps itself up-to-date.
### Instructions:
* Download [Kiwix JS WikiMed <<base_tag>>.zip](https://github.com/kiwix/kiwix-js-windows/releases/download/v<<base_tag>>-WikiMed/Kiwix.JS.WikiMed.<<base_tag>>.zip), or open Assets below and download the zipped file (not the source code). Unzip the contents of the archive to any folder, or to a flash drive / thumb drive;
* Double click on `Start Kiwix JS WikiMed`, or that doesn't work, use the provided batch file `Start Kiwix JS WikiMed via batch file.bat`, or open the `kiwix-js-windows-win32-ia32` folder and double click on `kiwix-js-windows.exe`;
* **Because the archive may not be commonly downloaded, you may face Windows SmartScreen issues** on first launch. Follow instructions to "Run anyway" if you trust this site. The app was made using Electron Packager version 15.2.0, and the `electron.exe` binary (renamed `kiwix-js-window.exe` with the Kiwix icon). You will not be asked again on subsequent launches.
### Release Notes
* This app is packaged with the <<date>> English-language WikiMed archive `<<zim>>`. The packaged archive is located in the `archives` folder. See the readme in that folder if you wish to add a different archive as the packaged ZIM;
* You can download WikiMed in other languages from the Configuration page;
* It supports dark mode, and opening a page in a separate browser window (see Configuration);
* You can print by pressing Ctrl-P or using the print icon. If local printers are not available (after clicking on More options...) then print to PDF and use another app to print.
### Known Issues
* REGRESSION: Due to a change in format, headings are always open in jQuery mode regardless of the "Open all sections" option in Configuration (the setting is respected in Service Worker mode)
* INCONSISTENCY: When printing in jQuery mode, all sections are opened before printing (if the user had closed any), whereas in SW mode, closed sections are not opened before printing
* Please see https://github.com/kiwix/kiwix-js-windows/issues for further known issues. If you find a new issue, please open a new issue on that page.