Browse code

Generate md5 and sha265 hashes when building, and upload them in hack/release.sh

Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au> (github: SvenDowideit)

Sven Dowideit authored on 2014/03/17 06:10:59
Showing 2 changed files
1 1
old mode 100644
2 2
new mode 100755
... ...
@@ -11,3 +11,11 @@ go build \
11 11
 	" \
12 12
 	./docker
13 13
 echo "Created binary: $DEST/docker-$VERSION"
14
+
15
+if command -v md5sum &> /dev/null; then
16
+	md5sum "$DEST/docker-$VERSION" > "$DEST/docker-$VERSION.md5"
17
+fi
18
+if command -v sha256sum &> /dev/null; then
19
+	sha256sum "$DEST/docker-$VERSION" > "$DEST/docker-$VERSION.sha256"
20
+fi
21
+
... ...
@@ -55,33 +55,16 @@ RELEASE_BUNDLES=(
55 55
 if [ "$1" != '--release-regardless-of-test-failure' ]; then
56 56
 	RELEASE_BUNDLES=( test "${RELEASE_BUNDLES[@]}" )
57 57
 fi
58
-
59
-if ! ./hack/make.sh "${RELEASE_BUNDLES[@]}"; then
60
-	echo >&2
61
-	echo >&2 'The build or tests appear to have failed.'
62
-	echo >&2
63
-	echo >&2 'You, as the release  maintainer, now have a couple options:'
64
-	echo >&2 '- delay release and fix issues'
65
-	echo >&2 '- delay release and fix issues'
66
-	echo >&2 '- did we mention how important this is?  issues need fixing :)'
67
-	echo >&2
68
-	echo >&2 'As a final LAST RESORT, you (because only you, the release maintainer,'
69
-	echo >&2 ' really knows all the hairy problems at hand with the current release'
70
-	echo >&2 ' issues) may bypass this checking by running this script again with the'
71
-	echo >&2 ' single argument of "--release-regardless-of-test-failure", which will skip'
72
-	echo >&2 ' running the test suite, and will only build the binaries and packages.  Please'
73
-	echo >&2 ' avoid using this if at all possible.'
74
-	echo >&2
75
-	echo >&2 'Regardless, we cannot stress enough the scarcity with which this bypass'
76
-	echo >&2 ' should be used.  If there are release issues, we should always err on the'
77
-	echo >&2 ' side of caution.'
78
-	echo >&2
79
-	exit 1
80
-fi
81
-
58
+	
82 59
 VERSION=$(cat VERSION)
83 60
 BUCKET=$AWS_S3_BUCKET
84 61
 
62
+# These are the 2 keys we've used to sign the deb's
63
+#   release (get.docker.io
64
+#	GPG_KEY="36A1D7869245C8950F966E92D8576A8BA88D21E9"
65
+#   test    (test.docker.io)
66
+#	GPG_KEY="740B314AE3941731B942C66ADF4FD13717AAD7D6"
67
+
85 68
 setup_s3() {
86 69
 	# Try creating the bucket. Ignore errors (it might already exist).
87 70
 	s3cmd mb s3://$BUCKET 2>/dev/null || true
... ...
@@ -114,12 +97,40 @@ s3_url() {
114 114
 	esac
115 115
 }
116 116
 
117
+build_all() {
118
+	if ! ./hack/make.sh "${RELEASE_BUNDLES[@]}"; then
119
+		echo >&2
120
+		echo >&2 'The build or tests appear to have failed.'
121
+		echo >&2
122
+		echo >&2 'You, as the release  maintainer, now have a couple options:'
123
+		echo >&2 '- delay release and fix issues'
124
+		echo >&2 '- delay release and fix issues'
125
+		echo >&2 '- did we mention how important this is?  issues need fixing :)'
126
+		echo >&2
127
+		echo >&2 'As a final LAST RESORT, you (because only you, the release maintainer,'
128
+		echo >&2 ' really knows all the hairy problems at hand with the current release'
129
+		echo >&2 ' issues) may bypass this checking by running this script again with the'
130
+		echo >&2 ' single argument of "--release-regardless-of-test-failure", which will skip'
131
+		echo >&2 ' running the test suite, and will only build the binaries and packages.  Please'
132
+		echo >&2 ' avoid using this if at all possible.'
133
+		echo >&2
134
+		echo >&2 'Regardless, we cannot stress enough the scarcity with which this bypass'
135
+		echo >&2 ' should be used.  If there are release issues, we should always err on the'
136
+		echo >&2 ' side of caution.'
137
+		echo >&2
138
+		exit 1
139
+	fi
140
+}
141
+
117 142
 release_build() {
118 143
 	GOOS=$1
119 144
 	GOARCH=$2
120 145
 
121
-	BINARY=bundles/$VERSION/cross/$GOOS/$GOARCH/docker-$VERSION
122
-	TGZ=bundles/$VERSION/tgz/$GOOS/$GOARCH/docker-$VERSION.tgz
146
+	SOURCE_DIR=bundles/$VERSION/cross/$GOOS/$GOARCH
147
+	BINARY=docker-$VERSION
148
+	BINARY_MD5=docker-$VERSION.md5
149
+	BINARY_SHA256=docker-$VERSION.sha256
150
+	TGZ=docker-$VERSION.tgz
123 151
 
124 152
 	# we need to map our GOOS and GOARCH to uname values
125 153
 	# see https://en.wikipedia.org/wiki/Uname
... ...
@@ -172,17 +183,29 @@ release_build() {
172 172
 	fi
173 173
 
174 174
 	echo "Uploading $BINARY to $S3OS/$S3ARCH/docker-$VERSION"
175
-	s3cmd --follow-symlinks --preserve --acl-public put $BINARY $S3DIR/docker-$VERSION
175
+	s3cmd --follow-symlinks --preserve --acl-public put $SOURCE_DIR/$BINARY $S3DIR/$BINARY
176
+
177
+	echo "Uploading $BINARY_MD5 to $S3OS/$S3ARCH/docker-$VERSION.md5"
178
+	s3cmd --follow-symlinks --preserve --acl-public put $SOURCE_DIR/$BINARY_MD5 $S3DIR/$BINARY_MD5
179
+
180
+	echo "Uploading $BINARY_BINARY_SHA256 to $S3OS/$S3ARCH/docker-$VERSION.sha256"
181
+	s3cmd --follow-symlinks --preserve --acl-public put $SOURCE_DIR/$BINARY_SHA256 $S3DIR/$BINARY_SHA256
176 182
 
177 183
 	echo "Uploading $TGZ to $S3OS/$S3ARCH/docker-$VERSION.tgz"
178
-	s3cmd --follow-symlinks --preserve --acl-public put $TGZ $S3DIR/docker-$VERSION.tgz
184
+	s3cmd --follow-symlinks --preserve --acl-public put $SOURCE_DIR/$TGZ $S3DIR/$TGZ
179 185
 
180 186
 	if [ -z "$NOLATEST" ]; then
181
-		echo "Copying $S3OS/$S3ARCH/docker-$VERSION to $S3OS/$S3ARCH/docker-latest"
182
-		s3cmd --acl-public cp $S3DIR/docker-$VERSION $S3DIR/docker-latest
187
+		echo "Copying $S3DIR/$BINARY to $S3DIR/docker-latest"
188
+		s3cmd --acl-public cp $S3DIR/$BINARY $S3DIR/docker-latest
183 189
 
184
-		echo "Copying $S3OS/$S3ARCH/docker-$VERSION.tgz to $S3OS/$S3ARCH/docker-latest.tgz"
185
-		s3cmd --acl-public cp $S3DIR/docker-$VERSION.tgz $S3DIR/docker-latest.tgz
190
+		echo "Copying $S3DIR/$BINARY_MD5 to $S3DIR/docker-latest.md5"
191
+		s3cmd --acl-public cp $S3DIR/$BINARY_MD5 $S3DIR/docker-latest.md5
192
+
193
+		echo "Copying $S3DIR/$BINARY_SHA256 to $S3DIR/docker-latest.sha256"
194
+		s3cmd --acl-public cp $S3DIR/$BINARY_SHA256 $S3DIR/docker-latest.sha256
195
+
196
+		echo "Copying $S3DIR/$TGZ $S3DIR/docker-latest.tgz"
197
+		s3cmd --acl-public cp $S3DIR/$TGZ $S3DIR/docker-latest.tgz
186 198
 	fi
187 199
 }
188 200
 
... ...
@@ -194,21 +217,8 @@ release_ubuntu() {
194 194
 		echo >&2 './hack/make.sh must be run before release_ubuntu'
195 195
 		exit 1
196 196
 	}
197
-	# Make sure that we have our keys
198
-	mkdir -p /.gnupg/
197
+	
199 198
 	s3cmd sync s3://$BUCKET/ubuntu/.gnupg/ /.gnupg/ || true
200
-	gpg --list-keys releasedocker >/dev/null || {
201
-		gpg --gen-key --batch <<EOF
202
-Key-Type: RSA
203
-Key-Length: 2048
204
-Passphrase: $GPG_PASSPHRASE
205
-Name-Real: Docker Release Tool
206
-Name-Email: docker@dotcloud.com
207
-Name-Comment: releasedocker
208
-Expire-Date: 0
209
-%commit
210
-EOF
211
-	}
212 199
 
213 200
 	# Sign our packages
214 201
 	dpkg-sig -g "--passphrase $GPG_PASSPHRASE" -k releasedocker \
... ...
@@ -305,14 +315,34 @@ release_test() {
305 305
 	fi
306 306
 }
307 307
 
308
+setup_gpg() {
309
+	# Make sure that we have our keys
310
+	mkdir -p /.gnupg/
311
+	gpg --list-keys releasedocker >/dev/null || {
312
+		gpg --gen-key --batch <<EOF
313
+Key-Type: RSA
314
+Key-Length: 2048
315
+Passphrase: $GPG_PASSPHRASE
316
+Name-Real: Docker Release Tool
317
+Name-Email: docker@dotcloud.com
318
+Name-Comment: releasedocker
319
+Expire-Date: 0
320
+%commit
321
+EOF
322
+	}
323
+}
324
+
308 325
 main() {
326
+	build_all
309 327
 	setup_s3
328
+	setup_gpg
310 329
 	release_binaries
311 330
 	release_ubuntu
312 331
 	release_index
313 332
 	release_test
314 333
 }
315 334
 
335
+
316 336
 main
317 337
 
318 338
 echo