diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +build/ diff --git a/README.md b/README.md index 2f1be04..484c260 100644 --- a/README.md +++ b/README.md @@ -225,3 +225,19 @@ Push to osgeo repository: ```shell docker push geoserver-docker.osgeo.org/geoserver:2.21.1 ``` + +### How to automate release? + +For CI purposes, the script in the `build` folder is used to simplify those steps. + +The variables `DOCKERUSER` and `DOCKERPASSWORD` have to be set with valid credentials before this script can push the image to the osgeo repo. + +You need to pass the version as first and the type as second argument, where type has to be one of `build`, `publish` or `buildandpublish`. + +Examples: + +`./release.sh 2.22.1 build` + +`./release.sh 2.22.0 publish` + +`./release.sh 2.22.1 buildandpublish` diff --git a/build/release.sh b/build/release.sh new file mode 100755 index 0000000..6d9814c --- /dev/null +++ b/build/release.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# error out if any statements fail +set -e + +function usage() { + echo "$0 [options] " + echo " version : The released version to build an docker image for (eg: 2.1.4)" + echo " mode : The mode. Choose one of 'build', 'publish' or 'buildandpublish'" +} + +if [ -z $1 ] || [ -z $2 ] || [[ $2 != "build" && $2 != "publish" && $2 != "buildandpublish" ]]; then + usage + exit +fi + +VERSION=$1 +TAG=geoserver-docker.osgeo.org/geoserver:$VERSION + +# Go up one level to the Dockerfile +cd ".." + +if [ $2 != "publish" ]; then + echo "Building GeoServer Docker Image..." + echo "docker build --build-arg GS_VERSION=$VERSION -t $TAG ." + docker build --build-arg GS_VERSION=$VERSION -t $TAG . +fi + +if [ $2 != "build" ]; then + echo "Publishing GeoServer Docker Image..." + echo $DOCKERPASSWORD | docker login -u $DOCKERUSER --password-stdin geoserver-docker.osgeo.org + echo "docker push $TAG" + docker push $TAG +fi