Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c67d116 authored by Amit Kumar's avatar Amit Kumar
Browse files

Add branch sanitation into versioning scripts.

parent 43d88303
Loading
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -129,3 +129,7 @@ named as major.minor.patch. For proper versioning, one MUST use the
features have been merged into dev branch and are ready to be released
in production. After merging into the master, `tag-version.sh` MUST be
used to tag the release version at the latest commit.

> Notes - `bump-version.sh` will and must execute only on **dev** and
> **hotfix\*** branches while `tag-version.sh` will and must only work
> on **master** branch.
 No newline at end of file
+85 −73
Original line number Diff line number Diff line
#!/bin/bash
git diff-index --quiet HEAD --

#if [ $? -ne 0 ]; then
  #echo "Working tree must be empty before bumping the version"
@@ -16,6 +15,7 @@ NOCOLOR="\033[0m"

QUESTION_FLAG="${GREEN}?"
NOTICE_FLAG="${CYAN}❯"
ERROR_FLAG="${RED}🛑🛑\U25CF"

BUMPING_MSG="${NOTICE_FLAG} Bumping up version...${NOCOLOR}"
PUSHING_MSG="${NOTICE_FLAG} Pushing new version to the ${WHITE}origin${CYAN}...${NOCOLOR}"
@@ -66,6 +66,7 @@ else
    fi
}

do_version_upgrade() {
    VERSION_UPGRADE_TYPE=$1

    old_major=$((`cat app/build.gradle | grep "versionMajor = " | awk '{print $4}'`))
@@ -81,6 +82,7 @@ if [[ "${VERSION_UPGRADE_TYPE,,}" = "major" ]]; then

        echo -e "${NOTICE_FLAG} Will set new version to ${GREEN}${new_version}${NOCOLOR}."
        echo -ne "${QUESTION_FLAG} ${RED}Are you sure? [Y/n]: ${NOCOLOR}"
        read response
        response=${response,,}

        if [[ ${response} =~ ^(yes|y| ) ]] || [[ -z ${response} ]]; then
@@ -138,3 +140,13 @@ else
        echo " Wrong or empty arguments passed for <revision_type>. See usage below."
        usage
    fi
}

# It must check for dev or hotfix* branch and bump the version only when current branch is dev or hotfix.
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
if [[ ${branch} = "dev" ]] || [[ ${branch} = hotfix* ]]; then
    do_version_upgrade $1
else
    echo -e "${ERROR_FLAG} Can only be used on dev or hotfix branch."
    exit 1
fi
+3 −1
Original line number Diff line number Diff line
#!/bin/bash

# It must check for master branch and tag only if current branch is master.

branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
response=${response,,}
if [[ ${branch} = "master" ]]; then
    major=$((`cat app/build.gradle | grep "versionMajor = " | awk '{print $4}'`))
    minor=$((`cat app/build.gradle | grep "versionMinor = " | awk '{print $4}'`))