From 280238d95d8934f6db0f5efa952962ceca983ba4 Mon Sep 17 00:00:00 2001 From: 3wc <3wc.git@doesthisthing.work> Date: Tue, 27 Apr 2021 19:09:39 +0200 Subject: [PATCH] Make `recipe .. release` handle missing `app` service Closes #151 --- abra | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/abra b/abra index f477fb8..92f213c 100755 --- a/abra +++ b/abra @@ -2020,6 +2020,20 @@ sub_recipe_release() { for compose_file in "${compose_files[@]}"; do mapfile -t services < <($YQ e -N '.services | keys | .[]' "$compose_file" | sort -u) + if ! printf '%s\0' "${services[@]}" | grep -Fqxz -- "app"; then + # shellcheck disable=SC2016 + warning 'No `app` service found; which one should we use for the version number?' + select service_item in "${services[@]##*/}"; do + if [ 1 -le "$REPLY" ] && [ "$REPLY" -le ${#services[@]} ]; then + main_service="$service_item" + success "Selected ${service_item} as main service" + break + fi + done + else + main_service="app" + fi + for service in "${services[@]}"; do # 3wc: skip the "app" service unless we're in compose.yml; this service is # often repeated in other compose.*.yml files to extend options, but we only @@ -2041,7 +2055,7 @@ sub_recipe_release() { fi if [ -z "$latest_version" ] || [ "$force" = "true" ] || [ "$service_tag" != "$latest_tag" ]; then - if [ "$service" = "app" ]; then + if [ "$service" = "$main_service" ]; then new_version="$service_tag" fi info "Fetching $service_image metadata from Docker Hub" @@ -2063,8 +2077,7 @@ sub_recipe_release() { done if [ "$new_version" = "false" ]; then - - # `app` tag hasn't changed, just bump release + # $main_service tag hasn't changed, just bump release if echo "$latest_version" | grep -q '_'; then latest_version_minor="${latest_version##*_}" else