Compare commits

...

18 Commits

4 changed files with 45 additions and 31 deletions

View File

@ -16,11 +16,12 @@ jobs:
- bash -c 'shopt -s globstar; shellcheck **/*.sh' - bash -c 'shopt -s globstar; shellcheck **/*.sh'
- &build - &build
stage: build stage: build
# set EXTRA_TAG to latest,stable when no more experimental versions for 0.17 come out
env: VERSION_SHORT=0.17 EXTRA_TAG=latest env: VERSION_SHORT=0.17 EXTRA_TAG=latest
script: script:
- ./build.sh $VERSION_SHORT - ./build.sh $VERSION_SHORT
- <<: *build - <<: *build
env: VERSION_SHORT=0.16 EXTRA_TAG=stable env: VERSION_SHORT=0.16
- <<: *build - <<: *build
env: VERSION_SHORT=0.15 env: VERSION_SHORT=0.15
- <<: *build - <<: *build

View File

@ -9,8 +9,8 @@ ARG PGID=845
ENV PORT=34197 \ ENV PORT=34197 \
RCON_PORT=27015 \ RCON_PORT=27015 \
VERSION=0.17.67 \ VERSION=0.17.74 \
SHA1=e23c4be62d1715c57fa3a6a97bc443c7af0f9af1 \ SHA1=ed275564687e91bed3a969ddf8907560c9cfe431 \
SAVES=/factorio/saves \ SAVES=/factorio/saves \
CONFIG=/factorio/config \ CONFIG=/factorio/config \
MODS=/factorio/mods \ MODS=/factorio/mods \

View File

@ -1,7 +1,8 @@
# Factorio [![Build Status](https://travis-ci.org/factoriotools/factorio-docker.svg?branch=master)](https://travis-ci.org/factoriotools/factorio-docker) [![Docker Version](https://images.microbadger.com/badges/version/factoriotools/factorio.svg)](https://hub.docker.com/r/factoriotools/factorio/) [![Docker Pulls](https://img.shields.io/docker/pulls/factoriotools/factorio.svg?maxAge=600)](https://hub.docker.com/r/factoriotools/factorio/) [![Docker Stars](https://img.shields.io/docker/stars/factoriotools/factorio.svg?maxAge=600)](https://hub.docker.com/r/factoriotools/factorio/) [![Microbadger Layers](https://images.microbadger.com/badges/image/factoriotools/factorio.svg)](https://microbadger.com/images/factoriotools/factorio "Get your own image badge on microbadger.com") # Factorio [![Build Status](https://travis-ci.org/factoriotools/factorio-docker.svg?branch=master)](https://travis-ci.org/factoriotools/factorio-docker) [![Docker Version](https://images.microbadger.com/badges/version/factoriotools/factorio.svg)](https://hub.docker.com/r/factoriotools/factorio/) [![Docker Pulls](https://img.shields.io/docker/pulls/factoriotools/factorio.svg?maxAge=600)](https://hub.docker.com/r/factoriotools/factorio/) [![Docker Stars](https://img.shields.io/docker/stars/factoriotools/factorio.svg?maxAge=600)](https://hub.docker.com/r/factoriotools/factorio/) [![Microbadger Layers](https://images.microbadger.com/badges/image/factoriotools/factorio.svg)](https://microbadger.com/images/factoriotools/factorio "Get your own image badge on microbadger.com")
* `0.17.67`, `0.17`, `latest` [(0.17/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.17/Dockerfile) * `0.17.74`, `0.17`, `latest` [(0.17/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.17/Dockerfile)
* `0.16.51`, `0.16`, `stable` [(0.16/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.16/Dockerfile) * `0.17.74` `stable` [(0.17/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.17/Dockerfile)
* `0.16.51`, `0.16` [(0.16/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.16/Dockerfile)
* `0.15.40`, `0.15` [(0.15/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.15/Dockerfile) * `0.15.40`, `0.15` [(0.15/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.15/Dockerfile)
* `0.14.23`, `0.14` [(0.14/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.14/Dockerfile) * `0.14.23`, `0.14` [(0.14/Dockerfile)](https://github.com/factoriotools/factorio-docker/blob/master/0.14/Dockerfile)
@ -22,7 +23,7 @@ You will be mining resources, researching technologies, building infrastructure,
The game is very stable and optimized for building massive factories. You can create your own maps, write mods in Lua or play with friends via Multiplayer. The game is very stable and optimized for building massive factories. You can create your own maps, write mods in Lua or play with friends via Multiplayer.
NOTE: This is only the server. The game is available at [factorio.com](https://www.factorio.com) and [Steam](http://store.steampowered.com/app/427520/). NOTE: This is only the server. The full game is available at [Factorio.com](https://www.factorio.com), [Steam](https://store.steampowered.com/app/427520/), [GOG.com](https://www.gog.com/game/factorio) and [Humble Bundle](https://www.humblebundle.com/store/factorio).
# Usage # Usage

View File

@ -2,9 +2,9 @@
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 ]]; 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]]*")
@ -16,61 +16,73 @@ cd "$VERSION_SHORT" || exit 1
VERSION=$(grep -oP '[0-9]+\.[0-9]+\.[0-9]+' Dockerfile | head -1) VERSION=$(grep -oP '[0-9]+\.[0-9]+\.[0-9]+' Dockerfile | head -1)
DOCKER_REPO=factoriotools/factorio DOCKER_REPO=factoriotools/factorio
if [[ $TRAVIS_PULL_REQUEST == true ]]; then if [[ ${TRAVIS_PULL_REQUEST:-} == true ]]; then
TAGS="$DOCKER_REPO:$TRAVIS_PULL_REQUEST_SLUG" TAGS="$DOCKER_REPO:$TRAVIS_PULL_REQUEST_SLUG"
else else
# we are either on master or on a tag build if [[ -n ${CI:-} ]]; then
if [[ $TRAVIS_BRANCH == master ]] || [[ $TRAVIS_BRANCH == "$VERSION" ]]; then # we are either on master or on a tag build
TAGS="$DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT" if [[ $TRAVIS_BRANCH == master ]] || [[ $TRAVIS_BRANCH == "$VERSION" ]]; then
# we are on an incremental build of a tag TAGS="-t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
elif [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then # we are on an incremental build of a tag
TAGS="$DOCKER_REPO:$TRAVIS_BRANCH -t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT" elif [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then
# we build a other branch than master TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH -t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
elif [[ -n $TRAVIS_BRANCH ]]; then # we build a other branch than master
TAGS="$DOCKER_REPO:$TRAVIS_BRANCH" elif [[ -n $TRAVIS_BRANCH ]]; then
# we are not in CI and tag version and version short TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH"
elif [[ $CI == "" ]]; then fi
TAGS="$DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT" else
# we are not in CI and tag version and version short
TAGS="-t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
fi fi
if [[ -n ${EXTRA_TAG:-} ]]; then if [[ -n ${EXTRA_TAG:-} ]]; then
TAGS="$TAGS -t $DOCKER_REPO:$EXTRA_TAG" IFS=","
for TAG in $EXTRA_TAG; do
TAGS+=" -t $DOCKER_REPO:$EXTRA_TAG"
done
fi fi
fi fi
# shellcheck disable=SC2086 # shellcheck disable=SC2068
docker build . -t $TAGS eval docker build . ${TAGS[@]}
docker images docker images
if [[ ${TRAVIS_BRANCH:-} ]]; then
TRAVIS_BRANCH_VERSION=${TRAVIS_BRANCH%-*}
fi
# only push when: # only push when:
# latest changes where made in the folder corosponding to the version we build, we are on master and don#t build a PR. # latest changes where made in the folder corosponding to the version we build, we are on master and don#t build a PR.
if [[ $(dirname "$(git diff --name-only HEAD^)") =~ $VERSION_SHORT ]] && [[ $TRAVIS_BRANCH == master ]] && [[ $TRAVIS_PULL_REQUEST_BRANCH == "" ]] || if [[ $(dirname "$(git diff --name-only HEAD^)") =~ $VERSION_SHORT ]] && [[ $TRAVIS_BRANCH == master ]] && [[ $TRAVIS_PULL_REQUEST_BRANCH == "" ]] ||
# we build a tag and we are not on master # we build a tag and we are not on master
[[ $VERSION == "${TRAVIS_BRANCH%-*}" ]] && [[ $TRAVIS_PULL_REQUEST_BRANCH == "" ]] || [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ $TRAVIS_PULL_REQUEST_BRANCH == "" ]] ||
# we are not in CI # we are not in CI
[[ $CI == "" ]]; then [[ -z ${CI:-} ]]; then
if [[ $CI == true ]]; then if [[ ${CI:-} == true ]]; then
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
if [[ -n $TRAVIS_BRANCH ]] && [[ $VERSION != "${TRAVIS_BRANCH%-*}" ]] && [[ $TRAVIS_BRANCH != "master" ]]; then if [[ -n ${TRAVIS_BRANCH:-} ]] && [[ $VERSION != "${TRAVIS_BRANCH_VERSION:-}" ]] && [[ ${TRAVIS_BRANCH:-} != "master" ]]; then
docker push "$DOCKER_REPO:$TRAVIS_BRANCH" docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
fi fi
# push an incremental tag # push an incremental tag
if [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]]; then
docker push "$DOCKER_REPO:$TRAVIS_BRANCH" docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
fi fi
if [[ -n $TRAVIS_TAG ]] || [[ $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
if [[ -n ${EXTRA_TAG:-} ]]; then if [[ -n ${EXTRA_TAG:-} ]]; then
docker push "$DOCKER_REPO:$EXTRA_TAG" IFS=","
for TAG in $EXTRA_TAG; do
docker push "$DOCKER_REPO:$TAG"
done
fi fi
curl -X POST https://hooks.microbadger.com/images/factoriotools/factorio/TmmKGNp8jKcFqZvcJhTCIAJVluw= curl -X POST https://hooks.microbadger.com/images/factoriotools/factorio/TmmKGNp8jKcFqZvcJhTCIAJVluw=