#!/bin/bash

# Get version tag string
VERSION_TAG=`(cd $PROJECT_DIR && git describe --long)`
echo "Version tag: $VERSION_TAG"

# Parse version tag string
[[ $VERSION_TAG =~ v([[:digit:]\.]+)([[:alpha:]]?)-([[:digit:]]+)-g([[:xdigit:]]+) ]]
VERSION="${BASH_REMATCH[1]}"
RELEASE="${BASH_REMATCH[2]}"
REVISION="${BASH_REMATCH[3]}"
BUILD="${BASH_REMATCH[4]}"
echo "Version: $VERSION.$REVISION$RELEASE ($BUILD)"

# Generate appversion.prefix
APPVERSION_FILE="$BUILD_ROOT/appversion.prefix"
rm -f "$APPVERSION_FILE"
echo "" > "$APPVERSION_FILE"
echo "#define OSMAND_VERSION $VERSION.$REVISION$RELEASE" >> "$APPVERSION_FILE"
echo "#define OSMAND_BUILD $BUILD" >> "$APPVERSION_FILE"

# Touch plist file
#touch -m "$PROJECT_DIR/$INFOPLIST_FILE"
#touch -A -05 -m "$PROJECT_DIR/$INFOPLIST_FILE"

#!/bin/bash

# Get version tag/hash strings
IOS_GIT_TAG=`(cd "$PROJECT_DIR" && git describe --long)`
echo "iOS git tag: $IOS_GIT_TAG"
CORE_GIT_HASH=`(cd "$PROJECT_DIR/../core" && git log --pretty=format:'%h' -n 1)`
echo "Core git hash: $CORE_GIT_HASH"
RESOURCES_GIT_HASH=`(cd "$PROJECT_DIR/../resources" && git log --pretty=format:'%h' -n 1)`
echo "Resources git hash: $RESOURCES_GIT_HASH"

# Parse version tag string
[[ $IOS_GIT_TAG =~ v([[:digit:]\.]+)([[:alpha:]]?)-([[:digit:]]+)-g([[:xdigit:]]+) ]]
VERSION="${BASH_REMATCH[1]}"
RELEASE="${BASH_REMATCH[2]}"
REVISION="${BASH_REMATCH[3]}"
BUILD="${BASH_REMATCH[4]}/${CORE_GIT_HASH}/${RESOURCES_GIT_HASH}"
echo "Version: $VERSION.$REVISION$RELEASE ($BUILD)"

# Generate appversion.prefix
APPVERSION_FILE="$BUILD_ROOT/appversion.prefix"
rm -f "$APPVERSION_FILE"
echo "" > "$APPVERSION_FILE"
echo "#define OSMAND_VERSION $VERSION.$REVISION$RELEASE" >> "$APPVERSION_FILE"
echo "#define OSMAND_BUILD $BUILD" >> "$APPVERSION_FILE"

# Touch plist file
#touch -m "$PROJECT_DIR/$INFOPLIST_FILE"
#touch -A -05 -m "$PROJECT_DIR/$INFOPLIST_FILE"

Include core and resources hash in version string
[IOS-45]: Include core and resources hash in version string
