Browse Source

Merge branch 'enhancement/97-add-fixed-version-number' into 'develop'

#97: Add fixed version information

See merge request funkwhale/funkwhale-android!107
technical/update-jvmTarget-version 0.1.2
Ryan Harg 3 years ago
parent
commit
5d2556ca58
  1. 2
      app/build.gradle.kts
  2. 1
      changes/changelog.d/97.misc
  3. 85
      dist/create-release.sh
  4. 2
      fdroidversion.txt

2
app/build.gradle.kts

@ -26,7 +26,7 @@ unMock { @@ -26,7 +26,7 @@ unMock {
}
androidGitVersion {
codeFormat = "MMNNPPBBB"
codeFormat = "MMNNPPBBB" // Keep in sync with version_code() in dist/create_release.sh
format = "%tag%%-count%%-commit%%-branch%"
}

1
changes/changelog.d/97.misc

@ -0,0 +1 @@ @@ -0,0 +1 @@
Add hard coded version information for F-Droid deployment (#97)

85
dist/create-release.sh vendored

@ -0,0 +1,85 @@ @@ -0,0 +1,85 @@
#!/bin/bash
# This script creates a new release of Funkwhale for Android.
#
# Usage: ./create-release.sh TAG
# tokenize_tag() - tokenize tag parameter, splitting at dot
#
# Expects a string parameter with format MAJOR.MINOR.PATCH, e.g. 1.2.3
# Returns an array containing elements for MAJOR, MINOR and PATCH
function tokenize_tag() {
IFS="." read -ra TOKENS <<< "$1"
}
# version_code() - create a numeric version code from a tokenized tag parameter
# that conforms to the version code format from the
# gradle build script
#
# Expects an array parameter with entries for MAJOR, MINOR and PATCH version parts
# Returns a formatted version code, leading zeroes are stripped
function version_code() {
result=""
# Every version part is filled with leading zeros to a string of size 2
for token in "$@"
do
((leadingZeros=2-${#token}))
for _ in $(seq 1 "$leadingZeros")
do
token="${token}0"
done
result="$result$token"
done
# strip leading zeroes, add three trailing zeroes and return
echo "${result#"${result%%[!0]*}"}000"
}
# Validate if script is used with correct number of params
if [ $# -lt 1 ]; then
echo 'Usage: ./create-release.sh TAG' >&2
echo ' TAG format MAJOR.MINOR.PATH, e.g. 1.2.3' >&2
exit 1
fi
tokenize_tag "$1"
# Validate tag parameter format
if [ ${#TOKENS[@]} != 3 ]; then
echo 'ERROR: Invalid tag parameter format.' >&2
echo 'Use MAJOR.MINOR.PATCH scheme, e.g. 1.2.3' >&2
exit 1
fi
# Validate that git repository is not dirty
if [ "$(git diff --stat)" != '' ]; then
echo 'ERROR: repository is dirty.' >&2
exit 1
fi
TAG="$1"
MESSAGE="Creating release version $TAG"
echo "Compiling the changelog..."
towncrier build --version "$TAG" --date $(date +"%Y-%m-%d")
git add CHANGELOG
git comit --message "Update changelog for version $TAG"
# Validate that git tag doesn't already exist
git fetch --all --tags
if [ "$(git tag -l | grep -e "^$TAG$")" != '' ]; then
echo "ERROR: tag $TAG already exists." >&2
exit 1
fi
# Write versionCode and versionName to a file that F-Droid can parse
echo "versionCode = $(version_code "${TOKENS[@]}")
versionName = $TAG" > fdroidversion.txt
echo "Tagging the application..."
# Create and push tag
git tag -a -s -m "$MESSAGE" "$TAG"
git push --tags

2
fdroidversion.txt

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
versionCode = 1010000
versionName = 0.1.1
Loading…
Cancel
Save