Added working auto-tagging

master
Jef Roosens 2021-03-23 10:55:00 +01:00
parent c411fc5d6c
commit e81205bef7
Signed by: Jef Roosens
GPG Key ID: B580B976584B5F30
1 changed files with 10 additions and 10 deletions

18
build
View File

@ -18,22 +18,15 @@ if [[ "$branch" = "master" ]]; then
tags=("$patch_version" "$minor_version" "$major_version" "latest")
elif [[ "$branch" = "develop" ]]; then
tags=("$patch_version-dev" "$minor_version-dev" "$major_version-dev" )
tags=("$patch_version-dev" "$minor_version-dev" "$major_version-dev" "dev")
else
tags=("$branch")
fi
tag_flags=()
for tag in "${tags[@]}"; do
tag_flags+=("-t $1:$tag")
done
# Run the actual build command
docker build $tag_flags .
docker build -t "$1:$tags" .
if [[ "$2" = push ]]; then
[[ "$branch" =~ ^develop|master$ ]] || {
@ -42,7 +35,14 @@ if [[ "$2" = push ]]; then
}
for tag in "${tags[@]}"; do
# Create the tag
docker tag "$1:$tags" "$1:$tag"
# Push the tag
docker push "$1:$tag"
# Remove the tag again, if it's not the main tag
[[ "$tag" != "$tags" ]] && docker rmi "$1:$tag"
done
elif [[ "$2" = run ]]; then