From 883ede9e8454b821c97ca571f68eecfd2b238767 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Mon, 8 Jan 2018 23:38:54 +0100 Subject: [PATCH] Add auto-update Signed-off-by: Knut Ahlers --- .gitignore | 1 + .travis.yml | 7 ++++++ build.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 2 +- 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100755 build.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ca78288 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +jq diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d66ce60 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +sudo: required + +services: + - docker + +script: + - bash build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..3f4db01 --- /dev/null +++ b/build.sh @@ -0,0 +1,60 @@ +#!/bin/bash +set -euo pipefail + +HOST_OS=$(uname -s) + +### ---- ### + +echo "Switch back to master" +git checkout master +git reset --hard origin/master + +### ---- ### + +if ! [ -e jq ]; then + echo "Loading local copy of jq-1.5" + + case ${HOST_OS} in + Linux) + curl -sSLo ./jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 + ;; + Darwin) + curl -sSLo ./jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-osx-amd64 + ;; + *) + echo "/!\\ Unable to download jq for ${HOST_OS}" + exit 1 + ;; + esac + + chmod +x jq +fi + +### ---- ### + +echo "Fetching latest version number of awscli" + +CURATOR_VERSION=$(curl -sSL https://pypi.python.org/pypi/elasticsearch-curator/json | ./jq -r .info.version) + +if ( git tag -l ${CURATOR_VERSION} | grep -q ${CURATOR_VERSION} ); then + echo "/!\\ Already got a tag for version ${CURATOR_VERSION}, stopping now" + exit 0 +fi + +echo "Writing requirements.txt" +echo "elasticsearch-curator==${CURATOR_VERSION}" > requirements.txt + +### ---- ### + +echo "Testing build..." +docker build . + +### ---- ### + +echo "Updating repository..." +git add requirements.txt +git -c user.name='Travis Automated Update' -c user.email='travis@luzifer.io' \ + commit -m "elasticsearch-curator ${CURATOR_VERSION}" +git tag ${CURATOR_VERSION} + +git push -q https://auth:${GH_TOKEN}@github.com/luzifer-docker/curator master --tags diff --git a/requirements.txt b/requirements.txt index d8c9c45..e2a899f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -elasticsearch-curator==5.4.1 +elasticsearch-curator==5.4.0