From fd21d241452949a96dfdc2b259d8d851078bf92f Mon Sep 17 00:00:00 2001 From: Olivier Patry Date: Mon, 30 Sep 2024 18:31:24 +0200 Subject: [PATCH] Add in-app level parameters for CI & Fastlane --- .github/workflows/PlayStorePublish.yml | 12 ++++++- _ci/playstore.sh | 45 +++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/.github/workflows/PlayStorePublish.yml b/.github/workflows/PlayStorePublish.yml index 87804f36..7e4a5aea 100644 --- a/.github/workflows/PlayStorePublish.yml +++ b/.github/workflows/PlayStorePublish.yml @@ -6,7 +6,7 @@ on: description: "Play Store track" required: true type: choice - default: "internal" + default: internal options: - internal - alpha @@ -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 diff --git a/_ci/playstore.sh b/_ci/playstore.sh index 9de55f51..ca9678a9 100755 --- a/_ci/playstore.sh +++ b/_ci/playstore.sh @@ -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" @@ -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" @@ -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 @@ -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" @@ -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}"