Loading GitflowAndVersioning.md 0 → 100644 +131 −0 Original line number Original line Diff line number Diff line # Git Workflow A popular and well-known branching model and strategy with a little tweak is used in BlissLauncher. [Click here to read more about the original git branching model](https://nvie.com/posts/a-successful-git-branching-model/) ## Main Branches At the very core, BlissLauncher have two main branches with infinite lifetime: - `master` - `dev` We consider `origin/master` to be the main branch where the source code of HEAD always reflects a production-ready state. We consider `origin/dev` to be the main branch where the source code of HEAD always reflects a state with the latest delivered development changes for the next release. When the source code in the dev branch reaches a stable point and is ready to be released, all of the changes should be merged back into master somehow and then tagged with a release number. ## Support Branches - `Feature branches` - `Hotfix branches` We don't use release branches separately to simplify the deployment process for our dev team. *That's the only difference, this model has as compare to original model.* ### Feature Branches Must branch off from: `dev` Must merge back into: `dev` Branch naming convention: anything except master, develop, hotfix-* (preferable `feature-*`) #### Steps for working on features When starting work on a new feature, branch off from the `dev` branch. ```sh $ git checkout -b feature-blur-background dev # Switched to a new branch "feature-blur-background" ``` Finished features may be merged into the develop branch to definitely add them to the upcoming release: ```sh git checkout dev # Switched to branch "dev" $ git merge --no-ff feature-blur-background # Updating ea1b82a..05e9557 # (Summary of changes) $ git branch -d feature-blur-background Deleted branch feature-blur-background (was 05e9557). $ git push origin dev ``` ### Hotfix Branches Must branch off from: `master` Must merge back into: `master` and `dev` Branch naming convention: `hotfix-*` #### Steps for working on hotfixes Hotfix branches are created from the master branch. As soon as, a hotfix branch is created, version must be bumped using the command in the root of the project `bump-version.sh patch` ```sh $ git checkout -b hotfix-1.2.1 master # Switched to a new branch "hotfix-1.2.1" $ ./bump-version.sh patch ``` Then, fix the bug and commit the fix in one or more separate commits. ```sh $ git commit -m "Fixed severe production problem" # [hotfix-1.2.1 abbe5d6] Fixed severe production problem # 5 files changed, 32 insertions(+), 17 deletions(-) ``` When finished, the bugfix needs to be merged back into master, but also needs to be merged back into dev, in order to safeguard that the bugfix is included in the next release as well. Use `tag-version.sh` for tagging on master branch. ```sh $ git checkout master # Switched to branch 'master' $ git merge --no-ff hotfix-1.2.1 # Merge made by recursive. # (Summary of changes) $ ./tag-version.sh $ git checkout dev # Switched to branch 'dev' $ git merge --no-ff hotfix-1.2.1 # Merge made by recursive. # (Summary of changes) ``` Finally, remove the temporary branch: ```sh $ git branch -d hotfix-1.2.1 Deleted branch hotfix-1.2.1 (was abbe5d6). ``` ### Prepare Release Whenever all the features that are targeted for the release-to-be-built are merged into the dev and we are ready to prepare a test-release build, version must be bumped by using the command `bump-version.sh [major | minor]` based on the changes in the feature. If the test-release works without problem and bugs are fixed for this release, we are ready to release and move this code into `master`. #### Steps for finishing a release First, the `dev` is merged into `master` (since every commit on master is a new release by definition, remember). Next, that commit on master must be tagged for easy future reference to this historical version. Use `tag-version.sh` for tagging on master branch. ```sh $ git checkout master # Switched to branch 'master' $ git merge --no-ff dev # Merge made by recursive. # (Summary of changes) $ git push origin master $ ./tag-version.sh ``` # Versioning Semantic Versioning is used for BlissLauncher that is every version is named as major.minor.patch. For proper versioning, one MUST use the `bump-version.sh` every-time a new hotfix branch is created or intended 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. No newline at end of file bump-version.sh 0 → 100755 +140 −0 Original line number Original line 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" #fi RED="\033[1;31m" GREEN='\033[1;32m' YELLOW="\033[1;33m" BLUE="\033[1;34m" PURPLE="\033[1;35m" CYAN="\033[1;36m" WHITE="\033[1;37m" NOCOLOR="\033[0m" QUESTION_FLAG="${GREEN}?" NOTICE_FLAG="${CYAN}❯" BUMPING_MSG="${NOTICE_FLAG} Bumping up version...${NOCOLOR}" PUSHING_MSG="${NOTICE_FLAG} Pushing new version to the ${WHITE}origin${CYAN}...${NOCOLOR}" usage() { # Get the script name script_name=${0##*/} # Echo usage info echo " " echo -e " ${GREEN}${script_name}${NOCOLOR}" echo " ======================================" echo " ======================================" echo -e " ${BLUE}Author: ${WHITE}Amit Kumar" echo -e " " echo -e " Used to increment the version of ${RED}BlissLauncher${NOCOLOR} safely by performing predefined actions: " echo " 1. Checks the category of the revision (major,minor or patch) based on the argument (revision_type) passed into the script." echo -e " 2. Overwrite the version name and version code in app module level build.gradle based on the following logic" echo -e " * - If this upgrade is a major, new version name will be ${CYAN}{old_major + 1}.0.0${NOCOLOR}" echo -e " * - If upgrade type is minor, updated version name will be ${CYAN}old_major.{old_minor + 1}.0${NOCOLOR}" echo -e " * - If it is a patch (hotfix), updated version name will be ${CYAN}old_major.old_minor.{old_patch + 1}.0${NOCOLOR}" echo -e " 3. Add and Commit the updated files with the message ${GREEN}Bump version to vX.Y.Z${NOCOLOR}." echo " 4. Create a new tag (named the same as new version name) which refers to" echo " the commit created in (3)." echo " 5. Push the commit and tag to the remote git server." echo " " echo -e " ${BLUE}Usage:${NOCOLOR}" echo " ${script_name} [<revision_type>]" echo " " echo -e " ${BLUE}Arguments:${NOCOLOR}" echo -e " revision_type Could be one of the following - ${RED}major, minor or patch${NOCOLOR}." echo -e " " exit 1 } commit_and_push() { git add app/build.gradle git commit -m "Bump version to v$1" echo -e "${QUESTION_FLAG} ${RED}Do you want to push it to remote now?[Y/n]: ${NOCOLOR}" read -r -p "" response response=${response,,} if [[ ${response} =~ ^(yes|y| ) ]] || [[ -z ${response} ]]; then echo -e ${PUSHING_MSG} branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') git push -u origin ${branch} else exit 1 fi } VERSION_UPGRADE_TYPE=$1 old_major=$((`cat app/build.gradle | grep "versionMajor = " | awk '{print $4}'`)) old_minor=$((`cat app/build.gradle | grep "versionMinor = " | awk '{print $4}'`)) old_patch=$((`cat app/build.gradle | grep "versionPatch = " | awk '{print $4}'`)) if [[ "${VERSION_UPGRADE_TYPE,,}" = "major" ]]; then echo -e ${BUMPING_MSG} echo -e "${NOTICE_FLAG} Current version: ${WHITE}${old_major}.${old_minor}.${old_patch}" new_major=$(($old_major + 1)) new_version="${new_major}.0.0" echo -e "${NOTICE_FLAG} Will set new version to ${GREEN}${new_version}${NOCOLOR}." echo -ne "${QUESTION_FLAG} ${RED}Are you sure? [Y/n]: ${NOCOLOR}" response=${response,,} if [[ ${response} =~ ^(yes|y| ) ]] || [[ -z ${response} ]]; then sed -i "s/versionMajor = .*/versionMajor = ${new_major}/" app/build.gradle sed -i "s/versionMinor = .*/versionMinor = 0/" app/build.gradle sed -i "s/versionPatch = .*/versionPatch = 0/" app/build.gradle new_version="${new_major}.0.0" commit_and_push ${new_version} else exit 1 fi elif [[ "${VERSION_UPGRADE_TYPE,,}" = "minor" ]]; then echo -e ${BUMPING_MSG} echo -e "${NOTICE_FLAG} Current version: ${WHITE}${old_major}.${old_minor}.${old_patch}" new_minor=$((old_minor + 1)) new_version="${old_major}.${new_minor}.0" 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 sed -i "s/versionMinor = .*/versionMinor = ${new_minor}/" app/build.gradle sed -i "s/versionPatch = .*/versionPatch = 0/" app/build.gradle commit_and_push ${new_version} else exit 1 fi elif [[ "${VERSION_UPGRADE_TYPE,,}" = "patch" ]]; then echo -e ${BUMPING_MSG} echo -e "${NOTICE_FLAG} Current version: ${WHITE}${old_major}.${old_minor}.${old_patch}" new_patch=$((old_patch + 1)) new_version="${old_major}.${old_minor}.${new_patch}" 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 sed -i "s/versionPatch = .*/versionPatch = ${new_patch}/" app/build.gradle commit_and_push ${new_version} else exit 1 fi elif [[ "${VERSION_UPGRADE_TYPE,,}" = "help" ]]; then usage else echo " Wrong or empty arguments passed for <revision_type>. See usage below." usage fi No newline at end of file tag-version.sh 0 → 100755 +22 −0 Original line number Original line Diff line number Diff line #!/bin/bash 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}'`)) patch=$((`cat app/build.gradle | grep "versionPatch = " | awk '{print $4}'`)) version="${major}.${minor}.${patch}" git tag -a "v${version}" -m "Bliss Launcher Version ${version}" echo -e "Do you want to push tag to remote now?[Y/n]: " read -r -p "" response response=${response,,} if [[ ${response} =~ ^(yes|y| ) ]] || [[ -z ${response} ]]; then branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') git push origin --tags else exit 1 fi else echo "Can only be used on master branch." fi No newline at end of file Loading
GitflowAndVersioning.md 0 → 100644 +131 −0 Original line number Original line Diff line number Diff line # Git Workflow A popular and well-known branching model and strategy with a little tweak is used in BlissLauncher. [Click here to read more about the original git branching model](https://nvie.com/posts/a-successful-git-branching-model/) ## Main Branches At the very core, BlissLauncher have two main branches with infinite lifetime: - `master` - `dev` We consider `origin/master` to be the main branch where the source code of HEAD always reflects a production-ready state. We consider `origin/dev` to be the main branch where the source code of HEAD always reflects a state with the latest delivered development changes for the next release. When the source code in the dev branch reaches a stable point and is ready to be released, all of the changes should be merged back into master somehow and then tagged with a release number. ## Support Branches - `Feature branches` - `Hotfix branches` We don't use release branches separately to simplify the deployment process for our dev team. *That's the only difference, this model has as compare to original model.* ### Feature Branches Must branch off from: `dev` Must merge back into: `dev` Branch naming convention: anything except master, develop, hotfix-* (preferable `feature-*`) #### Steps for working on features When starting work on a new feature, branch off from the `dev` branch. ```sh $ git checkout -b feature-blur-background dev # Switched to a new branch "feature-blur-background" ``` Finished features may be merged into the develop branch to definitely add them to the upcoming release: ```sh git checkout dev # Switched to branch "dev" $ git merge --no-ff feature-blur-background # Updating ea1b82a..05e9557 # (Summary of changes) $ git branch -d feature-blur-background Deleted branch feature-blur-background (was 05e9557). $ git push origin dev ``` ### Hotfix Branches Must branch off from: `master` Must merge back into: `master` and `dev` Branch naming convention: `hotfix-*` #### Steps for working on hotfixes Hotfix branches are created from the master branch. As soon as, a hotfix branch is created, version must be bumped using the command in the root of the project `bump-version.sh patch` ```sh $ git checkout -b hotfix-1.2.1 master # Switched to a new branch "hotfix-1.2.1" $ ./bump-version.sh patch ``` Then, fix the bug and commit the fix in one or more separate commits. ```sh $ git commit -m "Fixed severe production problem" # [hotfix-1.2.1 abbe5d6] Fixed severe production problem # 5 files changed, 32 insertions(+), 17 deletions(-) ``` When finished, the bugfix needs to be merged back into master, but also needs to be merged back into dev, in order to safeguard that the bugfix is included in the next release as well. Use `tag-version.sh` for tagging on master branch. ```sh $ git checkout master # Switched to branch 'master' $ git merge --no-ff hotfix-1.2.1 # Merge made by recursive. # (Summary of changes) $ ./tag-version.sh $ git checkout dev # Switched to branch 'dev' $ git merge --no-ff hotfix-1.2.1 # Merge made by recursive. # (Summary of changes) ``` Finally, remove the temporary branch: ```sh $ git branch -d hotfix-1.2.1 Deleted branch hotfix-1.2.1 (was abbe5d6). ``` ### Prepare Release Whenever all the features that are targeted for the release-to-be-built are merged into the dev and we are ready to prepare a test-release build, version must be bumped by using the command `bump-version.sh [major | minor]` based on the changes in the feature. If the test-release works without problem and bugs are fixed for this release, we are ready to release and move this code into `master`. #### Steps for finishing a release First, the `dev` is merged into `master` (since every commit on master is a new release by definition, remember). Next, that commit on master must be tagged for easy future reference to this historical version. Use `tag-version.sh` for tagging on master branch. ```sh $ git checkout master # Switched to branch 'master' $ git merge --no-ff dev # Merge made by recursive. # (Summary of changes) $ git push origin master $ ./tag-version.sh ``` # Versioning Semantic Versioning is used for BlissLauncher that is every version is named as major.minor.patch. For proper versioning, one MUST use the `bump-version.sh` every-time a new hotfix branch is created or intended 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. No newline at end of file
bump-version.sh 0 → 100755 +140 −0 Original line number Original line 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" #fi RED="\033[1;31m" GREEN='\033[1;32m' YELLOW="\033[1;33m" BLUE="\033[1;34m" PURPLE="\033[1;35m" CYAN="\033[1;36m" WHITE="\033[1;37m" NOCOLOR="\033[0m" QUESTION_FLAG="${GREEN}?" NOTICE_FLAG="${CYAN}❯" BUMPING_MSG="${NOTICE_FLAG} Bumping up version...${NOCOLOR}" PUSHING_MSG="${NOTICE_FLAG} Pushing new version to the ${WHITE}origin${CYAN}...${NOCOLOR}" usage() { # Get the script name script_name=${0##*/} # Echo usage info echo " " echo -e " ${GREEN}${script_name}${NOCOLOR}" echo " ======================================" echo " ======================================" echo -e " ${BLUE}Author: ${WHITE}Amit Kumar" echo -e " " echo -e " Used to increment the version of ${RED}BlissLauncher${NOCOLOR} safely by performing predefined actions: " echo " 1. Checks the category of the revision (major,minor or patch) based on the argument (revision_type) passed into the script." echo -e " 2. Overwrite the version name and version code in app module level build.gradle based on the following logic" echo -e " * - If this upgrade is a major, new version name will be ${CYAN}{old_major + 1}.0.0${NOCOLOR}" echo -e " * - If upgrade type is minor, updated version name will be ${CYAN}old_major.{old_minor + 1}.0${NOCOLOR}" echo -e " * - If it is a patch (hotfix), updated version name will be ${CYAN}old_major.old_minor.{old_patch + 1}.0${NOCOLOR}" echo -e " 3. Add and Commit the updated files with the message ${GREEN}Bump version to vX.Y.Z${NOCOLOR}." echo " 4. Create a new tag (named the same as new version name) which refers to" echo " the commit created in (3)." echo " 5. Push the commit and tag to the remote git server." echo " " echo -e " ${BLUE}Usage:${NOCOLOR}" echo " ${script_name} [<revision_type>]" echo " " echo -e " ${BLUE}Arguments:${NOCOLOR}" echo -e " revision_type Could be one of the following - ${RED}major, minor or patch${NOCOLOR}." echo -e " " exit 1 } commit_and_push() { git add app/build.gradle git commit -m "Bump version to v$1" echo -e "${QUESTION_FLAG} ${RED}Do you want to push it to remote now?[Y/n]: ${NOCOLOR}" read -r -p "" response response=${response,,} if [[ ${response} =~ ^(yes|y| ) ]] || [[ -z ${response} ]]; then echo -e ${PUSHING_MSG} branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') git push -u origin ${branch} else exit 1 fi } VERSION_UPGRADE_TYPE=$1 old_major=$((`cat app/build.gradle | grep "versionMajor = " | awk '{print $4}'`)) old_minor=$((`cat app/build.gradle | grep "versionMinor = " | awk '{print $4}'`)) old_patch=$((`cat app/build.gradle | grep "versionPatch = " | awk '{print $4}'`)) if [[ "${VERSION_UPGRADE_TYPE,,}" = "major" ]]; then echo -e ${BUMPING_MSG} echo -e "${NOTICE_FLAG} Current version: ${WHITE}${old_major}.${old_minor}.${old_patch}" new_major=$(($old_major + 1)) new_version="${new_major}.0.0" echo -e "${NOTICE_FLAG} Will set new version to ${GREEN}${new_version}${NOCOLOR}." echo -ne "${QUESTION_FLAG} ${RED}Are you sure? [Y/n]: ${NOCOLOR}" response=${response,,} if [[ ${response} =~ ^(yes|y| ) ]] || [[ -z ${response} ]]; then sed -i "s/versionMajor = .*/versionMajor = ${new_major}/" app/build.gradle sed -i "s/versionMinor = .*/versionMinor = 0/" app/build.gradle sed -i "s/versionPatch = .*/versionPatch = 0/" app/build.gradle new_version="${new_major}.0.0" commit_and_push ${new_version} else exit 1 fi elif [[ "${VERSION_UPGRADE_TYPE,,}" = "minor" ]]; then echo -e ${BUMPING_MSG} echo -e "${NOTICE_FLAG} Current version: ${WHITE}${old_major}.${old_minor}.${old_patch}" new_minor=$((old_minor + 1)) new_version="${old_major}.${new_minor}.0" 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 sed -i "s/versionMinor = .*/versionMinor = ${new_minor}/" app/build.gradle sed -i "s/versionPatch = .*/versionPatch = 0/" app/build.gradle commit_and_push ${new_version} else exit 1 fi elif [[ "${VERSION_UPGRADE_TYPE,,}" = "patch" ]]; then echo -e ${BUMPING_MSG} echo -e "${NOTICE_FLAG} Current version: ${WHITE}${old_major}.${old_minor}.${old_patch}" new_patch=$((old_patch + 1)) new_version="${old_major}.${old_minor}.${new_patch}" 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 sed -i "s/versionPatch = .*/versionPatch = ${new_patch}/" app/build.gradle commit_and_push ${new_version} else exit 1 fi elif [[ "${VERSION_UPGRADE_TYPE,,}" = "help" ]]; then usage else echo " Wrong or empty arguments passed for <revision_type>. See usage below." usage fi No newline at end of file
tag-version.sh 0 → 100755 +22 −0 Original line number Original line Diff line number Diff line #!/bin/bash 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}'`)) patch=$((`cat app/build.gradle | grep "versionPatch = " | awk '{print $4}'`)) version="${major}.${minor}.${patch}" git tag -a "v${version}" -m "Bliss Launcher Version ${version}" echo -e "Do you want to push tag to remote now?[Y/n]: " read -r -p "" response response=${response,,} if [[ ${response} =~ ^(yes|y| ) ]] || [[ -z ${response} ]]; then branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') git push origin --tags else exit 1 fi else echo "Can only be used on master branch." fi No newline at end of file