forked from aws/amazon-ecs-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-version.sh
executable file
·86 lines (70 loc) · 3.04 KB
/
update-version.sh
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
#!/bin/bash
# Copyright 2014-2016 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.
# This script will update the information of the ecs-init during building
set -e -x
CURRENTDIR=$(dirname "${0}")
version=$(cat "${CURRENTDIR}"/../ecs-init/ECSVERSION)
git_hash=$(git rev-parse --short=8 HEAD)
git_dirty=false
if [[ "$(git status --porcelain)" != "" ]]; then
git_dirty=true
fi
cat << EOF > "${CURRENTDIR}"/../ecs-init/version/version.go
// This is an autogenerated file and should not be edited.
// Copyright 2014-2016 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.
// Package version contains constants to indicate the current version of the
// ecs-init. It is autogenerated.
package version
// Version is the version of the ecs-init
var Version string = "${version}"
// GitDirty indicates the cleanliness of the git repo when this ecs-init was built
var GitDirty string = "${git_dirty}"
// GitShortHash is the short hash of this ecs-init build
var GitShortHash string = "${git_hash}"
EOF
cat << EOF > "${CURRENTDIR}"/../agent/version/version.go
// This is an autogenerated file and should not be edited.
// Copyright 2014-2016 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.
// Package version contains constants to indicate the current version of the
// ecs-agent. It is autogenerated.
package version
// Version is the version of the ecs-agent
const Version = "${version}"
// GitDirty indicates the cleanliness of the git repo when this ecs-init was built
const GitDirty = ${git_dirty}
// GitShortHash is the short hash of this ecs-agent build
const GitShortHash = "${git_hash}"
EOF