aboutsummaryrefslogtreecommitdiff
path: root/util/bump_version.sh
blob: 5ff69c8af7874be450796b3ee8d2fcc35d72a01c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash

die() { echo "$@" 1>&2 ; exit 1; }

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
}


##################################
# Switch to top minetest directory
##################################

cd ${0%/*}/..


#######################
# Determine old version
#######################

# Make sure all the files we need exist
grep -q -E '^set\(VERSION_MAJOR [0-9]+\)$' CMakeLists.txt || die "error: Could not find CMakeLists.txt"
grep -q -E '^set\(VERSION_MINOR [0-9]+\)$' CMakeLists.txt || die "error: Could not find CMakeLists.txt"
grep -q -E '^set\(VERSION_PATCH [0-9]+\)$' CMakeLists.txt || die "error: Could not find CMakeLists.txt"
grep -q -E '^ANDROID_VERSION_CODE = [0-9]+$' build/android/Makefile || die "error: Could not find build/android/Makefile"

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)
ANDROID_VERSION_CODE=$(grep -E '^ANDROID_VERSION_CODE = [0-9]+$' build/android/Makefile | tr -dC 0-9)

echo "Current Minetest version: $VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH"
echo "Current Android version code: $ANDROID_VERSION_CODE"


########################
# Prompt for new version
########################

NEW_VERSION_MAJOR=$VERSION_MAJOR
NEW_VERSION_MINOR=$VERSION_MINOR
NEW_VERSION_PATCH=$(expr $VERSION_PATCH + 1)

NEW_VERSION_MAJOR=$(prompt_for_number "Set major" $NEW_VERSION_MAJOR)

if [ "$NEW_VERSION_MAJOR" != "$VERSION_MAJOR" ]; then
	NEW_VERSION_MINOR=0
	NEW_VERSION_PATCH=0
fi

NEW_VERSION_MINOR=$(prompt_for_number "Set minor" $NEW_VERSION_MINOR)

if [ "$NEW_VERSION_MINOR" != "$VERSION_MINOR" ]; then
	NEW_VERSION_PATCH=0
fi

NEW_VERSION_PATCH=$(prompt_for_number "Set patch" $NEW_VERSION_PATCH)

NEW_ANDROID_VERSION_CODE=$(expr $ANDROID_VERSION_CODE + 1)
NEW_ANDROID_VERSION_CODE=$(prompt_for_number "Set android version code" $NEW_ANDROID_VERSION_CODE)

NEW_VERSION="$NEW_VERSION_MAJOR.$NEW_VERSION_MINOR.$NEW_VERSION_PATCH"


echo
echo "New version: $NEW_VERSION"
echo "New android version code: $NEW_ANDROID_VERSION_CODE"


#######################################
# Replace version everywhere and commit
#######################################

sed -i -re "s/^set\(VERSION_MAJOR [0-9]+\)$/set(VERSION_MAJOR $NEW_VERSION_MAJOR)/" CMakeLists.txt || die "Failed to update VERSION_MAJOR"

sed -i -re "s/^set\(VERSION_MINOR [0-9]+\)$/set(VERSION_MINOR $NEW_VERSION_MINOR)/" CMakeLists.txt || die "Failed to update VERSION_MINOR"

sed -i -re "s/^set\(VERSION_PATCH [0-9]+\)$/set(VERSION_PATCH $NEW_VERSION_PATCH)/" CMakeLists.txt || die "Failed to update VERSION_PATCH"

sed -i -re "s/^set\(DEVELOPMENT_BUILD TRUE\)$/set(DEVELOPMENT_BUILD FALSE)/" CMakeLists.txt || die "Failed to unset DEVELOPMENT_BUILD"

sed -i -re "s/^ANDROID_VERSION_CODE = [0-9]+$/ANDROID_VERSION_CODE = $NEW_ANDROID_VERSION_CODE/" build/android/Makefile || die "Failed to update ANDROID_VERSION_CODE"

sed -i -re "1s/[0-9]+\.[0-9]+\.[0-9]+/$NEW_VERSION/g" doc/lua_api.txt || die "Failed to update doc/lua_api.txt"

sed -i -re "1s/[0-9]+\.[0-9]+\.[0-9]+/$NEW_VERSION/g" doc/menu_lua_api.txt || die "Failed to update doc/menu_lua_api.txt"

git add -f CMakeLists.txt build/android/Makefile doc/lua_api.txt doc/menu_lua_api.txt || die "git add failed"

git commit -m "Bump version to $NEW_VERSION" || die "git commit failed"

############
# Create tag
############

echo "Tagging $NEW_VERSION"

git tag -a "$NEW_VERSION" -m "$NEW_VERSION" || die 'Adding tag failed'

######################
# Create revert commit
######################

echo 'Creating "revert to development" commit'

sed -i -re 's/^set\(DEVELOPMENT_BUILD FALSE\)$/set(DEVELOPMENT_BUILD TRUE)/' CMakeLists.txt || die 'Failed to set DEVELOPMENT_BUILD'

git add -f CMakeLists.txt || die 'git add failed'

git commit -m "Continue with $NEW_VERSION-dev" || die 'git commit failed'

ass="hl esc">\n" " num_oranges = 53\n" "}\n"; void TestSettings::testAllSettings() { try { Settings s; // Test reading of settings std::istringstream is(config_text_before); s.parseConfigLines(is); UASSERT(s.getS32("leet") == 1337); UASSERT(s.getS16("leetleet") == 32767); UASSERT(s.getS16("leetleet_neg") == -32768); // Not sure if 1.1 is an exact value as a float, but doesn't matter UASSERT(fabs(s.getFloat("floaty_thing") - 1.1) < 0.001); UASSERT(s.get("stringy_thing") == "asd /( ¤%&(/\" BLÖÄRP"); UASSERT(fabs(s.getV3F("coord").X - 1.0) < 0.001); UASSERT(fabs(s.getV3F("coord").Y - 2.0) < 0.001); UASSERT(fabs(s.getV3F("coord").Z - 4.5) < 0.001); // Test the setting of settings too s.setFloat("floaty_thing_2", 1.2); s.setV3F("coord2", v3f(1, 2, 3.3)); UASSERT(s.get("floaty_thing_2").substr(0,3) == "1.2"); UASSERT(fabs(s.getFloat("floaty_thing_2") - 1.2) < 0.001); UASSERT(fabs(s.getV3F("coord2").X - 1.0) < 0.001); UASSERT(fabs(s.getV3F("coord2").Y - 2.0) < 0.001); UASSERT(fabs(s.getV3F("coord2").Z - 3.3) < 0.001); // Test settings groups Settings *group = s.getGroup("asdf"); UASSERT(group != NULL); UASSERT(s.getGroupNoEx("zoop", group) == false); UASSERT(group->getS16("a") == 5); UASSERT(fabs(group->getFloat("bb") - 2.5) < 0.001); Settings *group3 = new Settings; group3->set("cat", "meow"); group3->set("dog", "woof"); Settings *group2 = new Settings; group2->setS16("num_apples", 4); group2->setS16("num_oranges", 53); group2->setGroup("animals", group3); group2->set("animals", "cute"); //destroys group 3 s.setGroup("groupy_thing", group2); // Test set failure conditions UASSERT(s.set("Zoop = Poop\nsome_other_setting", "false") == false); UASSERT(s.set("sneaky", "\"\"\"\njabberwocky = false") == false); UASSERT(s.set("hehe", "asdfasdf\n\"\"\"\nsomething = false") == false); // Test multiline settings UASSERT(group->get("ccc") == "testy\n testa "); UASSERT(s.get("blarg") == "some multiline text\n" " with leading whitespace!"); // Test NoiseParams UASSERT(s.getEntry("np_terrain").is_group == false); NoiseParams np; UASSERT(s.getNoiseParams("np_terrain", np) == true); UASSERT(fabs(np.offset - 5) < 0.001); UASSERT(fabs(np.scale - 40) < 0.001); UASSERT(fabs(np.spread.X - 250) < 0.001); UASSERT(fabs(np.spread.Y - 250) < 0.001); UASSERT(fabs(np.spread.Z - 250) < 0.001); UASSERT(np.seed == 12341); UASSERT(np.octaves == 5); UASSERT(fabs(np.persist - 0.7) < 0.001); np.offset = 3.5; np.octaves = 6;