Skip to content

Commit

Permalink
Improve release scripts
Browse files Browse the repository at this point in the history
- validate remote points at upstream
- push to release branch instead of master
  • Loading branch information
errordeveloper committed Aug 22, 2019
1 parent 66c210f commit 67c6ea9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
21 changes: 15 additions & 6 deletions tag-release-candidate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@ if ! [[ "${release_branch}" =~ ^release-[0-9]+\.[0-9]+$ ]] ; then
exit 3
fi

if git remote get-url origin | grep -v "[email protected]:weaveworks/eksctl" ; then
echo "Invalid origin: $(git remote get-url origin)"
exit 3
if

function branch_exists() {
git ls-remote --heads [email protected]:weaveworks/eksctl.git "${1}" | grep "${1}" >/dev/null
git ls-remote --heads origin "${1}" | grep -q "${1}"
}

function current_branch() {
git rev-parse --abbrev-ref @
}

if ! branch_exists "${release_branch}" ; then
git checkout master
if [ ! "$(git rev-parse --abbrev-ref @)" = master ] ; then
if [ ! "$(current_branch)" = master ] ; then
echo "Must be on master branch"
exit 4
fi
Expand All @@ -45,7 +54,7 @@ fi
# origin and fast-forwarding the local branch:
git fetch origin "${release_branch}"
git checkout "${release_branch}"
if [ ! "$(git rev-parse --abbrev-ref @)" = "${release_branch}" ] ; then
if [ ! "$(current_branch)" = "${release_branch}" ] ; then
echo "Must be on ${release_branch} branch"
exit 5
fi
Expand All @@ -69,10 +78,10 @@ m="Tag ${v} release candidate"

git commit --message "${m}"

git fetch --force --tags [email protected]:weaveworks/eksctl
git fetch --force --tags origin

git push [email protected]:weaveworks/eksctl master
git push origin "${release_branch}"

git tag --annotate --message "${m}" "${v}"

git push --force --tags [email protected]:weaveworks/eksctl
git push --force --tags origin
26 changes: 18 additions & 8 deletions tag-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -o errexit
set -o pipefail
set -o nounset


if [ "$#" -ne 1 ] ; then
echo "Usage: ${0} <tag>"
exit 1
Expand All @@ -22,15 +23,24 @@ if ! [[ "${release_branch}" =~ ^release-[0-9]+\.[0-9]+$ ]] ; then
exit 3
fi

if git remote get-url origin | grep -v "[email protected]:weaveworks/eksctl" ; then
echo "Invalid origin: $(git remote get-url origin)"
exit 3
if

function branch_exists() {
git ls-remote --heads [email protected]:weaveworks/eksctl.git "${1}" | grep "${1}" >/dev/null
git ls-remote --heads "${origin}" "${1}" | grep -q "${1}"
}

function current_branch() {
git rev-parse --abbrev-ref @
}

if ! branch_exists "${release_branch}" ; then
git checkout master
if [ ! "$(git rev-parse --abbrev-ref @)" = master ] ; then
if [ ! "$(current_branch)" = master ] ; then
echo "Must be on master branch"
exit 4
exit 7
fi
# Ensure local master is up-to-date by pulling its latest version from origin
# and fast-forwarding local master:
Expand All @@ -44,7 +54,7 @@ fi
# origin and fast-forwarding the local branch:
git fetch origin "${release_branch}"
git checkout "${release_branch}"
if [ ! "$(git rev-parse --abbrev-ref @)" = "${release_branch}" ] ; then
if [ ! "$(current_branch)" = "${release_branch}" ] ; then
echo "Must be on ${release_branch} branch"
exit 5
fi
Expand All @@ -68,15 +78,15 @@ m="Tag ${v} release"

git commit --message "${m}"

git fetch --force --tags [email protected]:weaveworks/eksctl
git fetch --force --tags origin

git push [email protected]:weaveworks/eksctl master
git push origin "${release_branch}"

# Update the site by putting everything from master into the docs branch
git push -f origin master:docs
git push --force origin "${release_branch}":docs

# Create the release tag and push it to start release process
git tag --annotate --message "${m}" --force "latest_release"
git tag --annotate --message "${m}" "${v}"

git push --force --tags [email protected]:weaveworks/eksctl
git push --force --tags origin

0 comments on commit 67c6ea9

Please sign in to comment.