remove ad from mod.conf
[waspsaliva.git] / util / bump_version.sh
blob996962199f54d58392244eec186f93f3245523f8
1 #!/bin/bash -e
3 prompt_for_number() {
4 local prompt_text=$1
5 local default_value=$2
6 local tmp=""
7 while true; do
8 read -p "$prompt_text [$default_value]: " tmp
9 if [ "$tmp" = "" ]; then
10 echo "$default_value"; return
11 elif echo "$tmp" | grep -q -E '^[0-9]+$'; then
12 echo "$tmp"; return
14 done
17 # On a release the following actions are performed
18 # * DEVELOPMENT_BUILD is set to false
19 # * android versionCode is bumped
20 # * appdata release version and date are updated
21 # * Commit the changes
22 # * Tag with current version
23 perform_release() {
24 sed -i -re "s/^set\(DEVELOPMENT_BUILD TRUE\)$/set(DEVELOPMENT_BUILD FALSE)/" CMakeLists.txt
26 sed -i -re "s/\"versionCode\", [0-9]+/\"versionCode\", $NEW_ANDROID_VERSION_CODE/" build/android/build.gradle
28 sed -i '/\<release/s/\(version\)="[^"]*"/\1="'"$RELEASE_VERSION"'"/' misc/net.minetest.minetest.appdata.xml
30 RELEASE_DATE=`date +%Y-%m-%d`
32 sed -i 's/\(<release date\)="[^"]*"/\1="'"$RELEASE_DATE"'"/' misc/net.minetest.minetest.appdata.xml
34 git add -f CMakeLists.txt build/android/build.gradle misc/net.minetest.minetest.appdata.xml
36 git commit -m "Bump version to $RELEASE_VERSION"
38 echo "Tagging $RELEASE_VERSION"
40 git tag -a "$RELEASE_VERSION" -m "$RELEASE_VERSION"
43 # After release
44 # * Set DEVELOPMENT_BUILD to true
45 # * Bump version in CMakeLists and docs
46 # * Commit the changes
47 back_to_devel() {
48 echo 'Creating "return back to development" commit'
50 sed -i -re 's/^set\(DEVELOPMENT_BUILD FALSE\)$/set(DEVELOPMENT_BUILD TRUE)/' CMakeLists.txt
52 sed -i -re "s/^set\(VERSION_MAJOR [0-9]+\)$/set(VERSION_MAJOR $NEXT_VERSION_MAJOR)/" CMakeLists.txt
54 sed -i -re "s/^set\(VERSION_MINOR [0-9]+\)$/set(VERSION_MINOR $NEXT_VERSION_MINOR)/" CMakeLists.txt
56 sed -i -re "s/^set\(VERSION_PATCH [0-9]+\)$/set(VERSION_PATCH $NEXT_VERSION_PATCH)/" CMakeLists.txt
58 sed -i -re "1s/[0-9]+\.[0-9]+\.[0-9]+/$NEXT_VERSION/g" doc/menu_lua_api.txt
60 sed -i -re "1s/[0-9]+\.[0-9]+\.[0-9]+/$NEXT_VERSION/g" doc/client_lua_api.txt
62 git add -f CMakeLists.txt doc/menu_lua_api.txt doc/client_lua_api.txt
64 git commit -m "Continue with $NEXT_VERSION-dev"
66 ##################################
67 # Switch to top minetest directory
68 ##################################
70 cd ${0%/*}/..
73 #######################
74 # Determine old version
75 #######################
77 # Make sure all the files we need exist
78 grep -q -E '^set\(VERSION_MAJOR [0-9]+\)$' CMakeLists.txt
79 grep -q -E '^set\(VERSION_MINOR [0-9]+\)$' CMakeLists.txt
80 grep -q -E '^set\(VERSION_PATCH [0-9]+\)$' CMakeLists.txt
81 grep -q -E '\("versionCode", [0-9]+\)' build/android/build.gradle
83 VERSION_MAJOR=$(grep -E '^set\(VERSION_MAJOR [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
84 VERSION_MINOR=$(grep -E '^set\(VERSION_MINOR [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
85 VERSION_PATCH=$(grep -E '^set\(VERSION_PATCH [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
86 ANDROID_VERSION_CODE=$(grep -E '"versionCode", [0-9]+' build/android/build.gradle | tr -dC 0-9)
88 RELEASE_VERSION="$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH"
90 echo "Current Minetest version: $RELEASE_VERSION"
91 echo "Current Android version code: $ANDROID_VERSION_CODE"
93 # +1 for ARM and +1 for ARM64 APKs
94 NEW_ANDROID_VERSION_CODE=$(expr $ANDROID_VERSION_CODE + 2)
95 NEW_ANDROID_VERSION_CODE=$(prompt_for_number "Set android version code" $NEW_ANDROID_VERSION_CODE)
97 echo
98 echo "New android version code: $NEW_ANDROID_VERSION_CODE"
100 ########################
101 # Perform release
102 ########################
104 perform_release
106 ########################
107 # Prompt for next version
108 ########################
110 NEXT_VERSION_MAJOR=$VERSION_MAJOR
111 NEXT_VERSION_MINOR=$VERSION_MINOR
112 NEXT_VERSION_PATCH=$(expr $VERSION_PATCH + 1)
114 NEXT_VERSION_MAJOR=$(prompt_for_number "Set next major" $NEXT_VERSION_MAJOR)
116 if [ "$NEXT_VERSION_MAJOR" != "$VERSION_MAJOR" ]; then
117 NEXT_VERSION_MINOR=0
118 NEXT_VERSION_PATCH=0
121 NEXT_VERSION_MINOR=$(prompt_for_number "Set next minor" $NEXT_VERSION_MINOR)
123 if [ "$NEXT_VERSION_MINOR" != "$VERSION_MINOR" ]; then
124 NEXT_VERSION_PATCH=0
127 NEXT_VERSION_PATCH=$(prompt_for_number "Set next patch" $NEXT_VERSION_PATCH)
129 NEXT_VERSION="$NEXT_VERSION_MAJOR.$NEXT_VERSION_MINOR.$NEXT_VERSION_PATCH"
131 echo
132 echo "New version: $NEXT_VERSION"
134 ########################
135 # Return back to devel
136 ########################
138 back_to_devel