mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
Generate Android versionCode from Major.Minor.Patch (#14963)
This commit is contained in:
parent
baafec9e9f
commit
60694cbd30
@ -8,7 +8,7 @@ android {
|
|||||||
compileSdk 34
|
compileSdk 34
|
||||||
targetSdkVersion 34
|
targetSdkVersion 34
|
||||||
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
|
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
|
||||||
versionCode project.versionCode
|
versionCode versionMajor * 1000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
|
||||||
}
|
}
|
||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
@ -116,18 +116,6 @@ clean {
|
|||||||
delete new File("src/main/assets", "Minetest.zip")
|
delete new File("src/main/assets", "Minetest.zip")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map for the version code that gives each ABI a value.
|
|
||||||
import com.android.build.OutputFile
|
|
||||||
|
|
||||||
def abiCodes = ['armeabi-v7a': 0, 'arm64-v8a': 1]
|
|
||||||
android.applicationVariants.all { variant ->
|
|
||||||
variant.outputs.each {
|
|
||||||
output ->
|
|
||||||
def abiName = output.getFilter(OutputFile.ABI)
|
|
||||||
output.versionCodeOverride = abiCodes.get(abiName, 0) + variant.versionCode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(':native')
|
implementation project(':native')
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||||
|
@ -4,10 +4,9 @@ project.ext.set("versionMajor", 5) // Version Major
|
|||||||
project.ext.set("versionMinor", 9) // Version Minor
|
project.ext.set("versionMinor", 9) // Version Minor
|
||||||
project.ext.set("versionPatch", 0) // Version Patch
|
project.ext.set("versionPatch", 0) // Version Patch
|
||||||
// ^ keep in sync with cmake
|
// ^ keep in sync with cmake
|
||||||
project.ext.set("versionCode", 48) // Android Version Code
|
|
||||||
// NOTE: +2 after each release!
|
project.ext.set("versionBuild", 0) // Version Build
|
||||||
// +1 for ARM and +1 for ARM64 APK's, because
|
// ^ fourth version number to allow releasing Android-only fixes and beta versions
|
||||||
// each APK must have a larger `versionCode` than the previous
|
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.ndk_version = '26.2.11394342'
|
ext.ndk_version = '26.2.11394342'
|
||||||
|
@ -16,20 +16,18 @@ prompt_for() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Reads current versions
|
# Reads current versions
|
||||||
# out: VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_IS_DEV CURRENT_VERSION ANDROID_VERSION_CODE
|
# out: VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_IS_DEV CURRENT_VERSION
|
||||||
read_versions() {
|
read_versions() {
|
||||||
VERSION_MAJOR=$(grep -oE '^set\(VERSION_MAJOR [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
|
VERSION_MAJOR=$(grep -oE '^set\(VERSION_MAJOR [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
|
||||||
VERSION_MINOR=$(grep -oE '^set\(VERSION_MINOR [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
|
VERSION_MINOR=$(grep -oE '^set\(VERSION_MINOR [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
|
||||||
VERSION_PATCH=$(grep -oE '^set\(VERSION_PATCH [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
|
VERSION_PATCH=$(grep -oE '^set\(VERSION_PATCH [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
|
||||||
VERSION_IS_DEV=$(grep -oE '^set\(DEVELOPMENT_BUILD [A-Z]+\)$' CMakeLists.txt)
|
VERSION_IS_DEV=$(grep -oE '^set\(DEVELOPMENT_BUILD [A-Z]+\)$' CMakeLists.txt)
|
||||||
ANDROID_VERSION_CODE=$(grep -oE '\("versionCode", [0-9]+\)' android/build.gradle | tr -dC 0-9)
|
|
||||||
|
|
||||||
# Make sure they all exist
|
# Make sure they all exist
|
||||||
[ -n "$VERSION_MAJOR" ]
|
[ -n "$VERSION_MAJOR" ]
|
||||||
[ -n "$VERSION_MINOR" ]
|
[ -n "$VERSION_MINOR" ]
|
||||||
[ -n "$VERSION_PATCH" ]
|
[ -n "$VERSION_PATCH" ]
|
||||||
[ -n "$VERSION_IS_DEV" ]
|
[ -n "$VERSION_IS_DEV" ]
|
||||||
[ -n "$ANDROID_VERSION_CODE" ]
|
|
||||||
|
|
||||||
if echo "$VERSION_IS_DEV" | grep -q ' TRUE'; then
|
if echo "$VERSION_IS_DEV" | grep -q ' TRUE'; then
|
||||||
VERSION_IS_DEV=1
|
VERSION_IS_DEV=1
|
||||||
@ -39,7 +37,6 @@ read_versions() {
|
|||||||
CURRENT_VERSION="$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH"
|
CURRENT_VERSION="$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH"
|
||||||
|
|
||||||
echo "Current Minetest version: $CURRENT_VERSION"
|
echo "Current Minetest version: $CURRENT_VERSION"
|
||||||
echo "Current Android version code: $ANDROID_VERSION_CODE"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Retrieves protocol version from header
|
# Retrieves protocol version from header
|
||||||
@ -49,18 +46,6 @@ read_proto_ver() {
|
|||||||
git show "$ref":src/network/networkprotocol.h | grep -oE 'LATEST_PROTOCOL_VERSION [0-9]+' | tr -dC 0-9
|
git show "$ref":src/network/networkprotocol.h | grep -oE 'LATEST_PROTOCOL_VERSION [0-9]+' | tr -dC 0-9
|
||||||
}
|
}
|
||||||
|
|
||||||
## Prompts for new android version code
|
|
||||||
# in: ANDROID_VERSION_CODE
|
|
||||||
# out: NEW_ANDROID_VERSION_CODE
|
|
||||||
bump_android_ver() {
|
|
||||||
# +1 for ARM and +1 for ARM64 APKs
|
|
||||||
NEW_ANDROID_VERSION_CODE=$(expr $ANDROID_VERSION_CODE + 2)
|
|
||||||
NEW_ANDROID_VERSION_CODE=$(prompt_for "Set android version code" '[0-9]+' $NEW_ANDROID_VERSION_CODE)
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "New android version code: $NEW_ANDROID_VERSION_CODE"
|
|
||||||
}
|
|
||||||
|
|
||||||
## Prompts for new version
|
## Prompts for new version
|
||||||
# in: VERSION_{MAJOR,MINOR,PATCH} DO_PATCH_REL
|
# in: VERSION_{MAJOR,MINOR,PATCH} DO_PATCH_REL
|
||||||
# out: NEXT_VERSION NEXT_VERSION_{MAJOR,MINOR,PATCH}
|
# out: NEXT_VERSION NEXT_VERSION_{MAJOR,MINOR,PATCH}
|
||||||
@ -108,14 +93,6 @@ set_dev_build() {
|
|||||||
git add -f CMakeLists.txt android/build.gradle
|
git add -f CMakeLists.txt android/build.gradle
|
||||||
}
|
}
|
||||||
|
|
||||||
## Writes new android version code
|
|
||||||
# in: NEW_ANDROID_VERSION_CODE
|
|
||||||
write_android_version() {
|
|
||||||
sed -i -re "s/\"versionCode\", [0-9]+/\"versionCode\", $NEW_ANDROID_VERSION_CODE/" android/build.gradle
|
|
||||||
|
|
||||||
git add -f android/build.gradle
|
|
||||||
}
|
|
||||||
|
|
||||||
## Writes new version to the right files
|
## Writes new version to the right files
|
||||||
# in: NEXT_VERSION NEXT_VERSION_{MAJOR,MINOR,PATCH}
|
# in: NEXT_VERSION NEXT_VERSION_{MAJOR,MINOR,PATCH}
|
||||||
write_new_version() {
|
write_new_version() {
|
||||||
@ -198,8 +175,6 @@ if [ "$DO_PATCH_REL" -eq 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bump_android_ver
|
|
||||||
write_android_version
|
|
||||||
set_dev_build 0
|
set_dev_build 0
|
||||||
|
|
||||||
perform_release "$CURRENT_VERSION"
|
perform_release "$CURRENT_VERSION"
|
||||||
@ -212,8 +187,6 @@ if [ "$DO_PATCH_REL" -eq 0 ]; then
|
|||||||
else
|
else
|
||||||
# On a patch release the version moves from 5.7.0 -> 5.7.1 (new tag)
|
# On a patch release the version moves from 5.7.0 -> 5.7.1 (new tag)
|
||||||
|
|
||||||
bump_android_ver
|
|
||||||
write_android_version
|
|
||||||
bump_version
|
bump_version
|
||||||
write_new_version
|
write_new_version
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user