Small improvements to the release script

Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
David Gageot 2015-12-28 10:39:41 +01:00
parent 93bc3585a7
commit 3b0f2b06ff
2 changed files with 58 additions and 66 deletions

View File

@ -1,26 +1,22 @@
#!/bin/bash #!/bin/bash
#Put your github username here, while testing performing new releases
#GITHUB_USER=jeanlaurent
GITHUB_USER=docker GITHUB_USER=docker
GITHUB_REPO=machine GITHUB_REPO=machine
PROJECT_URL="git@github.com:${GITHUB_USER}/${GITHUB_REPO}"
function usage { function usage {
echo "Usage: " echo "Usage: "
echo " GITHUB_TOKEN=XXXXX release/release.sh 0.5.x" echo " GITHUB_TOKEN=XXXXX ${0} 0.5.x"
} }
function display { function display {
echo "🐳 $1" echo "🐳 $1"
echo "" echo
} }
function checkError { function checkError {
if [[ "$?" -ne 0 ]]; then if [[ "$?" -ne 0 ]]; then
echo "😡 $1" echo "😡 $1"
if [[ "$2" == "showUsage" ]]; then
usage
fi
exit 1 exit 1
fi fi
} }
@ -30,41 +26,43 @@ function createMachine {
docker-machine create -d virtualbox --virtualbox-cpu-count=2 --virtualbox-memory=2048 release 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}"
RELEASE_DIR="$(git rev-parse --show-toplevel)/../release-${VERSION}"
GITHUB_RELEASE_FILE="github-release-${VERSION}.md"
if [[ -z "${VERSION}" ]]; then
#TODO: Check version is well formed
echo "Missing version argument"
usage
exit 1
fi
if [[ -z "${GITHUB_TOKEN}" ]]; then if [[ -z "${GITHUB_TOKEN}" ]]; then
echo "GITHUB_TOKEN missing" echo "GITHUB_TOKEN missing"
usage usage
exit 1 exit 1
fi fi
VERSION=$1
if [[ -z "${VERSION}" ]]; then
echo "Missing version argument"
usage
exit 1
fi
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 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 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 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 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) 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 ) checkError "Unable to find current version tag"
# this tag search is done on master not on the clone...
display "Starting release from ${LAST_RELEASE_VERSION} to ${GITHUB_VERSION} on ${PROJECT_URL} with token ${GITHUB_TOKEN}" display "Starting release from ${LAST_RELEASE_VERSION} to ${GITHUB_VERSION} on ${PROJECT_URL} with token ${GITHUB_TOKEN}"
while true; do while true; do
@ -84,48 +82,47 @@ if [[ "$?" -ne 0 ]]; then
createMachine createMachine
else else
if [[ "${MACHINE_STATUS}" != "Running" ]]; then 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 start release
docker-machine env release
if [[ "$?" -ne 0 ]]; then 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 createMachine
fi fi
display "Loosing 5 seconds to the virtualbox gods." display "Loosing 5 seconds to the VirtualBox gods"
sleep 5 sleep 5
fi fi
fi fi
eval $(docker-machine env release) 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 if [[ -d "${RELEASE_DIR}" ]]; then
display "Cleaning up ${RELEASE_DIR}" display "Cleaning up ${RELEASE_DIR}"
rm -rdf "${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 fi
display "Cloning into ${RELEASE_DIR} from ${PROJECT_URL}" display "Cloning into ${RELEASE_DIR} from ${PROJECT_URL}"
mkdir -p "${RELEASE_DIR}" 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}" 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}" cd "${RELEASE_DIR}"
display "Bump version number to ${VERSION}" display "Bump version number to ${VERSION}"
#TODO: This only works with the version written in the version.go file sed -i "" "s/Version = \".*-dev\"/Version = \"${VERSION}\"/g" version/version.go
sed -i.bak s/"${VERSION}-dev"/"${VERSION}"/g version/version.go checkError "Unable to change version in version/version.go"
checkError "Sed borkage..., aborting."
git add version/version.go git add version/version.go
git commit -q -m"Bump version to ${VERSION}" -s git commit -q -m"Bump version to ${VERSION}" -s
checkError "Can't git commit the version upgrade, aborting." checkError "Can't git commit the version upgrade, aborting"
rm version/version.go.bak
display "Building in-container style" display "Building in-container style"
USE_CONTAINER=true make clean validate build-x USE_CONTAINER=true make clean validate build-x
checkError "Build error, aborting." checkError "Build error, aborting"
display "Generating github release" display "Generating github release"
cp -f script/release/github-release-template.md "${GITHUB_RELEASE_FILE}" cp -f script/release/github-release-template.md "${GITHUB_RELEASE_FILE}"
@ -134,14 +131,12 @@ CONTRIBUTORS=$(git log "${LAST_RELEASE_VERSION}".. --format="%aN" --reverse | so
CHANGELOG=$(git log "${LAST_RELEASE_VERSION}".. --oneline) CHANGELOG=$(git log "${LAST_RELEASE_VERSION}".. --oneline)
CHECKSUM="" CHECKSUM=""
cd bin/ for file in $(ls bin/docker-machine*); do
for file in $(ls docker-machine*); do
SHA256=$(openssl dgst -sha256 < "${file}") SHA256=$(openssl dgst -sha256 < "${file}")
MD5=$(openssl dgst -md5 < "${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}" CHECKSUM="${CHECKSUM}${LINE}"
done done
cd ..
TEMPLATE=$(cat "${GITHUB_RELEASE_FILE}") TEMPLATE=$(cat "${GITHUB_RELEASE_FILE}")
echo "${TEMPLATE//\{\{VERSION\}\}/$GITHUB_VERSION}" > "${GITHUB_RELEASE_FILE}" echo "${TEMPLATE//\{\{VERSION\}\}/$GITHUB_VERSION}" > "${GITHUB_RELEASE_FILE}"
@ -168,7 +163,7 @@ if [[ "$?" -ne 0 ]]; then
git remote add remote.prod.url "${PROJECT_URL}" git remote add remote.prod.url "${PROJECT_URL}"
fi 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 git ls-remote --tags 2> /dev/null | grep -q "${GITHUB_VERSION}" # returns 0 if found, 1 if not
if [[ "$?" -ne 1 ]]; then if [[ "$?" -ne 1 ]]; then
display "Deleting previous tag ${GITHUB_VERSION}" display "Deleting previous tag ${GITHUB_VERSION}"
@ -191,13 +186,13 @@ github-release info \
--tag "${GITHUB_VERSION}" > /dev/null 2>&1 --tag "${GITHUB_VERSION}" > /dev/null 2>&1
if [[ "$?" -ne 1 ]]; then if [[ "$?" -ne 1 ]]; then
display "Release already exists, cleaning it up." display "Release already exists, cleaning it up"
github-release delete \ github-release delete \
--security-token "${GITHUB_TOKEN}" \ --security-token "${GITHUB_TOKEN}" \
--user "${GITHUB_USER}" \ --user "${GITHUB_USER}" \
--repo "${GITHUB_REPO}" \ --repo "${GITHUB_REPO}" \
--tag "${GITHUB_VERSION}" --tag "${GITHUB_VERSION}"
checkError "Could not delete release, aborting." checkError "Could not delete release, aborting"
fi fi
display "Creating release on github" display "Creating release on github"
@ -209,35 +204,33 @@ github-release release \
--name "${GITHUB_VERSION}" \ --name "${GITHUB_VERSION}" \
--description "${RELEASE_DOCUMENTATION}" \ --description "${RELEASE_DOCUMENTATION}" \
--pre-release --pre-release
checkError "Could not create release, aborting." checkError "Could not create release, aborting"
display "Uploading binaries" display "Uploading binaries"
cd bin/ for file in $(ls bin/docker-machine*); do
for file in $(ls docker-machine*); do
display "Uploading ${file}..." display "Uploading ${file}..."
github-release upload \ github-release upload \
--security-token "${GITHUB_TOKEN}" \ --security-token "${GITHUB_TOKEN}" \
--user "${GITHUB_USER}" \ --user "${GITHUB_USER}" \
--repo "${GITHUB_REPO}" \ --repo "${GITHUB_REPO}" \
--tag "${GITHUB_VERSION}" \ --tag "${GITHUB_VERSION}" \
--name "${file}" \ --name "$(basename "${file}")" \
--file "${file}" --file "${file}"
if [[ "$?" -ne 0 ]]; then if [[ "$?" -ne 0 ]]; then
display "Could not upload ${file}, continuing with others." display "Could not upload ${file}, continuing with others"
fi fi
done done
cd ..
git remote rm remote.prod.url git remote rm remote.prod.url
rm ${GITHUB_RELEASE_FILE} rm ${GITHUB_RELEASE_FILE}
echo "There is a couple of tasks your still need to do manually." 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 " 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 " 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 " 3. Update the documentation branch"
echo " 4 Test the binaries linked from the github release page" echo " 4. Test the binaries linked from the github release page"
echo " 6 Change version/version.go to the next version" echo " 5. Change version/version.go to the next dev version"
echo " 7 Party !!" echo " 6. 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
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"

View File

@ -27,14 +27,14 @@ $ if [[ ! -d "$HOME/bin" ]]; then mkdir -p "$HOME/bin"; fi && \
## Changelog ## Changelog
*Edit the changelog below by hand* *Edit the changelog below by hand*
{{CHANGELOG}} {{CHANGELOG}}
## Thank You ## 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: The following authors contributed changes to this release:
@ -42,7 +42,6 @@ The following authors contributed changes to this release:
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 ## Checksums
{{CHECKSUM}} {{CHECKSUM}}