Reliability improvements to recipe .. release

This commit is contained in:
3wc 2021-04-05 11:26:07 +02:00
parent a261114bbc
commit 103a4941c7

25
abra
View File

@ -541,9 +541,11 @@ require_app (){
error "Could not retrieve app type '$APP', this app type doesn't exist?"
fi
cd "$APP_DIR" && checkout_main_or_master
if [[ $(cd "$ABRA_DIR/apps/$APP" && git branch --list | wc -l) == "0" ]]; then
debug "Failed to clone default branch, guessing alternative is 'main'"
(cd "$ABRA_DIR/apps/$APP" && git checkout main > /dev/null 2>&1)
(cd "$ABRA_DIR/apps/$APP" && git checkout main)
fi
success "Fetched app configuration via Git"
@ -611,6 +613,10 @@ require_yq() {
vendor_binary "https://github.com/mikefarah/yq" "v4.6.1" "yq_linux_amd64"
}
checkout_main_or_master() {
git checkout main > /dev/null 2>&1 || git checkout master > /dev/null 2>&1
}
# FIXME 3wc: update or remove
if [ -z "$ABRA_ENV" ] && [ -f .env ] && type direnv > /dev/null 2>&1 && ! direnv status | grep -q 'Found RC allowed true'; then
error "direnv is blocked, run direnv allow"
@ -629,7 +635,7 @@ get_recipe_versions() {
recipe="${1?Recipe not set}"
mapfile -t RECIPE_VERSIONS < <($JQ -r ".${recipe}.versions | keys | .[]" "$ABRA_APPS_JSON" | sort)
mapfile -t RECIPE_VERSIONS < <($JQ -r ".\"${recipe}\".versions | keys | .[]" "$ABRA_APPS_JSON" | sort)
}
###### Run-time loading
@ -1871,7 +1877,7 @@ sub_recipe_versions() {
printf "%s thrilling versions of $abra__recipe_:\n" "${#RECIPE_VERSIONS[@]}"
for version in "${RECIPE_VERSIONS[@]}"; do
recipe_version_data=$($JQ -r ".${abra__recipe_}.versions.\"${version}\"" "$ABRA_APPS_JSON")
recipe_version_data=$($JQ -r ".\"${abra__recipe_}\".versions.\"${version}\"" "$ABRA_APPS_JSON")
mapfile -t services < <(echo "$recipe_version_data" | $JQ -r ". | keys | .[]" -)
printf '%s:\n' "$version"
for service in "${services[@]}"; do
@ -1914,7 +1920,7 @@ sub_recipe_release() {
info "Latest available version: '$latest_version'"
else
latest_version=""
latest_version_message=""
latest_version_message="Initial tagged release"
info "No previous releases found"
fi
@ -1923,6 +1929,14 @@ sub_recipe_release() {
error "$recipe is already on $current_tag, no release needed"
fi
if [ "$(git rev-parse --abbrev-ref --symbolic-full-name HEAD)" = "HEAD" ]; then
warning "It looks like $recipe_dir is in 'detached HEAD' state"
read -rp "Check out main/master branch first? [Y/n] "
if [ "${choice,,}" != "n" ]; then
checkout_main_or_master
fi
fi
mapfile -t extra_compose_files < <(ls -- compose.*.yml 2> /dev/null || true)
compose_files=("compose.yml" "${extra_compose_files[@]}")
@ -1948,7 +1962,7 @@ sub_recipe_release() {
service_tag="${service_image##*:}"
if [ -n "$latest_version" ]; then
latest_data=$($JQ ".$recipe.versions.\"$latest_version\".\"$service\"" "$ABRA_APPS_JSON")
latest_data=$($JQ ".\"$recipe\".versions.\"$latest_version\".\"$service\"" "$ABRA_APPS_JSON")
latest_tag="$(echo "$latest_data" | $JQ -r ".tag" -)"
fi
@ -1975,6 +1989,7 @@ sub_recipe_release() {
done
if [ "$new_version" = "false" ]; then
# `app` tag hasn't changed, just bump release
if echo "$latest_version" | grep -q '_'; then
latest_version_minor="${latest_version##*_}"