Add version management with auto-bump script
Version is tracked in version.properties and read by build.gradle.kts. Run ./bump-version.sh [major|minor|patch] before release builds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
7979ebd029
commit
52af9f6047
3 changed files with 67 additions and 2 deletions
|
|
@ -14,6 +14,15 @@ val keystoreProperties = Properties().apply {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load version from version.properties
|
||||||
|
val versionProperties = Properties().apply {
|
||||||
|
load(rootProject.file("version.properties").inputStream())
|
||||||
|
}
|
||||||
|
val vMajor = versionProperties["versionMajor"].toString().toInt()
|
||||||
|
val vMinor = versionProperties["versionMinor"].toString().toInt()
|
||||||
|
val vPatch = versionProperties["versionPatch"].toString().toInt()
|
||||||
|
val vCode = versionProperties["versionCode"].toString().toInt()
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "no.naiv.tiltshift"
|
namespace = "no.naiv.tiltshift"
|
||||||
compileSdk = 35
|
compileSdk = 35
|
||||||
|
|
@ -34,8 +43,8 @@ android {
|
||||||
applicationId = "no.naiv.tiltshift"
|
applicationId = "no.naiv.tiltshift"
|
||||||
minSdk = 35
|
minSdk = 35
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 1
|
versionCode = vCode
|
||||||
versionName = "1.0.0"
|
versionName = "$vMajor.$vMinor.$vPatch"
|
||||||
|
|
||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
useSupportLibrary = true
|
useSupportLibrary = true
|
||||||
|
|
|
||||||
52
bump-version.sh
Executable file
52
bump-version.sh
Executable file
|
|
@ -0,0 +1,52 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Bumps the version in version.properties before a release build.
|
||||||
|
# Usage: ./bump-version.sh [major|minor|patch]
|
||||||
|
# Default: patch
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
PROPS_FILE="$(dirname "$0")/version.properties"
|
||||||
|
|
||||||
|
if [[ ! -f "$PROPS_FILE" ]]; then
|
||||||
|
echo "Error: $PROPS_FILE not found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Read current values
|
||||||
|
major=$(grep '^versionMajor=' "$PROPS_FILE" | cut -d= -f2)
|
||||||
|
minor=$(grep '^versionMinor=' "$PROPS_FILE" | cut -d= -f2)
|
||||||
|
patch=$(grep '^versionPatch=' "$PROPS_FILE" | cut -d= -f2)
|
||||||
|
code=$(grep '^versionCode=' "$PROPS_FILE" | cut -d= -f2)
|
||||||
|
|
||||||
|
bump_type="${1:-patch}"
|
||||||
|
|
||||||
|
case "$bump_type" in
|
||||||
|
major)
|
||||||
|
major=$((major + 1))
|
||||||
|
minor=0
|
||||||
|
patch=0
|
||||||
|
;;
|
||||||
|
minor)
|
||||||
|
minor=$((minor + 1))
|
||||||
|
patch=0
|
||||||
|
;;
|
||||||
|
patch)
|
||||||
|
patch=$((patch + 1))
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 [major|minor|patch]" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
code=$((code + 1))
|
||||||
|
|
||||||
|
# Write updated values
|
||||||
|
cat > "$PROPS_FILE" << EOF
|
||||||
|
versionMajor=$major
|
||||||
|
versionMinor=$minor
|
||||||
|
versionPatch=$patch
|
||||||
|
versionCode=$code
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "$major.$minor.$patch (versionCode=$code)"
|
||||||
4
version.properties
Normal file
4
version.properties
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
versionMajor=1
|
||||||
|
versionMinor=1
|
||||||
|
versionPatch=0
|
||||||
|
versionCode=2
|
||||||
Loading…
Add table
Add a link
Reference in a new issue