forked from signalfx/signalfx-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease
executable file
·44 lines (33 loc) · 1.08 KB
/
release
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
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
version_from_metadata() {
grep -E "^version" $SCRIPT_DIR/metadata.rb | sed -Ee "s/version '(.*)'/\1/"
}
run_knife_command() {
docker run \
--rm \
-v $SCRIPT_DIR:/chef-repo/cookbooks/signalfx_agent \
-v $HOME/.chef:/root/.chef \
--workdir /chef-repo \
signalfx-agent-chef-dev \
knife $@
}
has_existing_version() {
run_knife_command supermarket show signalfx_agent --format json | \
jq -r '.versions' | \
sed -Ee 's@"https://.*([0-9]\.[0-9]\.[0-9])"$@\1@' | \
grep $(version_from_metadata)
}
make -C $SCRIPT_DIR dev-image
if has_existing_version; then
echo "Version $(version_from_metadata) already exists in the supermarket, please update metadata.rb to a new version" >&2
exit 1
fi
tag=chef-v$(version_from_metadata)
if ! git rev-parse $tag; then
git tag -a $tag
git push origin $tag
fi
run_knife_command supermarket share -o ./cookbooks signalfx_agent
echo "Cookbook version $(version_from_metadata) successfully uploaded to Supermarket"