Skip to content

Commit

Permalink
Add in-app level parameters for CI & Fastlane
Browse files Browse the repository at this point in the history
  • Loading branch information
opatry committed Sep 30, 2024
1 parent 50239ff commit fd21d24
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/PlayStorePublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
description: "Play Store track"
required: true
type: choice
default: "internal"
default: internal
options:
- internal
- alpha
Expand All @@ -22,6 +22,16 @@ on:
required: true
type: boolean
default: false
in_app_update_level:
description: "In-app update level"
required: true
type: choice
default: none
options:
- none
- feature
- bugfix
- hotfix
tag_repository:
description: "Tag the repository"
required: true
Expand Down
45 changes: 44 additions & 1 deletion _ci/playstore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ origin=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) || exit
available_tracks=("internal" "alpha" "beta" "production")
default_track="${available_tracks[0]}"

# in-app update priority mapping (none: not provided to Fastlane, feature; 1, bugfix: 3, hotfix: 5)
in_app_update_level=("none" "feature" "bugfix" "hotfix")
default_in_app_update_level="${in_app_update_level[0]}"

build_type="release"
flavor="store"

Expand All @@ -30,6 +34,18 @@ check_track() {
fi
}

check_in_app_level() {
# shellcheck disable=SC2076
if [[ ! " ${in_app_update_level[*]} " =~ " ${1} " ]]; then
if [ -n "${2:-}" ]; then
echo -e "${2}"
fi
local in_app_update_level_str="${in_app_update_level[*]}"
# quick & dirty array join by ',' surrounded with quotes
step_error "You must specify the in-app level among: '${GREEN}${in_app_update_level_str// /${RESET}', '${GREEN}}${RESET}'"
fi
}

if ! command -v bundletools &> /dev/null; then
bundletool() {
bundletool_version="1.17.1"
Expand Down Expand Up @@ -63,12 +79,29 @@ publish_aab() {

step "Publishing '${YELLOW}${aab##"${origin}/"}${RESET}' (${BLUE_BOLD}${app_package}${RESET} '${MAGENTA_BOLD}${version_name}${RESET}' #${GREEN_BOLD}${version_code}${RESET}) to '${MAGENTA}${track}${RESET}' track"

case "${update_level}" in
"none") update_level_digit=-1
;;
"feature") update_level_digit=1
;;
"bugfix") update_level_digit=3
;;
"hotfix") update_level_digit=5
;;
*) update_level_digit=-1
;;
esac

supply_args=(
--package_name "${app_package}"
--track "${track}"
--metadata_path "${metadata_path}"
)

if [ ${update_level_digit} -ge 0 ]; then
supply_args+=(--in_app_update_priority "${update_level_digit}")
fi

if [ "${upload_binary}" = true ]; then
supply_args+=(--aab "${aab}")
else
Expand Down Expand Up @@ -104,12 +137,22 @@ if [ $# -eq 0 ] && [ -z "${CI:-}" ] && command -v fzf &> /dev/null; then

upload_binary=$(ask_yn_choice "${MAGENTA_BOLD}Publish App Bundle (AAB) (including associated changelog)?${RESET}")
upload_store_assets=$(ask_yn_choice "${MAGENTA_BOLD}Publish Store assets (descriptions, images & screenshots)?${RESET}")

update_level=$(printf "%s\n" "${in_app_update_level[@]}" \
| fzf --prompt "Choose the in-app level update to use" \
--height ~7 \
--layout=reverse-list \
|| true)
check_in_app_level "${update_level}"
else
track="${1:-"${default_track}"}"
check_track "${track}"

upload_binary=${2:-true}
upload_store_assets=${3:-false}

update_level=${3:-"${default_in_app_update_level}"}
check_in_app_level "${update_level}"
fi

aab="${origin}/../tasks-app-android/build/outputs/bundle/${flavor}${build_type^}/tasks-app-android-${flavor}-${build_type}.aab"
Expand All @@ -128,4 +171,4 @@ cd "${origin}/.."

bundle exec fastlane run validate_play_store_json_key

publish_aab "${aab}" "${track}"
publish_aab "${aab}" "${track}" "${update_level}"

0 comments on commit fd21d24

Please sign in to comment.