2017-08-20 17:20:11 +02:00
|
|
|
#!/bin/bash -e
|
2014-12-25 06:11:53 +01:00
|
|
|
|
|
|
|
prompt_for_number() {
|
|
|
|
local prompt_text=$1
|
|
|
|
local default_value=$2
|
|
|
|
local tmp=""
|
|
|
|
while true; do
|
|
|
|
read -p "$prompt_text [$default_value]: " tmp
|
|
|
|
if [ "$tmp" = "" ]; then
|
|
|
|
echo "$default_value"; return
|
|
|
|
elif echo "$tmp" | grep -q -E '^[0-9]+$'; then
|
|
|
|
echo "$tmp"; return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
# On a release the following actions are performed
|
|
|
|
# * DEVELOPMENT_BUILD is set to false
|
|
|
|
# * android versionCode is bumped
|
2018-10-16 21:04:06 +02:00
|
|
|
# * appdata release version and date are updated
|
2017-08-20 17:20:11 +02:00
|
|
|
# * Commit the changes
|
|
|
|
# * Tag with current version
|
|
|
|
perform_release() {
|
2021-01-20 21:37:24 +01:00
|
|
|
RELEASE_DATE=$(date +%Y-%m-%d)
|
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
sed -i -re "s/^set\(DEVELOPMENT_BUILD TRUE\)$/set(DEVELOPMENT_BUILD FALSE)/" CMakeLists.txt
|
|
|
|
|
2021-01-20 21:37:24 +01:00
|
|
|
sed -i 's/project.ext.set("versionExtra", "-dev")/project.ext.set("versionExtra", "")/' build/android/build.gradle
|
2020-07-08 23:09:39 +02:00
|
|
|
sed -i -re "s/\"versionCode\", [0-9]+/\"versionCode\", $NEW_ANDROID_VERSION_CODE/" build/android/build.gradle
|
2017-08-20 17:20:11 +02:00
|
|
|
|
2018-10-16 21:04:06 +02:00
|
|
|
sed -i '/\<release/s/\(version\)="[^"]*"/\1="'"$RELEASE_VERSION"'"/' misc/net.minetest.minetest.appdata.xml
|
|
|
|
sed -i 's/\(<release date\)="[^"]*"/\1="'"$RELEASE_DATE"'"/' misc/net.minetest.minetest.appdata.xml
|
|
|
|
|
|
|
|
git add -f CMakeLists.txt build/android/build.gradle misc/net.minetest.minetest.appdata.xml
|
2017-08-20 17:20:11 +02:00
|
|
|
|
|
|
|
git commit -m "Bump version to $RELEASE_VERSION"
|
|
|
|
|
|
|
|
echo "Tagging $RELEASE_VERSION"
|
|
|
|
|
|
|
|
git tag -a "$RELEASE_VERSION" -m "$RELEASE_VERSION"
|
|
|
|
}
|
|
|
|
|
|
|
|
# After release
|
|
|
|
# * Set DEVELOPMENT_BUILD to true
|
|
|
|
# * Bump version in CMakeLists and docs
|
|
|
|
# * Commit the changes
|
|
|
|
back_to_devel() {
|
|
|
|
echo 'Creating "return back to development" commit'
|
|
|
|
|
2021-01-20 21:37:24 +01:00
|
|
|
# Update CMakeList.txt versions
|
2017-08-20 17:20:11 +02:00
|
|
|
sed -i -re 's/^set\(DEVELOPMENT_BUILD FALSE\)$/set(DEVELOPMENT_BUILD TRUE)/' CMakeLists.txt
|
|
|
|
sed -i -re "s/^set\(VERSION_MAJOR [0-9]+\)$/set(VERSION_MAJOR $NEXT_VERSION_MAJOR)/" CMakeLists.txt
|
|
|
|
sed -i -re "s/^set\(VERSION_MINOR [0-9]+\)$/set(VERSION_MINOR $NEXT_VERSION_MINOR)/" CMakeLists.txt
|
|
|
|
sed -i -re "s/^set\(VERSION_PATCH [0-9]+\)$/set(VERSION_PATCH $NEXT_VERSION_PATCH)/" CMakeLists.txt
|
2014-12-25 06:11:53 +01:00
|
|
|
|
2021-01-20 21:37:24 +01:00
|
|
|
# Update Android versions
|
|
|
|
sed -i 's/set("versionExtra", "")/set("versionExtra", "-dev")/' build/android/build.gradle
|
|
|
|
sed -i -re "s/set\(\"versionMajor\", [0-9]+\)/set(\"versionMajor\", $NEXT_VERSION_MAJOR)/" build/android/build.gradle
|
|
|
|
sed -i -re "s/set\(\"versionMinor\", [0-9]+\)/set(\"versionMinor\", $NEXT_VERSION_MINOR)/" build/android/build.gradle
|
|
|
|
sed -i -re "s/set\(\"versionPatch\", [0-9]+\)/set(\"versionPatch\", $NEXT_VERSION_PATCH)/" build/android/build.gradle
|
2017-08-20 17:20:11 +02:00
|
|
|
|
2021-01-20 21:37:24 +01:00
|
|
|
# Update doc versions
|
|
|
|
sed -i -re "1s/[0-9]+\.[0-9]+\.[0-9]+/$NEXT_VERSION/g" doc/menu_lua_api.txt
|
2018-06-14 19:40:23 +02:00
|
|
|
sed -i -re "1s/[0-9]+\.[0-9]+\.[0-9]+/$NEXT_VERSION/g" doc/client_lua_api.txt
|
2017-08-20 17:20:11 +02:00
|
|
|
|
2021-01-20 21:37:24 +01:00
|
|
|
# Commit
|
|
|
|
git add -f CMakeLists.txt build/android/build.gradle doc/menu_lua_api.txt doc/client_lua_api.txt
|
2017-08-20 17:20:11 +02:00
|
|
|
git commit -m "Continue with $NEXT_VERSION-dev"
|
|
|
|
}
|
2014-12-25 06:11:53 +01:00
|
|
|
##################################
|
|
|
|
# Switch to top minetest directory
|
|
|
|
##################################
|
|
|
|
|
|
|
|
cd ${0%/*}/..
|
|
|
|
|
|
|
|
|
|
|
|
#######################
|
|
|
|
# Determine old version
|
|
|
|
#######################
|
|
|
|
|
|
|
|
# Make sure all the files we need exist
|
2017-08-20 17:20:11 +02:00
|
|
|
grep -q -E '^set\(VERSION_MAJOR [0-9]+\)$' CMakeLists.txt
|
|
|
|
grep -q -E '^set\(VERSION_MINOR [0-9]+\)$' CMakeLists.txt
|
|
|
|
grep -q -E '^set\(VERSION_PATCH [0-9]+\)$' CMakeLists.txt
|
2020-07-08 23:09:39 +02:00
|
|
|
grep -q -E '\("versionCode", [0-9]+\)' build/android/build.gradle
|
2014-12-25 06:11:53 +01:00
|
|
|
|
|
|
|
VERSION_MAJOR=$(grep -E '^set\(VERSION_MAJOR [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
|
|
|
|
VERSION_MINOR=$(grep -E '^set\(VERSION_MINOR [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
|
|
|
|
VERSION_PATCH=$(grep -E '^set\(VERSION_PATCH [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
|
2020-07-08 23:09:39 +02:00
|
|
|
ANDROID_VERSION_CODE=$(grep -E '"versionCode", [0-9]+' build/android/build.gradle | tr -dC 0-9)
|
2014-12-25 06:11:53 +01:00
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
RELEASE_VERSION="$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH"
|
2014-12-25 06:11:53 +01:00
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
echo "Current Minetest version: $RELEASE_VERSION"
|
|
|
|
echo "Current Android version code: $ANDROID_VERSION_CODE"
|
2014-12-25 06:11:53 +01:00
|
|
|
|
2020-06-25 16:36:51 +02:00
|
|
|
# +1 for ARM and +1 for ARM64 APKs
|
|
|
|
NEW_ANDROID_VERSION_CODE=$(expr $ANDROID_VERSION_CODE + 2)
|
2014-12-25 06:11:53 +01:00
|
|
|
NEW_ANDROID_VERSION_CODE=$(prompt_for_number "Set android version code" $NEW_ANDROID_VERSION_CODE)
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "New android version code: $NEW_ANDROID_VERSION_CODE"
|
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
########################
|
|
|
|
# Perform release
|
|
|
|
########################
|
2014-12-25 06:11:53 +01:00
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
perform_release
|
2014-12-25 06:11:53 +01:00
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
########################
|
|
|
|
# Prompt for next version
|
|
|
|
########################
|
2017-06-06 19:54:48 +02:00
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
NEXT_VERSION_MAJOR=$VERSION_MAJOR
|
|
|
|
NEXT_VERSION_MINOR=$VERSION_MINOR
|
|
|
|
NEXT_VERSION_PATCH=$(expr $VERSION_PATCH + 1)
|
2014-12-25 06:11:53 +01:00
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
NEXT_VERSION_MAJOR=$(prompt_for_number "Set next major" $NEXT_VERSION_MAJOR)
|
2015-05-05 00:46:49 +02:00
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
if [ "$NEXT_VERSION_MAJOR" != "$VERSION_MAJOR" ]; then
|
|
|
|
NEXT_VERSION_MINOR=0
|
|
|
|
NEXT_VERSION_PATCH=0
|
|
|
|
fi
|
2015-05-05 00:46:49 +02:00
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
NEXT_VERSION_MINOR=$(prompt_for_number "Set next minor" $NEXT_VERSION_MINOR)
|
2015-05-05 00:46:49 +02:00
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
if [ "$NEXT_VERSION_MINOR" != "$VERSION_MINOR" ]; then
|
|
|
|
NEXT_VERSION_PATCH=0
|
|
|
|
fi
|
2015-05-05 00:46:49 +02:00
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
NEXT_VERSION_PATCH=$(prompt_for_number "Set next patch" $NEXT_VERSION_PATCH)
|
2015-05-05 00:46:49 +02:00
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
NEXT_VERSION="$NEXT_VERSION_MAJOR.$NEXT_VERSION_MINOR.$NEXT_VERSION_PATCH"
|
2015-05-05 00:46:49 +02:00
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
echo
|
|
|
|
echo "New version: $NEXT_VERSION"
|
2015-05-05 00:46:49 +02:00
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
########################
|
|
|
|
# Return back to devel
|
|
|
|
########################
|
2015-05-05 00:46:49 +02:00
|
|
|
|
2017-08-20 17:20:11 +02:00
|
|
|
back_to_devel
|