4 # This script looks for bundles built by make.sh, and releases them on a
7 # Bundles should be available for the VERSION string passed as argument.
9 # The correct way to call this script is inside a container built by the
10 # official Dockerfile at the root of the Docker source code. The Dockerfile,
11 # make.sh and release.sh should all be from the same source code revision.
15 # Print a usage message and exit.
19 - to be in a container generated by the Dockerfile at the top of the Docker
21 - to be provided with the location of an S3 bucket and path, in
22 environment variables AWS_S3_BUCKET and AWS_S3_BUCKET_PATH (default: '');
23 - to be provided with AWS credentials for this S3 bucket, in environment
24 variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY;
25 - a generous amount of good will and nice manners.
26 The canonical way to run me is to run the image produced by the Dockerfile: e.g.:"
28 docker run -e AWS_S3_BUCKET=test.docker.com \
29 -e AWS_ACCESS_KEY_ID \
30 -e AWS_SECRET_ACCESS_KEY \
31 -e AWS_DEFAULT_REGION \
33 docker ./hack/release.sh
38 [ "$AWS_S3_BUCKET" ] || usage
39 [ "$AWS_ACCESS_KEY_ID" ] || usage
40 [ "$AWS_SECRET_ACCESS_KEY" ] || usage
41 [ -d /go/src/github.com/docker/docker ] || usage
42 cd /go/src/github.com/docker/docker
43 [ -x hack/make.sh ] || usage
45 export AWS_DEFAULT_REGION
46 : ${AWS_DEFAULT_REGION:=us-west-1}
48 AWS_CLI=${AWS_CLI:-'aws'}
56 if [ "$1" != '--release-regardless-of-test-failure' ]; then
59 "${RELEASE_BUNDLES[@]}"
67 [[ -n "$AWS_S3_BUCKET_PATH" ]] && BUCKET_PATH+=/$AWS_S3_BUCKET_PATH
69 if command -v git &> /dev/null && git rev-parse &> /dev/null; then
70 if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
71 echo "You cannot run the release script on a repo with uncommitted changes"
76 # These are the 2 keys we've used to sign the deb's
77 # release (get.docker.com)
78 # GPG_KEY="36A1D7869245C8950F966E92D8576A8BA88D21E9"
79 # test (test.docker.com)
80 # GPG_KEY="740B314AE3941731B942C66ADF4FD13717AAD7D6"
84 # Try creating the bucket. Ignore errors (it might already exist).
85 $AWS_CLI s3 mb "s3://$BUCKET" 2>/dev/null || true
86 # Check access to the bucket.
87 $AWS_CLI s3 ls "s3://$BUCKET" >/dev/null
88 # Make the bucket accessible through website endpoints.
89 $AWS_CLI s3 website --index-document index --error-document error "s3://$BUCKET"
92 # write_to_s3 uploads the contents of standard input to the specified S3 url.
97 $AWS_CLI s3 cp --acl public-read --content-type 'text/plain' "$F" "$DEST"
103 get.docker.com|test.docker.com|experimental.docker.com)
104 echo "https://$BUCKET_PATH"
107 BASE_URL="http://${BUCKET}.s3-website-${AWS_DEFAULT_REGION}.amazonaws.com"
108 if [[ -n "$AWS_S3_BUCKET_PATH" ]] ; then
109 echo "$BASE_URL/$AWS_S3_BUCKET_PATH"
118 echo "Building release"
119 if ! ./hack/make.sh "${RELEASE_BUNDLES[@]}"; then
121 echo >&2 'The build or tests appear to have failed.'
123 echo >&2 'You, as the release maintainer, now have a couple options:'
124 echo >&2 '- delay release and fix issues'
125 echo >&2 '- delay release and fix issues'
126 echo >&2 '- did we mention how important this is? issues need fixing :)'
128 echo >&2 'As a final LAST RESORT, you (because only you, the release maintainer,'
129 echo >&2 ' really knows all the hairy problems at hand with the current release'
130 echo >&2 ' issues) may bypass this checking by running this script again with the'
131 echo >&2 ' single argument of "--release-regardless-of-test-failure", which will skip'
132 echo >&2 ' running the test suite, and will only build the binaries and packages. Please'
133 echo >&2 ' avoid using this if at all possible.'
135 echo >&2 'Regardless, we cannot stress enough the scarcity with which this bypass'
136 echo >&2 ' should be used. If there are release issues, we should always err on the'
137 echo >&2 ' side of caution.'
143 upload_release_build() {
149 echo "Uploading $src"
152 $AWS_CLI s3 cp --follow-symlinks --acl public-read "$src" "$dst"
153 if [ "$latest" ]; then
155 echo "Copying to $latest"
157 $AWS_CLI s3 cp --acl public-read "$dst" "$latest"
160 # get hash files too (see hash_files() in hack/make.sh)
161 for hashAlgo in md5 sha256; do
162 if [ -e "$src.$hashAlgo" ]; then
164 echo "Uploading $src.$hashAlgo"
165 echo " to $dst.$hashAlgo"
167 $AWS_CLI s3 cp --follow-symlinks --acl public-read --content-type='text/plain' "$src.$hashAlgo" "$dst.$hashAlgo"
168 if [ "$latest" ]; then
170 echo "Copying to $latest.$hashAlgo"
172 $AWS_CLI s3 cp --acl public-read "$dst.$hashAlgo" "$latest.$hashAlgo"
179 echo "Releasing binaries"
183 binDir=bundles/$VERSION/cross/$GOOS/$GOARCH
184 tgzDir=bundles/$VERSION/tgz/$GOOS/$GOARCH
185 binary=docker-$VERSION
191 if [ -z "$NOLATEST" ]; then
192 latestBase=docker-latest
195 # we need to map our GOOS and GOARCH to uname values
196 # see https://en.wikipedia.org/wiki/Uname
197 # ie, GOOS=linux -> "uname -s"=Linux
211 echo skipping solaris release
215 # this is windows use the .zip and .exe extensions for the files.
223 echo >&2 "error: can't convert $s3Os to an appropriate value for 'uname -s'"
238 # someday, we might potentially support multiple GOARM values, in which case we might get armhf here too
241 echo >&2 "error: can't convert $s3Arch to an appropriate value for 'uname -m'"
246 s3Dir="s3://$BUCKET_PATH/builds/$s3Os/$s3Arch"
249 if [ "$latestBase" ]; then
250 # commented out since we aren't uploading binaries right now.
251 # latest="$s3Dir/$latestBase$binaryExt"
252 # we don't include the $binaryExt because we don't want docker.exe.zip
253 latestTgz="$s3Dir/$latestBase$zipExt"
256 if [ ! -f "$tgzDir/$tgz" ]; then
257 echo >&2 "error: can't find $tgzDir/$tgz - was it packaged properly?"
260 # disable binary uploads for now. Only providing tgz downloads
261 # upload_release_build "$binDir/$binary" "$s3Dir/$binary" "$latest"
262 upload_release_build "$tgzDir/$tgz" "$s3Dir/$tgz" "$latestTgz"
265 # Upload binaries and tgz files to S3
267 [ "$(find bundles/$VERSION -path "bundles/$VERSION/cross/*/*/docker-$VERSION")" != "" ] || {
268 echo >&2 './hack/make.sh must be run before release_binaries'
272 for d in bundles/$VERSION/cross/*/*; do
273 GOARCH="$(basename "$d")"
274 GOOS="$(basename "$(dirname "$d")")"
275 release_build "$GOOS" "$GOARCH"
278 # TODO create redirect from builds/*/i686 to builds/*/i386
280 cat <<EOF | write_to_s3 s3://$BUCKET_PATH/builds/index
281 # To install, run the following commands as root:
282 curl -fsSLO $(s3_url)/builds/Linux/x86_64/docker-$VERSION.tgz && tar --strip-components=1 -xvzf docker-$VERSION.tgz -C /usr/local/bin
284 # Then start docker in daemon mode:
285 /usr/local/bin/dockerd
288 # Add redirect at /builds/info for URL-backwards-compatibility
289 rm -rf /tmp/emptyfile && touch /tmp/emptyfile
290 $AWS_CLI s3 cp --acl public-read --website-redirect '/builds/' --content-type='text/plain' /tmp/emptyfile "s3://$BUCKET_PATH/builds/info"
292 if [ -z "$NOLATEST" ]; then
293 echo "Advertising $VERSION on $BUCKET_PATH as most recent version"
294 echo "$VERSION" | write_to_s3 "s3://$BUCKET_PATH/latest"
298 # Upload the index script
300 echo "Releasing index"
301 url="$(s3_url)/" hack/make.sh install-script
302 write_to_s3 "s3://$BUCKET_PATH/index" < "bundles/$VERSION/install-script/install.sh"
306 [ "$SKIP_RELEASE_BUILD" = '1' ] || build_all
316 echo "Release complete; see $(s3_url)"
317 echo "Use the following text to announce the release:"
319 echo "We have just pushed $VERSION to $(s3_url). You can download it with the following:"
321 echo "Linux 64bit tgz: $(s3_url)/builds/Linux/x86_64/docker-$VERSION.tgz"
322 echo "Darwin/OSX 64bit client tgz: $(s3_url)/builds/Darwin/x86_64/docker-$VERSION.tgz"
323 echo "Windows 64bit zip: $(s3_url)/builds/Windows/x86_64/docker-$VERSION.zip"
324 echo "Windows 32bit client zip: $(s3_url)/builds/Windows/i386/docker-$VERSION.zip"