feat: alphabet list, change Layout etc

This commit is contained in:
2026-10-11 20:37:59 +02:00
parent 489896305d
commit 072f560989
31 changed files with 1847 additions and 832 deletions
+31 -15
View File
@@ -7,7 +7,8 @@ $ErrorActionPreference = 'Stop'
Set-Location $PSScriptRoot
$updateServer = 'https://updater.kooltap.com'
$apkPath = 'build\app\outputs\flutter-apk\app-release.apk'
$pubspecPath = Join-Path $PSScriptRoot 'pubspec.yaml'
$apkPath = Join-Path $PSScriptRoot 'build\app\outputs\flutter-apk\app-release.apk'
function Fail([string]$message) {
Write-Host $message -ForegroundColor Red
@@ -16,7 +17,7 @@ function Fail([string]$message) {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$pubspec = [IO.File]::ReadAllText('pubspec.yaml')
$pubspec = [IO.File]::ReadAllText($pubspecPath)
$match = [regex]::Match(
$pubspec,
'(?m)^version:[ \t]*([0-9]+\.[0-9]+\.[0-9]+)\+([0-9]+)'
@@ -29,22 +30,24 @@ $currentName = $match.Groups[1].Value
$currentBuild = [int]$match.Groups[2].Value
Write-Host "Current version: $currentName+$currentBuild"
# The server picks the latest release by build number, so every release needs
# a higher one than anything already published
# The server picks the latest release by Android version code, so every release
# needs a higher one than anything already published
$publishedName = $null
$publishedBuild = 0
$publishedCode = 0
try {
foreach ($release in Invoke-RestMethod "$updateServer/api/releases") {
if ($release.VersionCode -gt $publishedBuild) {
$releases = Invoke-RestMethod "$updateServer/api/releases" -UseBasicParsing -TimeoutSec 15
foreach ($release in $releases) {
if ($release.VersionCode -gt $publishedCode) {
$publishedName = $release.Version
$publishedBuild = [int]$release.VersionCode
$publishedCode = [int]$release.VersionCode
}
}
if ($publishedName) {
Write-Host "Latest published: $publishedName+$publishedBuild"
Write-Host "Latest published: $publishedName (version code $publishedCode)"
}
} catch {
Write-Host "Could not reach $updateServer, using pubspec.yaml only." -ForegroundColor Yellow
Write-Host "Could not reach ${updateServer}: $($_.Exception.Message)" -ForegroundColor Yellow
Write-Host 'Using pubspec.yaml only; the upload is refused if the version is too low.' -ForegroundColor Yellow
}
$name = Read-Host 'Release version (for example 1.2.2)'
@@ -55,14 +58,27 @@ if ($publishedName -and [version]$name -le [version]$publishedName) {
Fail "$name must be higher than the published $publishedName, or tablets will not see it."
}
$build = [Math]::Max($currentBuild, $publishedBuild) + 1
# The build number only counts builds of the same version and starts at 0 for
# a new one. Android refuses updates with a lower version code, so that code is
# derived from the whole version instead: 1.2.5+3 becomes 1020503
$build = if ($name -eq $currentName) { $currentBuild + 1 } else { 0 }
$major, $minor, $patch = $name.Split('.') | ForEach-Object { [int]$_ }
if ($minor -ge 100 -or $patch -ge 100 -or $build -ge 100) {
Fail 'Minor, patch and build numbers must stay below 100.'
}
$versionCode = $major * 1000000 + $minor * 10000 + $patch * 100 + $build
if ($versionCode -le $publishedCode) {
Fail "Version code $versionCode is not higher than the published $publishedCode."
}
$version = "$name+$build"
$versionStart = $match.Groups[1].Index
$versionEnd = $match.Groups[2].Index + $match.Groups[2].Length
$pubspec = $pubspec.Substring(0, $versionStart) + $version + $pubspec.Substring($versionEnd)
[IO.File]::WriteAllText((Resolve-Path 'pubspec.yaml'), $pubspec)
Write-Host "Updated pubspec.yaml to version $version."
[IO.File]::WriteAllText($pubspecPath, $pubspec)
Write-Host "Updated pubspec.yaml to version $version (version code $versionCode)."
if (-not $SkipTests) {
Write-Host 'Running tests...'
@@ -71,7 +87,7 @@ if (-not $SkipTests) {
}
Write-Host 'Building release APK...'
flutter build apk --release
flutter build apk --release --build-number=$versionCode
if ($LASTEXITCODE -ne 0) { Fail 'Release APK build failed.' }
Write-Host "Release APK created at $apkPath"
@@ -93,7 +109,7 @@ $client = [Net.Http.HttpClient]::new()
$client.Timeout = [TimeSpan]::FromMinutes(5)
$client.DefaultRequestHeaders.Add('X-Admin-Token', $token)
$apk = [IO.File]::OpenRead((Resolve-Path $apkPath))
$apk = [IO.File]::OpenRead($apkPath)
$form = [Net.Http.MultipartFormDataContent]::new()
$form.Add([Net.Http.StreamContent]::new($apk), 'apk', 'app-release.apk')
$form.Add([Net.Http.StringContent]::new($notes), 'notes')