This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate
executable file
·67 lines (53 loc) · 1.66 KB
/
update
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
#!/usr/bin/env bash
set -euo pipefail
test=
force=
while getopts ':tf' opt; do
case "$opt" in
t)
test=true
;;
f)
force=true
;;
'?')
printf 'Invalid option: -%s\n' "$OPTARG"
exit 1
;;
esac
done
code='TC'
latest_release="https://data.services.jetbrains.com/products/releases?code=$code&latest=true"
version_query=".${code}[0].version"
notes_query=".${code}[0].notesLink"
json="$(curl --silent --show-error "$latest_release")"
latest="$(echo "$json" | jq --raw-output --exit-status "$version_query")"
current="$(sed -ne 's/ARG VERSION=//p' Dockerfile)"
notes="$(echo "$json" | jq --raw-output --exit-status "$notes_query")"
if [[ "$current" == "$latest" ]]; then
printf '%s is still the latest release\n' "$current"
[[ -z "$force" ]] && exit
fi
if [[ -n "$test" ]]; then
printf 'Testing docker build with version %s\n' "$latest"
if ! docker image build --tag "agross/teamcity:$latest" \
--tag agross/teamcity:latest \
--force-rm \
--build-arg "VERSION=$latest" \
.; then
exit 2
fi
for image in "agross/teamcity:$latest" agross/teamcity:latest; do
if ! docker image push "$image"; then
printf 'Pushing image %s failed. Are you logged in?\n' "$image"
fi
docker image rm "$image"
done
fi
printf 'Updating Dockerfile from version %s to version %s\n' "$current" "$latest"
sed -i "s/\(ARG VERSION=\).*/\1$latest/" Dockerfile
message="$(printf 'Update to %s\n\nRelease notes: %s\n' "$latest" "$notes")"
git commit --message "$message" \
-- \
Dockerfile
git tag "$latest"