Make recipe .. release handle missing app service

Closes #151
This commit is contained in:
3wc 2021-04-27 19:09:39 +02:00
parent 44b378abba
commit 280238d95d

19
abra
View File

@ -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