Skip to content

Update Readme.

Update Readme. #245

Workflow file for this run

name: Build and publish to Docker
# Push seems to be triggered for both refs/heads/... and refs/tags/...
# So there is no need to trigger on release: { types: [published] }
on:
push:
jobs:
job:
name: Build and Publish
runs-on: ubuntu-latest
steps:
- name: Checkout the changes
uses: actions/checkout@v3
- name: main
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: |
make test
if [[ -z "$DOCKERHUB_USERNAME" ]] || [[ -z "$DOCKERHUB_PASSWORD" ]]; then
echo "Docker Hub secrets are not configured in this repo, exiting early"
exit 0
fi
unset VERSION
set -eux
if [[ "${GITHUB_REF:?}" == "refs/heads/master" ]]; then
# Master branch -- builds latest image
export VERSION="latest"
elif [[ "${GITHUB_REF:?}" =~ ^refs/heads/v([0-9]+\.[0-9]+(-.*)?)$ ]]; then
# Any vNNN.NNN branch -- builds "test-NNN.NNN" image
# Also allows vNNN.NNN-XXX -- where XXX could be anything (builds test-NNN.NNN-XXX)
export VERSION="test-${BASH_REMATCH[1]}"
elif [[ "${GITHUB_REF:?}" =~ ^refs/tags/v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
# Any vNNN.NNN.NNN tag (not branch!) -- builds "NNN.NNN.NNN" and "NNN.NNN" images
# This means that the two-part version image will always point to latest patch.
export VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]} \
${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
echo "Current content of openmaptiles/__init__.py:"
cat openmaptiles/__init__.py
echo "Updating version in openmaptiles/__init__.py to ${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}"
sed -i -e 's/^__version__ = '"'"'[0-9]\+[.][0-9]\+[.][0-9]\+'"'"'/__version__ = '"'${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}'"'/g' openmaptiles/__init__.py
echo "New content of openmaptiles/__init__.py:"
cat openmaptiles/__init__.py
else
echo "Unrecognized ref ${GITHUB_REF}, no docker images are built or uploaded"
exit 0
fi
echo "Building and publishing tags $VERSION"
echo "Authenticating to Docker Hub..."
echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
function script_cleanup {
docker logout
}
trap script_cleanup EXIT
function push_docker {
for ver in $VERSION; do
docker push openmaptiles/$1:$ver
done
}
df -h .
make build-docker
push_docker openmaptiles-tools
# Github has a very low disk limit, get rid of some data
df -h .
sudo docker system prune --all --force
df -h .
# TODO: fix unavailable image error inside the make target
NO_REFRESH=1 make build-postgis-preloaded
push_docker postgis
push_docker import-data
push_docker postgis-preloaded
df -h .
# The generate-vectortiles docker image often fails build, so leave it as last step
df -h .
sudo docker system prune --all --force
df -h .
make build-generate-vectortiles
push_docker generate-vectortiles