Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script for aiming tedious tasks for a new minor consul release #126

Merged
merged 1 commit into from
Jan 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions 0.6/consul/update_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

set -eo pipefail
[[ "$TRACE" ]] && set -x || :

debug() {
[[ "$DEBUG" ]] && echo "-----> $*" 1>&2
}

consul_version() {
sed -n "s/ENV CONSUL_VERSION //p" Dockerfile
}

next_version() {
debug "new version will be calculated ..."
local oldVersion=$(consul_version)
debug "oldVersion: $oldVersion"
echo ${oldVersion%.*}.$((${oldVersion##*.} + 1))
}

update_dockerfile() {
declare ver=${1:? required}

local sha=$(curl -Ls https://releases.hashicorp.com/consul/${ver}/consul_${ver}_SHA256SUMS | sed -n "s/ .*linux_amd64.*//p")
debug "sha=$sha"

sed -i "s/\(ENV CONSUL_VERSION\) .*/\1 $newVersion/;s/\(ENV CONSUL_SHA256\) .*/\1 $sha/" Dockerfile
}

main() {
declare desc="Updates Dockerfile url/sha for the provided version, or calculates next patch version if called without params"
declare newVersion=${1:-$(next_version)}

debug "newVersion=$newVersion"
update_dockerfile $newVersion
git diff
echo "=====> Now you can run: git commit -am 'Upgrade Consul to $newVersion'"
}

[[ "$0" == "$BASH_SOURCE" ]] && main "$@" || :