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