2020-09-10 12:11:57 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
mydir="$(dirname "$(realpath "$0")")"
|
|
|
|
|
|
|
|
source "$mydir/merge_helpers.sh"
|
|
|
|
|
2021-01-17 12:21:38 +03:00
|
|
|
# https://f-droid.org/en/docs/All_About_Descriptions_Graphics_and_Screenshots/
|
|
|
|
max_changelog_len=500
|
|
|
|
|
2023-04-01 12:23:33 +03:00
|
|
|
should_merge_translations_for_release=0
|
|
|
|
|
2020-11-05 17:46:48 +03:00
|
|
|
if [ "$1" = "preview" ]; then
|
|
|
|
preview=1
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
preview=0
|
|
|
|
require_clean_git
|
|
|
|
fi
|
|
|
|
|
2020-09-10 12:11:57 +03:00
|
|
|
|
2020-11-05 17:06:00 +03:00
|
|
|
if [ "$1" = "test" ]; then
|
|
|
|
release_type="test"
|
|
|
|
previousTestVersionCode="$2"
|
2023-07-21 13:21:19 +03:00
|
|
|
# Remove last digit for internal version codes without split ABI
|
|
|
|
previousTestVersionCode=`echo "$previousTestVersionCode" | sed 's|[0-9]$||'`
|
2020-11-05 17:06:00 +03:00
|
|
|
else
|
|
|
|
release_type="normal"
|
|
|
|
fi
|
|
|
|
|
2020-09-10 12:11:57 +03:00
|
|
|
|
|
|
|
pushd "$mydir" > /dev/null
|
|
|
|
|
2021-07-16 13:33:26 +03:00
|
|
|
do_translation_pull=0
|
|
|
|
|
2023-04-01 12:23:33 +03:00
|
|
|
if ((should_merge_translations_for_release)); then
|
|
|
|
if [ "$release_type" = "normal" ] && [ "$preview" != 1 ]; then
|
|
|
|
if git remote get-url weblate > /dev/null; then
|
|
|
|
echo "Pulling translations..."
|
|
|
|
translation commit && do_translation_pull=1 || echo "translation tool not found, skipping forced commit"
|
|
|
|
git fetch weblate
|
|
|
|
git merge weblate/sc --no-edit
|
|
|
|
else
|
|
|
|
echo "WARN: remote weblate not found, not updating translations"
|
|
|
|
fi
|
2021-08-20 10:45:42 +03:00
|
|
|
fi
|
2021-07-16 13:33:26 +03:00
|
|
|
fi
|
|
|
|
|
2020-09-10 12:11:57 +03:00
|
|
|
last_tag=`downstream_latest_tag`
|
|
|
|
|
|
|
|
|
2021-01-16 13:43:42 +03:00
|
|
|
# Legacy versioning, based on Element's version codes
|
|
|
|
#calculate_version_code() {
|
|
|
|
# echo "(($versionMajor * 10000 + $versionMinor * 100 + $versionPatch + $scVersion) + 4000000) * 10" | bc
|
|
|
|
#}
|
2020-11-05 16:15:41 +03:00
|
|
|
|
2020-09-10 12:11:57 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# Increase version
|
|
|
|
#
|
|
|
|
|
|
|
|
versionMajor=`get_prop ext.versionMajor`
|
|
|
|
versionMinor=`get_prop ext.versionMinor`
|
|
|
|
versionPatch=`get_prop ext.versionPatch`
|
|
|
|
scVersion=`get_prop ext.scVersion`
|
|
|
|
|
2020-11-05 16:15:41 +03:00
|
|
|
previousVersionCode=`grep '^ versionCode ' "$build_gradle" | sed 's|^ versionCode ||'`
|
2021-01-16 13:43:42 +03:00
|
|
|
# Legacy versioning, based on Element's version codes
|
|
|
|
#versionCode=`calculate_version_code`
|
|
|
|
#if [ "$release_type" = "test" ]; then
|
|
|
|
# if [ ! -z "$previousTestVersionCode" ]; then
|
|
|
|
# previousVersionCode=$((previousVersionCode > previousTestVersionCode ? previousVersionCode : previousTestVersionCode))
|
|
|
|
# fi
|
|
|
|
# versionCode=$((previousVersionCode + 1))
|
|
|
|
#elif [ "$versionCode" = "$previousVersionCode" ]; then
|
|
|
|
# ((scVersion++))
|
|
|
|
# echo "Increase downstream version to $scVersion"
|
|
|
|
# versionCode=`calculate_version_code`
|
|
|
|
#else
|
|
|
|
# echo "Upstream version upgrade, no need to change downstream version"
|
|
|
|
#fi
|
|
|
|
# New versioning: versionCode incremented independently of versionName, and always increment scVersion
|
|
|
|
((scVersion++))
|
2020-11-05 17:06:00 +03:00
|
|
|
if [ "$release_type" = "test" ]; then
|
|
|
|
if [ ! -z "$previousTestVersionCode" ]; then
|
2021-01-16 13:43:42 +03:00
|
|
|
testVersionCount=$((previousVersionCode > previousTestVersionCode ? 1 : (previousTestVersionCode - previousVersionCode + 1)))
|
2020-11-05 17:06:00 +03:00
|
|
|
previousVersionCode=$((previousVersionCode > previousTestVersionCode ? previousVersionCode : previousTestVersionCode))
|
2021-01-16 13:43:42 +03:00
|
|
|
else
|
|
|
|
testVersionCount=1
|
2020-11-05 17:06:00 +03:00
|
|
|
fi
|
|
|
|
versionCode=$((previousVersionCode + 1))
|
2020-11-05 16:15:41 +03:00
|
|
|
else
|
2021-01-16 13:43:42 +03:00
|
|
|
versionCode=$((previousVersionCode + 10))
|
2021-01-16 20:44:33 +03:00
|
|
|
# Ensure the new version code is higher than the one of the last test version
|
2023-07-21 13:21:19 +03:00
|
|
|
# Note that `versionCode` from build.gradle is before multiplying with 10 for split ABI, so here we remove the last digit
|
2022-08-10 13:39:53 +03:00
|
|
|
if [ -f "$HOME/fdroid/sm/data/metadata/de.spiritcroc.riotx.x.yml" ]; then
|
2023-07-21 13:21:19 +03:00
|
|
|
lastTestVersionCode="$(cat "$HOME/fdroid/sm/data/metadata/de.spiritcroc.riotx.x.yml"|grep versionCode|tail -n 1|sed 's|.*: ||;s|[0-9]$||')"
|
2021-01-16 20:44:33 +03:00
|
|
|
else
|
|
|
|
read -p "Enter versionCode of last test version: " lastTestVersionCode
|
|
|
|
fi
|
|
|
|
while [ "$lastTestVersionCode" -ge "$versionCode" ]; do
|
|
|
|
versionCode=$((versionCode + 10))
|
|
|
|
done
|
2020-11-05 16:15:41 +03:00
|
|
|
fi
|
2020-09-10 12:11:57 +03:00
|
|
|
|
2021-01-16 13:43:42 +03:00
|
|
|
|
|
|
|
version="$versionMajor.$versionMinor.$versionPatch.sc$scVersion"
|
2020-11-05 17:46:48 +03:00
|
|
|
|
|
|
|
if [ "$release_type" = "test" ]; then
|
2021-01-16 13:43:42 +03:00
|
|
|
version="$version-test$testVersionCount"
|
2020-11-05 17:46:48 +03:00
|
|
|
fi
|
|
|
|
|
2020-09-30 11:52:45 +03:00
|
|
|
new_tag="sc_v$version"
|
2020-09-10 12:11:57 +03:00
|
|
|
|
2020-11-05 17:46:48 +03:00
|
|
|
if ((preview)); then
|
2023-07-21 13:21:19 +03:00
|
|
|
# Append 0 for universal apk
|
|
|
|
echo "versionCode ${versionCode}0"
|
2020-11-05 17:46:48 +03:00
|
|
|
echo "versionName $version"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2020-09-10 12:11:57 +03:00
|
|
|
set_prop "ext.scVersion" "$scVersion"
|
|
|
|
set_prop "versionCode" "$versionCode"
|
|
|
|
set_prop "versionName" "\"$version\""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Generate changelog
|
|
|
|
#
|
|
|
|
|
2021-01-17 12:21:38 +03:00
|
|
|
git_changelog() {
|
|
|
|
git_args="$1"
|
|
|
|
|
|
|
|
git log $git_args --pretty=format:"- %s" "$last_tag".. --committer="$(git config user.name)" \
|
2021-01-16 20:59:42 +03:00
|
|
|
| grep -v 'Automatic revert to unchanged upstream strings' \
|
|
|
|
| grep -v 'Automatic upstream merge preparation' \
|
2022-03-31 10:18:28 +03:00
|
|
|
| sed "s|Merge tag '\\(.*\\)' into sc.*|Update codebase to Element \1|" \
|
|
|
|
| sed "s|Merge tag '\\(.*\\)' into merge.*|Update codebase to Element \1|" \
|
2021-08-02 14:59:41 +03:00
|
|
|
| grep -v "Merge .*branch" \
|
2021-01-16 20:59:42 +03:00
|
|
|
| grep -v "Automatic color correction" \
|
|
|
|
| grep -v "Automatic upstream merge postprocessing" \
|
|
|
|
| grep -v "Automatic SchildiChat string correction" \
|
2021-02-20 17:43:51 +03:00
|
|
|
| grep -v 'merge_helpers\|README\|increment_version' \
|
|
|
|
| grep -v "\\.sh" \
|
2022-05-18 11:21:16 +03:00
|
|
|
| grep -v "\\.md" \
|
2021-06-04 12:28:55 +03:00
|
|
|
| grep -v "Update string correction" \
|
|
|
|
| grep -v "Added translation using Weblate" \
|
|
|
|
| grep -v "Translated using Weblate" \
|
2021-07-16 14:22:14 +03:00
|
|
|
| grep -v "weblate/sc" \
|
2022-03-02 18:14:22 +03:00
|
|
|
| grep -v "\\[.*merge.*\\]" \
|
2021-10-22 12:15:30 +03:00
|
|
|
| grep -v "Disable Android Auto supports" \
|
2022-08-09 16:37:37 +03:00
|
|
|
| grep -v "\\[gplay-release\\]" \
|
2021-07-16 14:22:14 +03:00
|
|
|
|| echo "No significant changes since the last stable release"
|
2021-01-17 12:21:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
changelog_dir=fastlane/metadata/android/en-US/changelogs
|
|
|
|
changelog_file="$changelog_dir/$versionCode.txt"
|
|
|
|
mkdir -p "$changelog_dir"
|
|
|
|
if [ "$release_type" = "test" ]; then
|
|
|
|
git_changelog > "$changelog_file"
|
|
|
|
# Automated changelog is usually too long for F-Droid changelog
|
|
|
|
if [ "$(wc -m "$changelog_file"|sed 's| .*||')" -gt "$max_changelog_len" ]; then
|
|
|
|
current_commit="$(git rev-parse HEAD)"
|
|
|
|
changelog_add="$(echo -e "- ...\n\nAll changes: https://github.com/SchildiChat/SchildiChat-android/commits/$current_commit")"
|
|
|
|
addlen="$(expr length "$changelog_add")"
|
|
|
|
# - 3: probably not necessary, but I don't want to risk a broken link because of some miscalculation
|
|
|
|
allow_len=$((max_changelog_len - addlen - 3))
|
|
|
|
while [ "$(wc -m "$changelog_file"|sed 's| .*||')" -gt "$allow_len" ]; do
|
|
|
|
content_shortened="$(head -n -1 "$changelog_file")"
|
|
|
|
echo "$content_shortened" > "$changelog_file"
|
|
|
|
done
|
|
|
|
echo "$changelog_add" >> "$changelog_file"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
git_changelog --reverse > "$changelog_file"
|
2021-01-16 20:59:42 +03:00
|
|
|
fi
|
2020-11-05 17:06:00 +03:00
|
|
|
if [ "$release_type" != "test" ]; then
|
2021-02-20 17:43:51 +03:00
|
|
|
echo "Opening changelog for manual revision..."
|
|
|
|
await_edit "$changelog_file" || true
|
2020-11-05 17:06:00 +03:00
|
|
|
fi
|
2020-09-10 12:11:57 +03:00
|
|
|
|
2021-01-17 12:21:38 +03:00
|
|
|
while [ "$(wc -m "$changelog_file"|sed 's| .*||')" -gt "$max_changelog_len" ]; do
|
|
|
|
echo "Your changelog is too long, only $max_changelog_len characters allowed!"
|
|
|
|
echo "Currently: $(wc -m "$changelog_file")"
|
|
|
|
read -p "Press enter when changelog is done"
|
|
|
|
done
|
|
|
|
|
2020-09-10 12:11:57 +03:00
|
|
|
git add -A
|
2020-11-05 17:06:00 +03:00
|
|
|
if [ "$release_type" = "test" ]; then
|
|
|
|
git commit -m "Test version $versionCode"
|
|
|
|
else
|
|
|
|
git commit -m "Increment version"
|
|
|
|
git tag "$new_tag"
|
|
|
|
fi
|
2020-09-10 12:11:57 +03:00
|
|
|
|
2021-07-16 13:33:26 +03:00
|
|
|
if ((do_translation_pull)); then
|
|
|
|
echo "Updating weblate repo..."
|
|
|
|
translation pull
|
|
|
|
fi
|
|
|
|
|
2020-09-10 12:11:57 +03:00
|
|
|
popd > /dev/null
|