Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Commit

Permalink
Small improvements to the release script
Browse files Browse the repository at this point in the history
Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot committed Dec 28, 2015
1 parent 93bc358 commit 3b0f2b0
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 61 deletions.
107 changes: 50 additions & 57 deletions script/release.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
#!/bin/bash

#Put your github username here, while testing performing new releases
#GITHUB_USER=jeanlaurent
GITHUB_USER=docker
GITHUB_REPO=machine
PROJECT_URL="git@github.com:${GITHUB_USER}/${GITHUB_REPO}"

function usage {
echo "Usage: "
echo " GITHUB_TOKEN=XXXXX release/release.sh 0.5.x"
echo " GITHUB_TOKEN=XXXXX ${0} 0.5.x"
}

function display {
echo "🐳 $1"
echo ""
echo
}

function checkError {
if [[ "$?" -ne 0 ]]; then
echo "😡 $1"
if [[ "$2" == "showUsage" ]]; then
usage
fi
exit 1
fi
}
Expand All @@ -30,41 +26,43 @@ function createMachine {
docker-machine create -d virtualbox --virtualbox-cpu-count=2 --virtualbox-memory=2048 release
}

VERSION=$1
GITHUB_VERSION="v${VERSION}"
PROJECT_URL="git@github.com:${GITHUB_USER}/${GITHUB_REPO}"
if [[ -z "${GITHUB_TOKEN}" ]]; then
echo "GITHUB_TOKEN missing"
usage
exit 1
fi

RELEASE_DIR="$(git rev-parse --show-toplevel)/../release-${VERSION}"
GITHUB_RELEASE_FILE="github-release-${VERSION}.md"
VERSION=$1

if [[ -z "${VERSION}" ]]; then
#TODO: Check version is well formed
echo "Missing version argument"
usage
exit 1
fi

if [[ -z "${GITHUB_TOKEN}" ]]; then
echo "GITHUB_TOKEN missing"
usage
if [[ ! "${VERSION}" =~ ^[0-9]\.[0-9](\.[0-9])?(-rc[1-9][0-9]*)?$ ]]; then
echo "Invalid version. It should look like 0.5.1, 0.6 or 0.5.1-rc2"
exit 1
fi

command -v git > /dev/null 2>&1
checkError "You obviously need git, please consider installing it..." "showUsage"
checkError "You obviously need git, please consider installing it..."

command -v github-release > /dev/null 2>&1
checkError "github-release is not installed, go get -u github.com/aktau/github-release or check https://github.com/aktau/github-release, aborting." "showUsage"
checkError "github-release is not installed, go get -u github.com/aktau/github-release or check https://github.com/aktau/github-release, aborting."

command -v openssl > /dev/null 2>&1
checkError "You need openssl to generate binaries signature, brew install it, aborting." "showUsage"
checkError "You need openssl to generate binaries signature, brew install it, aborting."

command -v docker-machine > /dev/null 2>&1
checkError "You must have a docker-machine in your path" "showUsage"
checkError "You must have a docker-machine in your path"

GITHUB_VERSION="v${VERSION}"
RELEASE_DIR="$(dirname "$(git rev-parse --show-toplevel)")/release-${VERSION}"
GITHUB_RELEASE_FILE="github-release-${VERSION}.md"

LAST_RELEASE_VERSION=$(git describe --abbrev=0 --tags)
#TODO: ABORT if not found (very unlikely but could happen if two tags are on the same commits )
# this tag search is done on master not on the clone...
checkError "Unable to find current version tag"

display "Starting release from ${LAST_RELEASE_VERSION} to ${GITHUB_VERSION} on ${PROJECT_URL} with token ${GITHUB_TOKEN}"
while true; do
Expand All @@ -84,48 +82,47 @@ if [[ "$?" -ne 0 ]]; then
createMachine
else
if [[ "${MACHINE_STATUS}" != "Running" ]]; then
display "Machine 'release' is not running, trying to start it."
display "Machine 'release' is not running, trying to start it"
docker-machine start release
docker-machine env release
if [[ "$?" -ne 0 ]]; then
display "Machine 'release' could not be started, removing and creating a fresh new one."
display "Machine 'release' could not be started, removing and creating a fresh new one"
createMachine
fi
display "Loosing 5 seconds to the virtualbox gods."
display "Loosing 5 seconds to the VirtualBox gods"
sleep 5
fi
fi

eval $(docker-machine env release)
checkError "Machine 'release' is in a weird state, aborting."
checkError "Machine 'release' is in a weird state, aborting"

if [[ -d "${RELEASE_DIR}" ]]; then
display "Cleaning up ${RELEASE_DIR}"
rm -rdf "${RELEASE_DIR}"
checkError "Can't clean up ${RELEASE_DIR}. You should do it manually and retry."
checkError "Can't clean up ${RELEASE_DIR}. You should do it manually and retry"
fi

display "Cloning into ${RELEASE_DIR} from ${PROJECT_URL}"

mkdir -p "${RELEASE_DIR}"
checkError "Can't create ${RELEASE_DIR}, aborting."
checkError "Can't create ${RELEASE_DIR}, aborting"
git clone -q "${PROJECT_URL}" "${RELEASE_DIR}"
checkError "Can't clone into ${RELEASE_DIR}, aborting."
checkError "Can't clone into ${RELEASE_DIR}, aborting"

cd "${RELEASE_DIR}"

display "Bump version number to ${VERSION}"
#TODO: This only works with the version written in the version.go file
sed -i.bak s/"${VERSION}-dev"/"${VERSION}"/g version/version.go
checkError "Sed borkage..., aborting."
sed -i "" "s/Version = \".*-dev\"/Version = \"${VERSION}\"/g" version/version.go
checkError "Unable to change version in version/version.go"

git add version/version.go
git commit -q -m"Bump version to ${VERSION}" -s
checkError "Can't git commit the version upgrade, aborting."
rm version/version.go.bak
checkError "Can't git commit the version upgrade, aborting"

display "Building in-container style"
USE_CONTAINER=true make clean validate build-x
checkError "Build error, aborting."
checkError "Build error, aborting"

display "Generating github release"
cp -f script/release/github-release-template.md "${GITHUB_RELEASE_FILE}"
Expand All @@ -134,14 +131,12 @@ CONTRIBUTORS=$(git log "${LAST_RELEASE_VERSION}".. --format="%aN" --reverse | so
CHANGELOG=$(git log "${LAST_RELEASE_VERSION}".. --oneline)

CHECKSUM=""
cd bin/
for file in $(ls docker-machine*); do
for file in $(ls bin/docker-machine*); do
SHA256=$(openssl dgst -sha256 < "${file}")
MD5=$(openssl dgst -md5 < "${file}")
LINE=$(printf "\n * **%s**\n * sha256 \`%s\`\n * md5 \`%s\`\n\n" "${file}" "${SHA256}" "${MD5}")
LINE=$(printf "\n * **%s**\n * sha256 \`%s\`\n * md5 \`%s\`\n\n" "$(basename ${file})" "${SHA256}" "${MD5}")
CHECKSUM="${CHECKSUM}${LINE}"
done
cd ..

TEMPLATE=$(cat "${GITHUB_RELEASE_FILE}")
echo "${TEMPLATE//\{\{VERSION\}\}/$GITHUB_VERSION}" > "${GITHUB_RELEASE_FILE}"
Expand All @@ -168,7 +163,7 @@ if [[ "$?" -ne 0 ]]; then
git remote add remote.prod.url "${PROJECT_URL}"
fi

display "Checking if remote tag ${GITHUB_VERSION} already exists."
display "Checking if remote tag ${GITHUB_VERSION} already exists"
git ls-remote --tags 2> /dev/null | grep -q "${GITHUB_VERSION}" # returns 0 if found, 1 if not
if [[ "$?" -ne 1 ]]; then
display "Deleting previous tag ${GITHUB_VERSION}"
Expand All @@ -191,13 +186,13 @@ github-release info \
--tag "${GITHUB_VERSION}" > /dev/null 2>&1

if [[ "$?" -ne 1 ]]; then
display "Release already exists, cleaning it up."
display "Release already exists, cleaning it up"
github-release delete \
--security-token "${GITHUB_TOKEN}" \
--user "${GITHUB_USER}" \
--repo "${GITHUB_REPO}" \
--tag "${GITHUB_VERSION}"
checkError "Could not delete release, aborting."
checkError "Could not delete release, aborting"
fi

display "Creating release on github"
Expand All @@ -209,35 +204,33 @@ github-release release \
--name "${GITHUB_VERSION}" \
--description "${RELEASE_DOCUMENTATION}" \
--pre-release
checkError "Could not create release, aborting."

checkError "Could not create release, aborting"

display "Uploading binaries"
cd bin/
for file in $(ls docker-machine*); do
for file in $(ls bin/docker-machine*); do
display "Uploading ${file}..."
github-release upload \
--security-token "${GITHUB_TOKEN}" \
--user "${GITHUB_USER}" \
--repo "${GITHUB_REPO}" \
--tag "${GITHUB_VERSION}" \
--name "${file}" \
--name "$(basename "${file}")" \
--file "${file}"
if [[ "$?" -ne 0 ]]; then
display "Could not upload ${file}, continuing with others."
display "Could not upload ${file}, continuing with others"
fi
done
cd ..

git remote rm remote.prod.url

rm ${GITHUB_RELEASE_FILE}

echo "There is a couple of tasks your still need to do manually."
echo " 1 Open the release notes created for you on github https://github.com/docker/machine/releases/tag/${GITHUB_VERSION}, you'll have a chance to enhance commit details a bit."
echo " 2 Once you're happy with your release notes on github, copy the list of changes to the CHANGELOG.md"
echo " 3 Update the documentation branch"
echo " 4 Test the binaries linked from the github release page"
echo " 6 Change version/version.go to the next version"
echo " 7 Party !!"
echo " The full details of these tasks are described in the RELEASE.md document, available at https://github.com/docker/machine/blob/master/docs/RELEASE.md"
echo "There is a couple of tasks your still need to do manually:"
echo " 1. Open the release notes created for you on github https://github.com/${GITHUB_USER}/${GITHUB_REPO}/releases/tag/${GITHUB_VERSION}, you'll have a chance to enhance commit details a bit"
echo " 2. Once you're happy with your release notes on github, copy the list of changes to the CHANGELOG.md"
echo " 3. Update the documentation branch"
echo " 4. Test the binaries linked from the github release page"
echo " 5. Change version/version.go to the next dev version"
echo " 6. Party !!"
echo
echo "The full details of these tasks are described in the RELEASE.md document, available at https://github.com/${GITHUB_USER}/${GITHUB_REPO}/blob/master/docs/RELEASE.md"
7 changes: 3 additions & 4 deletions script/release/github-release-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,20 @@ $ if [[ ! -d "$HOME/bin" ]]; then mkdir -p "$HOME/bin"; fi && \

## Changelog


*Edit the changelog below by hand*

{{CHANGELOG}}

## Thank You

Thank you very much to our active users and contributors. If you have filed detailed bug reports, THANK YOU! Please continue to do so if you encounter any issues. It's your hard work that makes Machine better.
Thank you very much to our active users and contributors. If you have filed detailed bug reports, THANK YOU!
Please continue to do so if you encounter any issues. It's your hard work that makes Docker Machine better.

The following authors contributed changes to this release:

{{CONTRIBUTORS}}

Great thanks to all of the above! We appreciate it. Keep up the great work!

Great thanks to all of the above! We appreciate it. Keep up the great work!

## Checksums

Expand Down

0 comments on commit 3b0f2b0

Please sign in to comment.