mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-08 14:49:34 -04:00
Add script to bump the app version
This commit is contained in:
parent
47867375d2
commit
b7179ac808
58
scripts/Set-AppVersion.ps1
Normal file
58
scripts/Set-AppVersion.ps1
Normal file
@ -0,0 +1,58 @@
|
||||
# Updates the app version in all required places according to the custom value
|
||||
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[string]$customversion = ''
|
||||
)
|
||||
|
||||
if ($customversion) {
|
||||
"`nUser set custom input version: $customversion"
|
||||
$INPUT_VERSION = $customversion
|
||||
} else {
|
||||
$init_params = Get-Content -Raw "$PSScriptRoot\..\www\js\app.js"
|
||||
$file_tag = ''
|
||||
if ($init_params -match 'params\[[''"]appVersion[''"]]\s*=\s*[''"]([^''"]+)') {
|
||||
$file_tag = 'v' + $matches[1]
|
||||
}
|
||||
if ($file_tag) {
|
||||
"`nCurrent app version is: $file_tag"
|
||||
if ($file_tag -match '(^.*\.)([0-9]+)(.*$)') {
|
||||
if ($matches[2]) {
|
||||
$file_tag = $matches[1] + ($matches[2] / 1 + 1) + $matches[3]
|
||||
}
|
||||
}
|
||||
}
|
||||
$tag_name = Read-Host "`nEnter the tag name for this release, Enter to accept suggested tag [$file_tag]"
|
||||
if ($tag_name -eq "") { $tag_name = $file_tag }
|
||||
if ($tag_name -NotMatch '^v?\d+\.\d+\.\d+([+EN-]|$)') {
|
||||
"`nTag name must be in the format " + '"[v]0.0.0"!' + "`n"
|
||||
exit
|
||||
}
|
||||
$INPUT_VERSION = $tag_name
|
||||
}
|
||||
|
||||
if ($INPUT_VERSION) {
|
||||
$VERSION = $INPUT_VERSION
|
||||
} elseif ($TAG_VERSION) {
|
||||
$VERSION = $TAG_VERSION
|
||||
}
|
||||
|
||||
if ($VERSION -match '^v?[\d.]') {
|
||||
$VERSION = $VERSION -replace '^v', ''
|
||||
"`nSetting App Version to $VERSION in service-worker.js and app.js ..."
|
||||
(Get-Content ./service-worker.js) -replace '(appVersion\s*=\s*["''])[^"'']+', "`${1}$VERSION" | Set-Content ./service-worker.js
|
||||
(Get-Content ./www/js/app.js) -replace '(appVersion..\s*=\s*["''])[^"'']+', "`${1}$VERSION" | Set-Content ./www/js/app.js
|
||||
$FileList = './manifest.json', './manifest.webapp', './ubuntu_touch/manifest.json'
|
||||
ForEach ($File in $FileList) {
|
||||
$FileContent = Get-Content -Raw $File
|
||||
"Setting App Version to $VERSION in $File ..."
|
||||
$FileContent = $FileContent -replace '("version"\s*:\s*")[^"]*', "`${1}$VERSION"
|
||||
# Remove extra whitespace
|
||||
$FileContent = $FileContent -replace '\s+$', ''
|
||||
# DEV: don't set BOM, as Linux tools crash with it
|
||||
Set-Content $File $FileContent
|
||||
}
|
||||
"`nDone. Please check the updated files.`n"
|
||||
} else {
|
||||
"No valid INPUT_VERSION or TAG_VERSION were provided. File version numbers were unchanged.`n"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user