forked from aws/amazon-ecs-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstage
executable file
·113 lines (99 loc) · 2.56 KB
/
stage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
# Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the
# "License"). You may not use this file except in compliance
# with the License. A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and
# limitations under the License.
set -e
DRYRUN=true
SKIP_REBUILD=false
IMAGE_NAME=""
AWS_PROFILE=""
S3_BUCKET=""
S3_ACL_OVERRIDE=""
source $(dirname "${0}")/publishing-common.sh
usage() {
echo "Usage: ${0} -b BUCKET [OPTIONS]"
echo
echo "This script is responsible for staging new versions of the Amazon ECS Container Agent."
echo "1. (Optionally) Push the image to a registry, tagged with :latest, :VERSION, and :SHA"
echo "2. Push the image (and its md5sum) to S3 with -latest, -VERSION, and -SHA"
echo
echo "Options"
echo " -d true|false Dryrun (default is true)"
echo " -p PROFILE AWS CLI Profile (default is none)"
echo " -b BUCKET AWS S3 Bucket"
echo " -a ACL AWS S3 Object Canned ACL (default is public-read)"
echo " -i IMAGE Docker image name"
echo " -s Skip re-build"
echo " -h Display this help message"
}
stage_s3() {
tarball="$(mktemp)"
tarball_md5="$(mktemp)"
docker save "amazon/amazon-ecs-agent:latest" > "${tarball}"
md5sum "${tarball}" | sed 's/ .*//' > "${tarball_md5}"
echo "Saved with md5sum $(cat ${tarball_md5})"
for tag in ${IMAGE_TAG_VERSION} ${IMAGE_TAG_SHA} ${IMAGE_TAG_LATEST}; do
echo "Publishing as ecs-agent-${tag}"
dryval s3_cp "${tarball}" "s3://${S3_BUCKET}/ecs-agent-${tag}.tar"
dryval s3_cp "${tarball_md5}" "s3://${S3_BUCKET}/ecs-agent-${tag}.tar.md5"
done
rm "${tarball}"
rm "${tarball_md5}"
}
while getopts ":d:p:b:i:a:sh" opt; do
case ${opt} in
d)
if [[ "${OPTARG}" = "false" ]]; then
DRYRUN=false
fi
;;
p)
AWS_PROFILE="${OPTARG}"
;;
b)
S3_BUCKET="${OPTARG}"
;;
a)
S3_ACL_OVERRIDE="${OPTARG}"
;;
i)
IMAGE_NAME="${OPTARG}"
;;
s)
SKIP_REBUILD=true
;;
\?)
echo "Invalid option -${OPTARG}" >&2
usage
exit 1
;;
:)
echo "Option -${OPTARG} requires an argument." >&2
usage
exit 1
;;
h)
usage
exit 0
;;
esac
done
if [ -z "${S3_BUCKET}" ]; then
usage
exit 1
fi
if ! $($SKIP_REBUILD); then
make release
fi
tag_and_push_docker
stage_s3