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:
Joe Tretter
2026-04-22 09:03:47 -05:00
parent abf042ae65
commit b80a8aca25
3 changed files with 43 additions and 2 deletions

View File

@@ -70,6 +70,11 @@ bash ./SetupBuildEnvironment.sh --build
the script will also attempt to create a **git commit after a successful build** if there are source changes to commit.
It will also automatically bump the Android app version in `app/build.gradle.kts` before each build by:
- incrementing `versionCode` by 1
- incrementing the patch component of `versionName` (for example `0.1.0``0.1.1`)
## Next steps toward full GitHug parity
- Expand the Git sandbox to cover merge, rebase, stash, tags, remotes, reset, revert, cherry-pick, bisect, and more

View File

@@ -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

View File

@@ -11,8 +11,8 @@ android {
applicationId = "com.kawomi.githugandroid"
minSdk = 26
targetSdk = 34
versionCode = 1
versionName = "0.1.0"
versionCode = 2
versionName = "0.1.1"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true