Skip to content

Commit

Permalink
config: allow multiple base names
Browse files Browse the repository at this point in the history
  • Loading branch information
tarleb committed Oct 20, 2024
1 parent 54156a6 commit 705bd04
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions scripts/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
usage ()
{
printf 'Generate parameters for GitHub Actions\n\n'
printf 'Usage:\n\t%s <pandoc_version> <build_stack> <image_name>\n' "$0"
printf 'Usage:\n\t%s <pandoc_version> <build_stack> <image_names>\n' "$0"
}

if [ "$#" -ne 3 ]; then
Expand All @@ -13,7 +13,7 @@ fi

version="${1:-main}"
build_stack="${2:-alpine}"
image_name="${3:-pandoc/minimal}"
images="${3}"

versions_file=versions.md
row="$(grep "^| $version " "$versions_file")"
Expand All @@ -34,31 +34,39 @@ field ()
case "${build_stack}" in
(alpine|static)
base_image='alpine'
base_image_tag="$(field 3)"
base_image_version="$(field 3)"
;;
(ubuntu)
base_image='ubuntu'
base_image_tag="$(field 4)"
base_image_version="$(field 4)"
;;
(*)
printf "Unsupported base image: '%s'\n" "$base_image"
;;
esac

printf '%s\n' "$(field 2)"

tagsbase="$(field 2 | sed -e "s#\([^,]*\)#${image_name}:\1#g")"
tags="$(printf '%s' "$tagsbase" | \
sed -e 's#\([^,]*\)#\1-'${base_image}'#g')"
if ( [ "$image_name" != 'pandoc/minimal' ] && \
[ "$build_stack" = 'alpine' ] ) ||
( [ "$image_name" = 'pandoc/minimal' ] && \
[ "$build_stack" = 'static' ] );
then
tags="${tags},${tagsbase}"
fi
version_tags="$(field 2)"
tags=
for name in $(printf '%s\n' "$images" | tr ',' ' '); do
image_tags_base="$( \
printf "$version_tags" | sed -e "s#\([^,]*\)#${name}:\1#g" \
)"
image_tags="$(printf '%s' "$image_tags_base" | \
sed -e 's#\([^,]*\)#\1-'${base_image}'#g')"
image_name=$(printf "$name" | sed -e 's#.*\([^/]\+/[^/]\+\)$#\1#')
if ( [ "$image_name" != 'pandoc/minimal' ] && \
[ "$build_stack" = 'alpine' ] ) ||
( [ "$image_name" = 'pandoc/minimal' ] && \
[ "$build_stack" = 'static' ] );
then
tags="${tags},${image_tags_base},${image_tags}"
else
tags="${tags},${image_tags}"
fi
done
tags=$(printf '%s\n' "$tags" | sed -e 's/^,//')

printf 'tags="%s"\n' "$tags"
printf 'base_image="%s"\n' "$base_image"
printf 'base_image_tag="%s"\n' "$base_image_tag"
printf 'base_image_version="%s"\n' "$base_image_version"
printf 'texlive_version="%s"\n' "$(field 5)"

0 comments on commit 705bd04

Please sign in to comment.