Some checks failed
Build three ZaStoGram APKs / build (arm64-v8a, ZaStoGram-standalone-arm64-v8a, Arm64, arm64) (push) Has been cancelled
Build three ZaStoGram APKs / build (armeabi-v7a, ZaStoGram-standalone-armeabi-v7a, Armv7, armv7) (push) Has been cancelled
Build three ZaStoGram APKs / build (x86, ZaStoGram-standalone-x86, X86, x86) (push) Has been cancelled
ZaStoGram source guards / guards (push) Has been cancelled
Номер сборки передавался руками отдельным параметром, и это оказалось ловушкой: Android отвергает установку пакета с меньшим versionCode, сообщая лишь «Приложение не установлено». Так вышел неустанавливаемый релиз 1.1.13 — переданное значение не применилось, versionCode оказался ниже, чем у 1.1.12, и понять причину по сообщению было невозможно. Теперь для семантического тега вида X.Y.Z номер вычисляется из самого тега: X*1000 + Y*100 + Z, то есть 1.1.14 даёт 1114, а 1.2.0 — 1200. Номер релиза становится единственным источником правды, и «1.1.14 новее 1.1.13» верно по построению, а не по внимательности человека. Dev-сборки именуются иначе и продолжают использовать номер прогона CI; они ставятся под собственным идентификатором приложения и со стабильными не пересекаются. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
69 lines
3.7 KiB
Groovy
69 lines
3.7 KiB
Groovy
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
buildscript {
|
|
repositories {
|
|
mavenCentral()
|
|
google()
|
|
maven { url 'https://developer.huawei.com/repo/' }
|
|
}
|
|
dependencies {
|
|
classpath 'com.android.tools.build:gradle:8.6.1'
|
|
classpath 'com.google.gms:google-services:4.3.15'
|
|
classpath 'com.huawei.agconnect:agcp:1.9.1.301'
|
|
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.0'
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20"
|
|
// ZaStoGram plugin engine: Chaquopy embeds CPython 3.11 into the APK.
|
|
// 16.1.x supports AGP 7.0-8.13 (we use 8.6.1) and Python 3.8-3.13.
|
|
classpath 'com.chaquo.python:gradle:16.1.0'
|
|
}
|
|
}
|
|
repositories {
|
|
google()
|
|
}
|
|
|
|
// ZaStoGram release identity is a single build-wide input. The standalone
|
|
// application derives both its install identity and updater channel from these
|
|
// values, so a dev APK can never accidentally replace the stable application.
|
|
def zastoUpdateChannelValue = (findProperty("zastoUpdateChannel") ?: System.getenv("ZASTO_UPDATE_CHANNEL") ?: "stable").toString().trim().toLowerCase()
|
|
if (!(zastoUpdateChannelValue in ["dev", "stable"])) {
|
|
throw new GradleException("Unsupported ZaStoGram update channel '${zastoUpdateChannelValue}'. Expected dev or stable")
|
|
}
|
|
def zastoReleaseTagValue = (findProperty("zastoReleaseTag") ?: System.getenv("ZASTO_RELEASE_TAG") ?: "").toString().trim()
|
|
def zastoForgejoRepositoryValue = (findProperty("zastoForgejoRepository") ?: System.getenv("ZASTO_FORGEJO_REPOSITORY") ?: "zastogram/ZaStoGram").toString().trim()
|
|
if (!(zastoForgejoRepositoryValue ==~ /[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+/)) {
|
|
throw new GradleException("Invalid ZaStoGram Forgejo repository '${zastoForgejoRepositoryValue}'. Expected owner/repository")
|
|
}
|
|
def zastoBuildNumberValue = (findProperty("zastoBuildNumber") ?: System.getenv("ZASTO_BUILD_NUMBER") ?: "0").toString().trim()
|
|
if (!(zastoBuildNumberValue ==~ /\d+/) || zastoBuildNumberValue.toInteger() > 9999) {
|
|
throw new GradleException("Invalid ZaStoGram build number '${zastoBuildNumberValue}'. Expected an integer from 0 to 9999")
|
|
}
|
|
|
|
// The release tag is the single source of truth for a stable build. Android
|
|
// refuses to install a package whose versionCode is not above the installed
|
|
// one and reports only "App not installed", so a hand-passed build number is
|
|
// a silent trap: pass a smaller one by accident and the release is dead on
|
|
// arrival. A semantic tag therefore DERIVES the number instead, which makes
|
|
// "1.1.14 is newer than 1.1.13" true by construction.
|
|
//
|
|
// Layout: X*1000 + Y*100 + Z, so 1.1.14 -> 1114 and 1.2.0 -> 1200. Dev builds
|
|
// tag themselves differently (forgejo-build-N-M) and keep the CI run number;
|
|
// they install under their own application id and never meet a stable build.
|
|
def zastoSemanticTag = (zastoReleaseTagValue =~ /^(\d+)\.(\d+)\.(\d+)$/)
|
|
def zastoResolvedBuildNumber = zastoBuildNumberValue.toInteger()
|
|
if (zastoSemanticTag.matches()) {
|
|
def major = zastoSemanticTag[0][1].toInteger()
|
|
def minor = zastoSemanticTag[0][2].toInteger()
|
|
def patch = zastoSemanticTag[0][3].toInteger()
|
|
if (major > 9 || minor > 9 || patch > 99) {
|
|
throw new GradleException(
|
|
"Release tag '${zastoReleaseTagValue}' does not fit the versionCode layout. " +
|
|
"Expected major and minor below 10 and patch below 100.")
|
|
}
|
|
zastoResolvedBuildNumber = major * 1000 + minor * 100 + patch
|
|
}
|
|
|
|
ext.zastoReleaseIdentity = [
|
|
updateChannel: zastoUpdateChannelValue,
|
|
releaseTag: zastoReleaseTagValue,
|
|
forgejoRepository: zastoForgejoRepositoryValue,
|
|
buildNumber: zastoResolvedBuildNumber,
|
|
]
|