Universalize Create-DraftRelease script

Former-commit-id: a993b9b1ea004ee4ddc88d7795f19d255c2ea1ff [formerly 49cc5ca1317e869ea145ee8bcc9040ac97861f21] [formerly c155ce2732f0cba1407a7a62d67b970e7723e26d] [formerly ceaad293fc825b8c8caf1490e26ea2b9cf77bf5f [formerly bf9548120351bfba35ce405a49322c708ecb8aca [formerly c1e4e44aa4514a774cd0d4bf88d845199d75d1d8]]]
Former-commit-id: 7c1ea84beb469c0b811d0dd21915c757d4636d84 [formerly f3361ca00651c7e90d09da72e2671862e986c841 [formerly b645d90ef8e11901680746a541d77c96a76a4f12]]
Former-commit-id: 9f2a2be8c6d39ae6ff2f96efb7aacdad86050d96 [formerly 0c4a2bda1cacf25eda0b5abb901ba37cb39c763d]
Former-commit-id: 3e2876f436deaa546204eb71d052b257b6c4fa24
This commit is contained in:
Jaifroid 2021-01-16 08:27:37 +00:00
parent 6a7aaf6ad0
commit e20a4055d6
2 changed files with 58 additions and 15 deletions

View File

@ -1,5 +1,6 @@
param (
[string]$tag_name = ""
[string]$tag_name = "",
[switch]$dryrun = $false
)
# Provide parameters
@ -14,9 +15,16 @@ if ($tag_name -NotMatch '^v\d+\.\d+\.\d+') {
exit
}
"`nCreating release for $tag_name..."
$base_tag = $tag_name -replace '^v([\d.]+)', '$1'
$release_title = "Kiwix JS Windows $base_tag UWP"
$release_body = Get-Content -Raw "$PSScriptRoot/Kiwix_JS_Windows_Release_Body.md"
$base_tag = $tag_name -replace '^v([\d.]+).*', '$1'
$text_tag = $tag_name -replace '^v[\d.]+-?(.*)$', '$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")
$release_body = $release_body -replace '<<base_tag>>', "$base_tag"
# Set up release_params object
$release_params = @{
@ -28,6 +36,7 @@ $release_params = @{
}
Body = @{
'tag_name' = $tag_name
'target_commitish' = $branch
'name' = $release_title
'draft' = $true
'body' = $release_body
@ -36,10 +45,10 @@ $release_params = @{
}
# Post to the release server
$release = Invoke-RestMethod @release_params
if (-Not $dryrun) { $release = Invoke-RestMethod @release_params }
# Check that we appear to have created a release
if ($release.assets_url -imatch '^https:') {
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*"
@ -57,13 +66,13 @@ if ($release.assets_url -imatch '^https:') {
# ZIP the remaining assets
"Compressing remaining assets..."
$compressed_assets_dir = $AppxBundle -replace '[^/\\]+$', ''
$compressed_archive = $compressed_assets_dir + "PowerShell.Installation.Script.KiwixWebApp_$base_tag.0_Test.zip"
$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"
"$AddAppPackage", "$cert_file" | Compress-Archive -DestinationPath $compressed_archive -Force
if (-Not $dryrun) { "$AddAppPackage", "$cert_file" | Compress-Archive -DestinationPath $compressed_archive -Force }
# Check the compressed file exists
if (Test-Path $compressed_archive -PathType leaf) {
if ($dryrun -or (Test-Path $compressed_archive -PathType leaf)) {
"Compression successful`n"
} else {
"There was an error compressing assets."
@ -91,11 +100,15 @@ if ($release.assets_url -imatch '^https:') {
"`nUpploading $asset..."
# Upload asset to the release server
# $upload = [System.IO.File]::ReadAllBytes($upload_file) | Invoke-RestMethod @upload_params
$upload = Invoke-RestMethod @upload_params
if ($upload.name -eq $asset_name) {
"Upload successfully posted as " + $upload.url
"Full details:"
echo $upload
if (-Not $dryrun) { $upload = Invoke-RestMethod @upload_params }
if ($dryrun -or $upload.name -eq $asset_name) {
if (-Not $dryrun) {
"Upload successfully posted as " + $upload.url
"Full details:"
echo $upload
} else {
echo "DRYRUN with these upload parameters:`n" + @upload_params
}
} else {
"The upload appears to have failed!"
if ($upload) {
@ -108,7 +121,7 @@ if ($release.assets_url -imatch '^https:') {
}
}
"Cleaning up..."
del $compressed_archive
if (-Not $dryrun) { del $compressed_archive }
"`nDone."
} else {
"There was an error setting up the release!"

View File

@ -0,0 +1,30 @@
## This is the WikiMed UWP release (for Store or manual installation)
It contains the <<date>> release of the WikiMed ZIM together with the changes detailed in the [CHANGELOG](https://github.com/kiwix/kiwix-js-windows/blob/Kiwix-JS-WikiMed/CHANGELOG.md).
**Status of store app: PUBLISHED**
https://www.microsoft.com/store/apps/9PHJSNP1CZ8J
If you prefer not to use the Microsoft Store or wish to test a different build, please follow the
instructions below the screenshot.
![image](https://user-images.githubusercontent.com/4304337/102692331-8c8ba400-420a-11eb-9f70-37e6880b9ccf.png)
## Manual Installation: Windows 10 Tablet / PC
**Uninstall any previous installation of Kiwix JS WikiMed before you follow this procedure**.
Download the signed bundle [KiwixWebAppWikiMed_<<base_tag>>.0_AnyCPU.appxbundle](https://github.com/kiwix/kiwix-js-windows/releases/download/v<<base_tag>>-WikiMed/KiwixWebAppWikiMed_<<base_tag>>.0_AnyCPU.appxbundle) and run/launch it (depending on the browser, you may need to single-click or double-click the file or "download complete" notification). The App Installer should open and ask you whether you wish to install (it may also ask you if you wish to allow sideloading apps: if so, answer yes). If you are satisfied that the app is trusted, click Install.
On slightly older versions of Windows 10, you may need to enable sideloading of apps beforehand: go to Settings / Update and security / For developers and select "Sideload apps". You may be asked to reboot.
If the above procedures fail, or the App Installer is not available, then download and unzip into a folder the `Powershell_Installation_Script...` from Assets, place the `.appxbundle` in the same folder, and follow Powershell Installation instructions [here](https://github.com/kiwix/kiwix-js-windows/tree/master/AppPackages#windows-10-tablet--pc) (except that you don't need to download further files, all the needed ones are included in the zip file `PowerShell_Installation_Script...`).
## Manual Installation: Windows 10 Mobile
**Uninstall any previous installation of Kiwix JS WikiMed before you follow this procedure**.
Download [KiwixWebAppWikiMed_<<base_tag>>.0_AnyCPU.appxbundle](https://github.com/kiwix/kiwix-js-windows/releases/download/v<<base_tag>>-WikiMed/KiwixWebAppWikiMed_<<base_tag>>.0_AnyCPU.appxbundle) to your downloads folder, or other accessible folder, on the device. Enable Developer mode on your device (Settings / Updates and security / For developers).
Open the File Explorer on the phone, navigate to the downloads folder and tap the KiwixWebAppWikiMed bundle. You will be asked if you wish to install, but it then installs silently in the background. Be patient: it can take a minute or so for the WikiMed icon to appear in the All Apps list.