2014-01-21 20:21:56 -05:00
|
|
|
#!/usr/bin/env bash
|
2013-10-17 04:08:14 -04:00
|
|
|
set -e
|
2013-08-07 00:16:13 -04:00
|
|
|
|
2013-08-09 20:38:48 -04:00
|
|
|
# This script looks for bundles built by make.sh, and releases them on a
|
|
|
|
# public S3 bucket.
|
2013-08-07 00:16:13 -04:00
|
|
|
#
|
|
|
|
# Bundles should be available for the VERSION string passed as argument.
|
|
|
|
#
|
2013-08-09 20:38:48 -04:00
|
|
|
# The correct way to call this script is inside a container built by the
|
|
|
|
# official Dockerfile at the root of the Docker source code. The Dockerfile,
|
|
|
|
# make.sh and release.sh should all be from the same source code revision.
|
2013-08-07 00:16:13 -04:00
|
|
|
|
2013-10-17 04:08:14 -04:00
|
|
|
set -o pipefail
|
2013-08-07 00:16:13 -04:00
|
|
|
|
|
|
|
# Print a usage message and exit.
|
|
|
|
usage() {
|
2013-10-17 04:08:14 -04:00
|
|
|
cat >&2 <<'EOF'
|
2013-08-09 21:08:06 -04:00
|
|
|
To run, I need:
|
|
|
|
- to be in a container generated by the Dockerfile at the top of the Docker
|
|
|
|
repository;
|
2015-08-25 15:18:04 -04:00
|
|
|
- to be provided with the location of an S3 bucket and path, in
|
|
|
|
environment variables AWS_S3_BUCKET and AWS_S3_BUCKET_PATH (default: '');
|
2013-08-09 21:08:06 -04:00
|
|
|
- to be provided with AWS credentials for this S3 bucket, in environment
|
2016-03-22 22:46:46 -04:00
|
|
|
variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY;
|
2013-08-09 21:08:06 -04:00
|
|
|
- a generous amount of good will and nice manners.
|
|
|
|
The canonical way to run me is to run the image produced by the Dockerfile: e.g.:"
|
|
|
|
|
2014-09-23 19:18:09 -04:00
|
|
|
docker run -e AWS_S3_BUCKET=test.docker.com \
|
2016-03-22 22:46:46 -04:00
|
|
|
-e AWS_ACCESS_KEY_ID \
|
|
|
|
-e AWS_SECRET_ACCESS_KEY \
|
|
|
|
-e AWS_DEFAULT_REGION \
|
|
|
|
-it --privileged \
|
2013-10-17 04:08:14 -04:00
|
|
|
docker ./hack/release.sh
|
2013-08-09 21:08:06 -04:00
|
|
|
EOF
|
2013-08-07 00:16:13 -04:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2013-08-09 21:08:06 -04:00
|
|
|
[ "$AWS_S3_BUCKET" ] || usage
|
2016-03-22 22:46:46 -04:00
|
|
|
[ "$AWS_ACCESS_KEY_ID" ] || usage
|
|
|
|
[ "$AWS_SECRET_ACCESS_KEY" ] || usage
|
2014-07-24 18:19:50 -04:00
|
|
|
[ -d /go/src/github.com/docker/docker ] || usage
|
|
|
|
cd /go/src/github.com/docker/docker
|
2013-10-17 04:08:14 -04:00
|
|
|
[ -x hack/make.sh ] || usage
|
|
|
|
|
2016-03-22 22:46:46 -04:00
|
|
|
export AWS_DEFAULT_REGION
|
2016-03-25 10:54:36 -04:00
|
|
|
: ${AWS_DEFAULT_REGION:=us-west-1}
|
2016-03-22 22:46:46 -04:00
|
|
|
|
2016-11-22 04:12:40 -05:00
|
|
|
AWS_CLI=${AWS_CLI:-'aws'}
|
|
|
|
|
2013-10-17 04:08:14 -04:00
|
|
|
RELEASE_BUNDLES=(
|
|
|
|
binary
|
2013-12-19 01:06:14 -05:00
|
|
|
cross
|
2013-11-17 22:25:08 -05:00
|
|
|
tgz
|
2013-10-17 04:08:14 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
if [ "$1" != '--release-regardless-of-test-failure' ]; then
|
2014-04-08 00:22:03 -04:00
|
|
|
RELEASE_BUNDLES=(
|
2015-05-12 18:39:57 -04:00
|
|
|
test-unit
|
2014-04-08 00:22:03 -04:00
|
|
|
"${RELEASE_BUNDLES[@]}"
|
|
|
|
test-integration-cli
|
|
|
|
)
|
2013-10-17 04:08:14 -04:00
|
|
|
fi
|
2014-04-08 00:22:03 -04:00
|
|
|
|
2015-04-14 12:31:52 -04:00
|
|
|
VERSION=$(< VERSION)
|
2013-08-09 21:18:33 -04:00
|
|
|
BUCKET=$AWS_S3_BUCKET
|
2015-08-25 15:18:04 -04:00
|
|
|
BUCKET_PATH=$BUCKET
|
|
|
|
[[ -n "$AWS_S3_BUCKET_PATH" ]] && BUCKET_PATH+=/$AWS_S3_BUCKET_PATH
|
2013-08-07 00:16:13 -04:00
|
|
|
|
2015-09-10 15:22:06 -04:00
|
|
|
if command -v git &> /dev/null && git rev-parse &> /dev/null; then
|
|
|
|
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
|
|
|
|
echo "You cannot run the release script on a repo with uncommitted changes"
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-03-16 17:10:59 -04:00
|
|
|
# These are the 2 keys we've used to sign the deb's
|
2014-09-23 19:18:09 -04:00
|
|
|
# release (get.docker.com)
|
2014-03-16 17:10:59 -04:00
|
|
|
# GPG_KEY="36A1D7869245C8950F966E92D8576A8BA88D21E9"
|
2014-09-23 19:18:09 -04:00
|
|
|
# test (test.docker.com)
|
2014-03-16 17:10:59 -04:00
|
|
|
# GPG_KEY="740B314AE3941731B942C66ADF4FD13717AAD7D6"
|
|
|
|
|
2013-08-07 00:16:13 -04:00
|
|
|
setup_s3() {
|
2015-07-27 17:28:05 -04:00
|
|
|
echo "Setting up S3"
|
2013-08-07 00:16:13 -04:00
|
|
|
# Try creating the bucket. Ignore errors (it might already exist).
|
2016-11-22 04:12:40 -05:00
|
|
|
$AWS_CLI s3 mb "s3://$BUCKET" 2>/dev/null || true
|
2013-08-09 21:18:33 -04:00
|
|
|
# Check access to the bucket.
|
2016-11-22 04:12:40 -05:00
|
|
|
$AWS_CLI s3 ls "s3://$BUCKET" >/dev/null
|
2013-08-14 21:35:17 -04:00
|
|
|
# Make the bucket accessible through website endpoints.
|
2016-11-22 04:12:40 -05:00
|
|
|
$AWS_CLI s3 website --index-document index --error-document error "s3://$BUCKET"
|
2013-08-07 00:16:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
# write_to_s3 uploads the contents of standard input to the specified S3 url.
|
|
|
|
write_to_s3() {
|
|
|
|
DEST=$1
|
|
|
|
F=`mktemp`
|
2015-04-14 12:08:08 -04:00
|
|
|
cat > "$F"
|
2016-11-22 04:12:40 -05:00
|
|
|
$AWS_CLI s3 cp --acl public-read --content-type 'text/plain' "$F" "$DEST"
|
2015-04-14 12:08:08 -04:00
|
|
|
rm -f "$F"
|
2013-08-07 00:16:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
s3_url() {
|
2013-09-28 00:50:24 -04:00
|
|
|
case "$BUCKET" in
|
2015-06-18 17:54:40 -04:00
|
|
|
get.docker.com|test.docker.com|experimental.docker.com)
|
2015-08-25 15:18:04 -04:00
|
|
|
echo "https://$BUCKET_PATH"
|
2013-09-28 00:50:24 -04:00
|
|
|
;;
|
|
|
|
*)
|
2016-03-25 10:54:36 -04:00
|
|
|
BASE_URL="http://${BUCKET}.s3-website-${AWS_DEFAULT_REGION}.amazonaws.com"
|
2015-08-25 15:18:04 -04:00
|
|
|
if [[ -n "$AWS_S3_BUCKET_PATH" ]] ; then
|
|
|
|
echo "$BASE_URL/$AWS_S3_BUCKET_PATH"
|
|
|
|
else
|
|
|
|
echo "$BASE_URL"
|
|
|
|
fi
|
2013-09-28 00:50:24 -04:00
|
|
|
;;
|
|
|
|
esac
|
2013-08-07 00:16:13 -04:00
|
|
|
}
|
|
|
|
|
2014-03-16 17:10:59 -04:00
|
|
|
build_all() {
|
2015-07-27 17:28:05 -04:00
|
|
|
echo "Building release"
|
2014-03-16 17:10:59 -04:00
|
|
|
if ! ./hack/make.sh "${RELEASE_BUNDLES[@]}"; then
|
|
|
|
echo >&2
|
|
|
|
echo >&2 'The build or tests appear to have failed.'
|
|
|
|
echo >&2
|
|
|
|
echo >&2 'You, as the release maintainer, now have a couple options:'
|
|
|
|
echo >&2 '- delay release and fix issues'
|
|
|
|
echo >&2 '- delay release and fix issues'
|
|
|
|
echo >&2 '- did we mention how important this is? issues need fixing :)'
|
|
|
|
echo >&2
|
|
|
|
echo >&2 'As a final LAST RESORT, you (because only you, the release maintainer,'
|
|
|
|
echo >&2 ' really knows all the hairy problems at hand with the current release'
|
|
|
|
echo >&2 ' issues) may bypass this checking by running this script again with the'
|
|
|
|
echo >&2 ' single argument of "--release-regardless-of-test-failure", which will skip'
|
|
|
|
echo >&2 ' running the test suite, and will only build the binaries and packages. Please'
|
|
|
|
echo >&2 ' avoid using this if at all possible.'
|
|
|
|
echo >&2
|
|
|
|
echo >&2 'Regardless, we cannot stress enough the scarcity with which this bypass'
|
|
|
|
echo >&2 ' should be used. If there are release issues, we should always err on the'
|
|
|
|
echo >&2 ' side of caution.'
|
|
|
|
echo >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-03-19 21:58:39 -04:00
|
|
|
upload_release_build() {
|
|
|
|
src="$1"
|
|
|
|
dst="$2"
|
|
|
|
latest="$3"
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Uploading $src"
|
|
|
|
echo " to $dst"
|
|
|
|
echo
|
2016-11-22 04:12:40 -05:00
|
|
|
$AWS_CLI s3 cp --follow-symlinks --acl public-read "$src" "$dst"
|
2014-03-19 21:58:39 -04:00
|
|
|
if [ "$latest" ]; then
|
|
|
|
echo
|
|
|
|
echo "Copying to $latest"
|
|
|
|
echo
|
2016-11-22 04:12:40 -05:00
|
|
|
$AWS_CLI s3 cp --acl public-read "$dst" "$latest"
|
2014-03-19 21:58:39 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# get hash files too (see hash_files() in hack/make.sh)
|
|
|
|
for hashAlgo in md5 sha256; do
|
|
|
|
if [ -e "$src.$hashAlgo" ]; then
|
|
|
|
echo
|
|
|
|
echo "Uploading $src.$hashAlgo"
|
|
|
|
echo " to $dst.$hashAlgo"
|
|
|
|
echo
|
2016-11-22 04:12:40 -05:00
|
|
|
$AWS_CLI s3 cp --follow-symlinks --acl public-read --content-type='text/plain' "$src.$hashAlgo" "$dst.$hashAlgo"
|
2014-03-19 21:58:39 -04:00
|
|
|
if [ "$latest" ]; then
|
|
|
|
echo
|
|
|
|
echo "Copying to $latest.$hashAlgo"
|
|
|
|
echo
|
2016-11-22 04:12:40 -05:00
|
|
|
$AWS_CLI s3 cp --acl public-read "$dst.$hashAlgo" "$latest.$hashAlgo"
|
2014-03-19 21:58:39 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2013-12-24 01:31:53 -05:00
|
|
|
release_build() {
|
2015-07-27 17:28:05 -04:00
|
|
|
echo "Releasing binaries"
|
2013-12-24 01:31:53 -05:00
|
|
|
GOOS=$1
|
|
|
|
GOARCH=$2
|
|
|
|
|
2014-03-19 21:58:39 -04:00
|
|
|
binDir=bundles/$VERSION/cross/$GOOS/$GOARCH
|
|
|
|
tgzDir=bundles/$VERSION/tgz/$GOOS/$GOARCH
|
|
|
|
binary=docker-$VERSION
|
2016-03-31 12:27:50 -04:00
|
|
|
zipExt=".tgz"
|
|
|
|
binaryExt=""
|
|
|
|
tgz=$binary$zipExt
|
2014-03-19 21:58:39 -04:00
|
|
|
|
|
|
|
latestBase=
|
|
|
|
if [ -z "$NOLATEST" ]; then
|
|
|
|
latestBase=docker-latest
|
|
|
|
fi
|
2013-12-24 01:31:53 -05:00
|
|
|
|
|
|
|
# we need to map our GOOS and GOARCH to uname values
|
|
|
|
# see https://en.wikipedia.org/wiki/Uname
|
|
|
|
# ie, GOOS=linux -> "uname -s"=Linux
|
|
|
|
|
2014-03-19 21:58:39 -04:00
|
|
|
s3Os=$GOOS
|
|
|
|
case "$s3Os" in
|
2013-12-24 01:31:53 -05:00
|
|
|
darwin)
|
2014-03-19 21:58:39 -04:00
|
|
|
s3Os=Darwin
|
2013-12-24 01:31:53 -05:00
|
|
|
;;
|
|
|
|
freebsd)
|
2014-03-19 21:58:39 -04:00
|
|
|
s3Os=FreeBSD
|
2013-12-24 01:31:53 -05:00
|
|
|
;;
|
|
|
|
linux)
|
2014-03-19 21:58:39 -04:00
|
|
|
s3Os=Linux
|
2013-12-24 01:31:53 -05:00
|
|
|
;;
|
2016-11-22 04:12:40 -05:00
|
|
|
solaris)
|
|
|
|
echo skipping solaris release
|
|
|
|
return 0
|
|
|
|
;;
|
2015-03-11 14:29:29 -04:00
|
|
|
windows)
|
2016-10-29 03:03:26 -04:00
|
|
|
# this is windows use the .zip and .exe extensions for the files.
|
2015-03-11 14:29:29 -04:00
|
|
|
s3Os=Windows
|
2016-03-31 12:27:50 -04:00
|
|
|
zipExt=".zip"
|
|
|
|
binaryExt=".exe"
|
|
|
|
tgz=$binary$zipExt
|
|
|
|
binary+=$binaryExt
|
2015-03-11 14:29:29 -04:00
|
|
|
;;
|
2013-12-24 01:31:53 -05:00
|
|
|
*)
|
2014-03-19 21:58:39 -04:00
|
|
|
echo >&2 "error: can't convert $s3Os to an appropriate value for 'uname -s'"
|
2013-12-24 01:31:53 -05:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2014-03-19 21:58:39 -04:00
|
|
|
s3Arch=$GOARCH
|
|
|
|
case "$s3Arch" in
|
2013-12-24 01:31:53 -05:00
|
|
|
amd64)
|
2014-03-19 21:58:39 -04:00
|
|
|
s3Arch=x86_64
|
2013-12-24 01:31:53 -05:00
|
|
|
;;
|
|
|
|
386)
|
2014-03-19 21:58:39 -04:00
|
|
|
s3Arch=i386
|
2013-12-24 01:31:53 -05:00
|
|
|
;;
|
|
|
|
arm)
|
2014-03-19 21:58:39 -04:00
|
|
|
s3Arch=armel
|
2015-12-13 11:00:39 -05:00
|
|
|
# someday, we might potentially support multiple GOARM values, in which case we might get armhf here too
|
2013-12-24 01:31:53 -05:00
|
|
|
;;
|
|
|
|
*)
|
2014-03-19 21:58:39 -04:00
|
|
|
echo >&2 "error: can't convert $s3Arch to an appropriate value for 'uname -m'"
|
2013-12-24 01:31:53 -05:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2015-08-25 15:18:04 -04:00
|
|
|
s3Dir="s3://$BUCKET_PATH/builds/$s3Os/$s3Arch"
|
2016-03-31 12:27:50 -04:00
|
|
|
# latest=
|
2014-03-19 21:58:39 -04:00
|
|
|
latestTgz=
|
|
|
|
if [ "$latestBase" ]; then
|
2016-03-31 12:27:50 -04:00
|
|
|
# commented out since we aren't uploading binaries right now.
|
|
|
|
# latest="$s3Dir/$latestBase$binaryExt"
|
|
|
|
# we don't include the $binaryExt because we don't want docker.exe.zip
|
|
|
|
latestTgz="$s3Dir/$latestBase$zipExt"
|
2014-03-19 21:58:39 -04:00
|
|
|
fi
|
2013-12-24 01:31:53 -05:00
|
|
|
|
2014-03-19 21:58:39 -04:00
|
|
|
if [ ! -f "$tgzDir/$tgz" ]; then
|
|
|
|
echo >&2 "error: can't find $tgzDir/$tgz - was it packaged properly?"
|
2013-12-24 01:31:53 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
2016-03-22 13:42:54 -04:00
|
|
|
# disable binary uploads for now. Only providing tgz downloads
|
|
|
|
# upload_release_build "$binDir/$binary" "$s3Dir/$binary" "$latest"
|
2014-03-19 21:58:39 -04:00
|
|
|
upload_release_build "$tgzDir/$tgz" "$s3Dir/$tgz" "$latestTgz"
|
2013-12-24 01:31:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# Upload binaries and tgz files to S3
|
|
|
|
release_binaries() {
|
2016-10-03 18:20:51 -04:00
|
|
|
[ "$(find bundles/$VERSION -path "bundles/$VERSION/cross/*/*/docker-$VERSION")" != "" ] || {
|
2013-12-24 01:31:53 -05:00
|
|
|
echo >&2 './hack/make.sh must be run before release_binaries'
|
2013-11-17 22:25:08 -05:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2013-12-24 01:31:53 -05:00
|
|
|
for d in bundles/$VERSION/cross/*/*; do
|
|
|
|
GOARCH="$(basename "$d")"
|
|
|
|
GOOS="$(basename "$(dirname "$d")")"
|
|
|
|
release_build "$GOOS" "$GOARCH"
|
|
|
|
done
|
2013-11-17 22:25:08 -05:00
|
|
|
|
2013-12-24 01:31:53 -05:00
|
|
|
# TODO create redirect from builds/*/i686 to builds/*/i386
|
2013-11-08 17:45:18 -05:00
|
|
|
|
2015-08-25 15:18:04 -04:00
|
|
|
cat <<EOF | write_to_s3 s3://$BUCKET_PATH/builds/index
|
2016-06-13 11:55:06 -04:00
|
|
|
# To install, run the following commands as root:
|
|
|
|
curl -fsSLO $(s3_url)/builds/Linux/x86_64/docker-$VERSION.tgz && tar --strip-components=1 -xvzf docker-$VERSION.tgz -C /usr/local/bin
|
|
|
|
|
2013-08-07 00:16:13 -04:00
|
|
|
# Then start docker in daemon mode:
|
2016-06-13 11:55:06 -04:00
|
|
|
/usr/local/bin/dockerd
|
2013-08-07 00:16:13 -04:00
|
|
|
EOF
|
2013-11-08 17:45:18 -05:00
|
|
|
|
|
|
|
# Add redirect at /builds/info for URL-backwards-compatibility
|
|
|
|
rm -rf /tmp/emptyfile && touch /tmp/emptyfile
|
2016-11-22 04:12:40 -05:00
|
|
|
$AWS_CLI s3 cp --acl public-read --website-redirect '/builds/' --content-type='text/plain' /tmp/emptyfile "s3://$BUCKET_PATH/builds/info"
|
2013-11-08 17:45:18 -05:00
|
|
|
|
2013-08-07 00:16:13 -04:00
|
|
|
if [ -z "$NOLATEST" ]; then
|
2015-08-25 15:18:04 -04:00
|
|
|
echo "Advertising $VERSION on $BUCKET_PATH as most recent version"
|
|
|
|
echo "$VERSION" | write_to_s3 "s3://$BUCKET_PATH/latest"
|
2013-08-07 00:16:13 -04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-08-14 21:35:17 -04:00
|
|
|
# Upload the index script
|
|
|
|
release_index() {
|
2015-07-27 17:28:05 -04:00
|
|
|
echo "Releasing index"
|
2016-01-25 12:01:46 -05:00
|
|
|
url="$(s3_url)/" hack/make.sh install-script
|
2016-01-06 17:25:39 -05:00
|
|
|
write_to_s3 "s3://$BUCKET_PATH/index" < "bundles/$VERSION/install-script/install.sh"
|
2013-08-14 21:35:17 -04:00
|
|
|
}
|
|
|
|
|
2013-08-07 00:16:13 -04:00
|
|
|
main() {
|
2016-11-22 04:12:40 -05:00
|
|
|
[ "$SKIP_RELEASE_BUILD" -eq 1 ] || build_all
|
2013-08-07 00:16:13 -04:00
|
|
|
setup_s3
|
2013-12-24 01:31:53 -05:00
|
|
|
release_binaries
|
2013-08-14 21:35:17 -04:00
|
|
|
release_index
|
2013-08-07 00:16:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
main
|
2013-12-24 01:31:53 -05:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo "Release complete; see $(s3_url)"
|
2015-07-09 13:58:27 -04:00
|
|
|
echo "Use the following text to announce the release:"
|
|
|
|
echo
|
|
|
|
echo "We have just pushed $VERSION to $(s3_url). You can download it with the following:"
|
|
|
|
echo
|
|
|
|
echo "Linux 64bit tgz: $(s3_url)/builds/Linux/x86_64/docker-$VERSION.tgz"
|
2016-06-13 11:55:06 -04:00
|
|
|
echo "Darwin/OSX 64bit client tgz: $(s3_url)/builds/Darwin/x86_64/docker-$VERSION.tgz"
|
|
|
|
echo "Windows 64bit zip: $(s3_url)/builds/Windows/x86_64/docker-$VERSION.zip"
|
2016-04-04 09:27:14 -04:00
|
|
|
echo "Windows 32bit client zip: $(s3_url)/builds/Windows/i386/docker-$VERSION.zip"
|
2013-12-24 01:31:53 -05:00
|
|
|
echo
|