2020-03-21 10:42:13 +03:00
|
|
|
#!/bin/bash
|
2020-05-16 14:28:29 +03:00
|
|
|
|
2020-07-31 22:25:42 +03:00
|
|
|
set -ex
|
2020-03-21 10:42:13 +03:00
|
|
|
|
2020-07-31 21:17:14 +03:00
|
|
|
PLATFORMS="linux/arm/v7,linux/arm64/v8,linux/amd64"
|
2020-07-31 22:25:42 +03:00
|
|
|
DOCKER_IMAGE="shlinkio/shlink"
|
2020-05-05 22:58:23 +03:00
|
|
|
|
2020-07-31 21:17:14 +03:00
|
|
|
# If ref is not develop, then this is a tag. Build that docker tag and also "stable"
|
|
|
|
if [[ "$GITHUB_REF" != *"develop"* ]]; then
|
|
|
|
TAGS="-t ${DOCKER_IMAGE}:${GITHUB_REF#?}"
|
2020-05-07 11:45:53 +03:00
|
|
|
# Push stable tag only if this is not an alpha or beta tag
|
2020-07-31 21:17:14 +03:00
|
|
|
[[ $GITHUB_REF != *"alpha"* && $GITHUB_REF != *"beta"* ]] && TAGS="${TAGS} -t ${DOCKER_IMAGE}:stable"
|
2020-05-15 19:40:20 +03:00
|
|
|
|
2020-05-05 22:58:23 +03:00
|
|
|
docker buildx build --push \
|
2020-07-31 21:17:14 +03:00
|
|
|
--build-arg SHLINK_VERSION=${GITHUB_REF#?} \
|
2020-05-17 10:37:05 +03:00
|
|
|
--platform ${PLATFORMS} \
|
2020-05-15 19:40:20 +03:00
|
|
|
${TAGS} .
|
|
|
|
|
2020-07-31 21:17:14 +03:00
|
|
|
# If build branch is develop, build latest
|
|
|
|
elif [[ "$GITHUB_REF" == *"develop"* ]]; then
|
2020-05-05 22:58:23 +03:00
|
|
|
docker buildx build --push \
|
2020-05-17 10:37:05 +03:00
|
|
|
--platform ${PLATFORMS} \
|
2020-05-17 11:19:54 +03:00
|
|
|
-t ${DOCKER_IMAGE}:latest .
|
2020-03-21 10:42:13 +03:00
|
|
|
fi
|