mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-21 17:05:39 +03:00
Add increment_version.sh
Change-Id: Id52547142003e34a68645655835b842cab19a869
This commit is contained in:
parent
8cba674d01
commit
91c7e39d50
1 changed files with 73 additions and 0 deletions
73
increment_version.sh
Executable file
73
increment_version.sh
Executable file
|
@ -0,0 +1,73 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
mydir="$(dirname "$(realpath "$0")")"
|
||||
|
||||
source "$mydir/merge_helpers.sh"
|
||||
|
||||
require_clean_git
|
||||
|
||||
|
||||
pushd "$mydir" > /dev/null
|
||||
|
||||
last_tag=`downstream_latest_tag`
|
||||
|
||||
build_gradle="vector/build.gradle"
|
||||
|
||||
get_prop() {
|
||||
local prop="$1"
|
||||
cat "$build_gradle" | grep "$prop = " | sed "s|$prop = ||"
|
||||
}
|
||||
set_prop() {
|
||||
local prop="$1"
|
||||
local value="$2"
|
||||
if grep -q "$prop =" "$build_gradle"; then
|
||||
local equals="= "
|
||||
local not_equals=""
|
||||
else
|
||||
local equals=""
|
||||
# Don't touch lines that have an equals in it, but not for this prop
|
||||
local not_equals="/=/! "
|
||||
fi
|
||||
sed -i "$not_equals""s|\($prop $equals\).*|\1$value|g" "$build_gradle"
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Increase version
|
||||
#
|
||||
|
||||
versionMajor=`get_prop ext.versionMajor`
|
||||
versionMinor=`get_prop ext.versionMinor`
|
||||
versionPatch=`get_prop ext.versionPatch`
|
||||
scVersion=`get_prop ext.scVersion`
|
||||
|
||||
((scVersion++))
|
||||
|
||||
version="$versionMajor.$versionMinor.$versionPatch.sc.$scVersion"
|
||||
versionCode=`echo "(($versionMajor * 10000 + $versionMinor * 100 + $versionPatch + $scVersion) + 4000000) * 10" | bc`
|
||||
new_tag="sc_v$version"
|
||||
|
||||
set_prop "ext.scVersion" "$scVersion"
|
||||
set_prop "versionCode" "$versionCode"
|
||||
set_prop "versionName" "\"$version\""
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Generate changelog
|
||||
#
|
||||
|
||||
changelog_dir=fastlane/metadata/android/en-US/changelogs
|
||||
changelog_file="$changelog_dir/$versionCode.txt"
|
||||
mkdir -p "$changelog_dir"
|
||||
git log --reverse --pretty=format:"- %s" "$last_tag".. --committer="$(git config user.name)" > "$changelog_file"
|
||||
$EDITOR "$changelog_file" || true
|
||||
read -p "Press enter when changelog is done"
|
||||
|
||||
git add -A
|
||||
git commit -m "Increment version"
|
||||
git tag "$new_tag"
|
||||
|
||||
popd > /dev/null
|
Loading…
Reference in a new issue