mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2024-12-26 19:08:23 +01:00
ci: unbrick incremental tags
This commit is contained in:
parent
bd6d956518
commit
d03fb43532
28
build.sh
28
build.sh
@ -1,10 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eoux pipefail
|
set -eoux pipefail
|
||||||
|
|
||||||
if [[ -z ${1:-} ]] && [[ -n ${CI:-} ]]; then
|
if [[ -z ${1:-} && -n ${CI:-} ]]; then
|
||||||
echo 'Usage: ./build.sh VERSION_SHORT'
|
echo 'Usage: ./build.sh VERSION_SHORT'
|
||||||
exit 1
|
exit 1
|
||||||
elif [[ ${CI:-} == true ]] || [[ -n ${1:-} ]]; then
|
elif [[ ${CI:-} == true || -n ${1:-} ]]; then
|
||||||
VERSION_SHORT="$1"
|
VERSION_SHORT="$1"
|
||||||
else
|
else
|
||||||
VERSION_SHORT=$(find . -maxdepth 1 -type d | sort | tail -1 | grep -o "[[0-9]].[[0-9]]*")
|
VERSION_SHORT=$(find . -maxdepth 1 -type d | sort | tail -1 | grep -o "[[0-9]].[[0-9]]*")
|
||||||
@ -21,16 +21,14 @@ if [[ ${TRAVIS_PULL_REQUEST:-} == true ]]; then
|
|||||||
else
|
else
|
||||||
if [[ -n ${CI:-} ]]; then
|
if [[ -n ${CI:-} ]]; then
|
||||||
# we are either on master or on a tag build
|
# we are either on master or on a tag build
|
||||||
if [[ ${TRAVIS_BRANCH:-} == master ]] || [[ ${TRAVIS_BRANCH:-} == "$VERSION" ]]; then
|
if [[ ${TRAVIS_BRANCH:-} == master || ${TRAVIS_BRANCH:-} == "$VERSION" ]]; then
|
||||||
TAGS="-t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
TAGS="-t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
||||||
# we are on an incremental build of a tag
|
# we are on an incremental build of a tag
|
||||||
elif [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then
|
elif [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then
|
||||||
TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH -t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH -t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
|
||||||
# we build a other branch than master
|
# we build a other branch than master and exclude dependabot branches from tags cause the / is not supported by docker
|
||||||
# disabled for now cause it breaks Travis CI builds of dependabot
|
elif [[ -n ${TRAVIS_BRANCH:-} && $TRAVIS_BRANCH =~ "/" ]]; then
|
||||||
# https://travis-ci.org/github/factoriotools/factorio-docker/jobs/688176474#L182
|
TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH"
|
||||||
# elif [[ -n $TRAVIS_BRANCH ]]; then
|
|
||||||
# TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# we are not in CI and tag version and version short
|
# we are not in CI and tag version and version short
|
||||||
@ -61,7 +59,7 @@ fi
|
|||||||
|
|
||||||
# only push when:
|
# only push when:
|
||||||
# or we build a tag and we don't build a PR
|
# or we build a tag and we don't build a PR
|
||||||
if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ ${TRAVIS_PULL_REQUEST_BRANCH:-} == "" ]] ||
|
if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" && ${TRAVIS_PULL_REQUEST_BRANCH:-} == "" ]] ||
|
||||||
# or we are not in CI
|
# or we are not in CI
|
||||||
[[ -z ${CI:-} ]]; then
|
[[ -z ${CI:-} ]]; then
|
||||||
|
|
||||||
@ -69,12 +67,10 @@ if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ ${TRAVIS_PULL_REQUEST_BR
|
|||||||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# push a tag on a branch other than master
|
# push a tag on a branch other than master except dependabot branches cause docker does not support /
|
||||||
# disabled for now cause it breaks Travis CI builds of dependabot
|
if [[ -n ${TRAVIS_BRANCH:-} && $VERSION != "${TRAVIS_BRANCH_VERSION:-}" && ${TRAVIS_BRANCH:-} != "master" && ${TRAVIS_BRANCH:-} =~ "/" ]]; then
|
||||||
# https://travis-ci.org/github/factoriotools/factorio-docker/jobs/688176474#L182
|
docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
|
||||||
# if [[ -n ${TRAVIS_BRANCH:-} ]] && [[ $VERSION != "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ ${TRAVIS_BRANCH:-} != "master" ]]; then
|
fi
|
||||||
# docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# push an incremental tag
|
# push an incremental tag
|
||||||
# eg 0.18.24-1
|
# eg 0.18.24-1
|
||||||
@ -83,7 +79,7 @@ if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ ${TRAVIS_PULL_REQUEST_BR
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# only push on tags or when manually running the script
|
# only push on tags or when manually running the script
|
||||||
if [[ -n ${TRAVIS_TAG:-} ]] || [[ -z ${CI:-} ]]; then
|
if [[ -n ${TRAVIS_TAG:-} || -z ${CI:-} ]]; then
|
||||||
docker push "$DOCKER_REPO:$VERSION"
|
docker push "$DOCKER_REPO:$VERSION"
|
||||||
docker push "$DOCKER_REPO:$VERSION_SHORT"
|
docker push "$DOCKER_REPO:$VERSION_SHORT"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user