diff --git a/README.md b/README.md index 44f5967..e98eba2 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ Targeting commit: e3e45889b --------------------------------------------------------------- ``` -Next step is selecting a target that should be run on CI: +Next step is selecting one or multiple targets that should be run on CI: ```bash diff --git a/app-deploy.sh b/app-deploy.sh index 1b93c01..ad9fcf8 100755 --- a/app-deploy.sh +++ b/app-deploy.sh @@ -39,6 +39,7 @@ function main { # CREATE TAG deploy_options + input_to_tags create_app_version_and_build_number # CREATE CHANGELOG @@ -108,6 +109,23 @@ function initial_checkup { fi } +function input_to_tags { + + # Parse all selected options + IFS=', ' read -r -a environments_array <<< "$target_selection" + + environments_to_build=() + + for environment in "${environments_array[@]}"; do + if [ ${environment} -le $((${#environments[@]} - 1)) -a ${environment} -ge 0 ]; then + environments_to_build+=("${environments[${environment}]}") + else + echo "Error: You chose wrong, young Jedi. This is the end of your path..." + exit 4 + fi + done +} + function create_app_version_and_build_number { echo @@ -146,7 +164,10 @@ function create_app_version_and_build_number { fi # Create tag name internal{-TargetX}/vM.m.p-{number of commits}. E.g. internal-all/v1.0.0-1234 - tag="$target/v$appversion-$tags_count" + tags_to_deploy=() + for target in "${environments_to_build[@]}"; do + tags_to_deploy+=("$target/v$appversion-$tags_count") + done echo echo "Next app version is: ${bold}v$appversion-$tags_count${normal}" @@ -164,8 +185,19 @@ function generate_tag_and_changelog { echo "Enter changelog message..." echo "------------------------------------------------------------" sleep 1 - - git tag -a "$tag" + + tag_message_added=0 + for tag in "${tags_to_deploy[@]}"; do + + if [ ${tag_message_added} -eq 1 ]; then + TAG=`git describe --exact-match` + CHANGELOG=`git show -s --format=%N ${TAG} | tail -n +4` + git tag -a "$tag" -m "${CHANGELOG}" + else + git tag -a "$tag" + tag_message_added=1 + fi + done } function push_tag_and_start_deploy { @@ -184,20 +216,23 @@ function push_tag_and_start_deploy { echo "---------------------------------------------------------------" echo " ~ CONFIGURATION ~ " echo - echo "Target: ${bold}$target_selection. $target${normal}" - echo "Version: ${bold}v$appversion-$tags_count${normal}" - echo "Tag: ${bold}$tag${normal}" + echo "Version: ${bold}v$appversion-$tags_count${normal}" + for tag in "${tags_to_deploy[@]}"; do + echo "Tag: ${bold}$tag${normal}" + done echo echo "Changelog:" echo "${bold}$changelog_message${normal}" echo "---------------------------------------------------------------" echo - read -r -p "Is configuration correct for the CI deployment? [y/n] " response + read -r -p "Is configuration correct for the CI deployment? [y or enter / n] " response echo - if [[ ${response} =~ ^(no|n|N) ]] || [ -z ${response} ]; then - git tag -d "$tag" + if [[ ${response} =~ ^(no|n|N) ]]; then echo "Aborting." + for tag in "${tags_to_deploy[@]}"; do + git tag -d "$tag" + done exit 6 fi @@ -209,9 +244,12 @@ function push_tag { if [ $? -eq 0 ]; then echo echo "------------------------------------------------------------" - echo "Tag added. Pushing tags ..." - echo - git push origin "$tag" + echo + for tag in "${tags_to_deploy[@]}"; do + # Push if everything is ok! + echo "Tag ${bold}${tag}${normal} added. Pushing tag ..." + git push origin "$tag" + done echo echo "============================================================" echo "DEPLOY TAG SUCCESSFULLY ADDED!" diff --git a/deploy-options.sh b/deploy-options.sh index a48a525..d5157b7 100644 --- a/deploy-options.sh +++ b/deploy-options.sh @@ -40,10 +40,9 @@ function deploy_options { echo "| TryOutApps |" echo "--------------" echo - echo "[0] All" - echo "[1] Staging" - echo "[2] UAT" - echo "[3] Production" + echo "[0] Staging" + echo "[1] UAT" + echo "[2] Production" echo echo "==================" echo @@ -51,26 +50,11 @@ function deploy_options { echo "| APP STORE CONNECT |" echo "---------------------" echo - echo "[4] App Store" + echo "[3] App Store" echo read -r -p "Enter number in square brackets: " target_selection - # erase_lines - # Logic for creating first part of the tag. + # Array for creating first part of the tag. # Should be in sync with options shown to the user. - - if [ ${target_selection} -eq 0 ]; then - target="internal-all" - elif [ ${target_selection} -eq 1 ]; then - target="internal-staging" - elif [ ${target_selection} -eq 2 ]; then - target="internal-uat" - elif [ ${target_selection} -eq 3 ]; then - target="internal-production" - elif [ ${target_selection} -eq 4 ]; then - target="appstore" - else - echo "Wrong target index. Aborting..." - exit 4 - fi + environments=("internal-staging" "internal-uat" "internal-production" "appstore") }