Add automatic updating for vault version

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2017-10-02 12:58:05 +02:00
parent aa229f414d
commit 3e4ccd8c7a
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
3 changed files with 48 additions and 2 deletions

7
.travis.yml Normal file
View file

@ -0,0 +1,7 @@
sudo: required
services:
- docker
script:
- bash update-version.sh

View file

@ -2,8 +2,8 @@ FROM alpine
LABEL maintainer "Knut Ahlers <knut@luzifer.io>"
ENV VAULT_VERSION=0.8.1 \
VAULT_HASH=3c4d70ba71619a43229e65c67830e30e050eab7a81ac6b28325ff707e5914188
ENV VAULT_VERSION 0.8.1
ENV VAULT_HASH 3c4d70ba71619a43229e65c67830e30e050eab7a81ac6b28325ff707e5914188
ADD https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip /tmp/vault.zip

39
update-version.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/bash
set -e
set -o pipefail
### ---- ###
echo "Switch back to master"
git checkout master
git reset --hard origin/master
### ---- ###
echo "Fetching latest version..."
LATEST=$(curl -sSLf 'https://latest.luzifer.io/catalog-api/vault/latest.txt?p=version')
echo "Getting SHA256SUM for Linux AMD64 version..."
SHASUM=$(curl -s https://releases.hashicorp.com/vault/${LATEST}/vault_${LATEST}_SHA256SUMS | awk '/linux_amd64/{print $1}')
echo "Testing availability of archive 'vault_${LATEST}_linux_amd64.zip'..."
curl -sSLIfo /dev/null https://releases.hashicorp.com/vault/${LATEST}/vault_${LATEST}_linux_amd64.zip
echo "Found version ${LATEST}, patching..."
sed -i "s/ENV VAULT_VERSION .*$/ENV VAULT_VERSION ${LATEST}/" Dockerfile
sed -i "s/ENV VAULT_HASH .*$/ENV VAULT_HASH ${SHASUM}/" Dockerfile
echo "Checking for changes..."
git diff --exit-code && exit 0
echo "Testing build..."
docker build .
echo "Updating repository..."
git add Dockerfile
git -c user.name='Travis Automated Update' -c user.email='travis@luzifer.io' \
commit -m "Vault ${LATEST}"
git tag ${LATEST}
git push -q https://${GH_USER}:${GH_TOKEN}@github.com/luzifer-docker/vault.git master --tags