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