Auto-commit after successful build: improve build setup, update docs/config
Changed files:\nREADME.md SetupBuildEnvironment.sh app/build.gradle.kts
This commit is contained in:
@@ -195,6 +195,41 @@ sdk.dir=$SDK_DIR
|
||||
EOF_INNER
|
||||
}
|
||||
|
||||
bump_android_version() {
|
||||
local gradle_file="$PROJECT_DIR/app/build.gradle.kts"
|
||||
if [ ! -f "$gradle_file" ]; then
|
||||
log "No app/build.gradle.kts found; skipping version bump"
|
||||
return
|
||||
fi
|
||||
|
||||
log "Bumping Android app version before build"
|
||||
python - <<PY
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
path = Path(r'''$gradle_file''')
|
||||
text = path.read_text()
|
||||
|
||||
version_code_match = re.search(r'versionCode\s*=\s*(\d+)', text)
|
||||
version_name_match = re.search(r'versionName\s*=\s*"(\d+)\.(\d+)\.(\d+)"', text)
|
||||
|
||||
if not version_code_match or not version_name_match:
|
||||
raise SystemExit('Could not find versionCode/versionName in app/build.gradle.kts')
|
||||
|
||||
current_code = int(version_code_match.group(1))
|
||||
major, minor, patch = map(int, version_name_match.groups())
|
||||
|
||||
new_code = current_code + 1
|
||||
new_name = f'{major}.{minor}.{patch + 1}'
|
||||
|
||||
text = re.sub(r'versionCode\s*=\s*\d+', f'versionCode = {new_code}', text, count=1)
|
||||
text = re.sub(r'versionName\s*=\s*"\d+\.\d+\.\d+"', f'versionName = "{new_name}"', text, count=1)
|
||||
|
||||
path.write_text(text)
|
||||
print(f'Updated versionCode to {new_code} and versionName to {new_name}')
|
||||
PY
|
||||
}
|
||||
|
||||
setup_env() {
|
||||
setup_java_env
|
||||
export ANDROID_HOME="$SDK_DIR"
|
||||
@@ -239,6 +274,7 @@ maybe_build() {
|
||||
fi
|
||||
|
||||
setup_env
|
||||
bump_android_version
|
||||
log "Building debug APK with --no-daemon"
|
||||
"$PROJECT_DIR/gradlew" --no-daemon assembleDebug
|
||||
auto_commit_if_needed
|
||||
|
||||
Reference in New Issue
Block a user