This repository was archived by the owner on Jul 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate
More file actions
executable file
·69 lines (56 loc) · 1.7 KB
/
Copy pathupdate
File metadata and controls
executable file
·69 lines (56 loc) · 1.7 KB
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
#!/usr/bin/env bash
set -euo pipefail
test=
force=
while getopts ':tf' opt; do
case "$opt" in
t)
test=true
;;
f)
force=true
;;
'?')
>&2 printf 'Invalid option: -%s\n' "$OPTARG"
exit 1
;;
esac
done
code='US'
latest_release="https://data.services.jetbrains.com/products/releases?code=$code&latest=true"
version_query="[.${code}[0].version, .${code}[0].build] | join(\".\")"
notes_query=".${code}[0].notesLink"
json="$(curl --silent --show-error "$latest_release")"
latest="$(jq --raw-output --exit-status "$version_query" <<< "$json")"
current="$(sed -ne 's/ARG VERSION=//p' Dockerfile)"
if ! notes="$(jq --raw-output --exit-status "$notes_query" <<< "$json")"; then
>&2 printf 'No release notes for version %s\n' "$latest"
notes=
fi
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 --label "test-build=$code" \
--force-rm \
--build-arg "VERSION=$latest" \
.; then
exit 2
fi
docker image ls --quiet \
--filter "label=test-build=$code" |
xargs --no-run-if-empty docker image rm
fi
printf 'Updating Dockerfile from version %s to version %s\n' "$current" "$latest"
sed -i "s/\(ARG VERSION=\).*/\1$latest/" Dockerfile
if [[ -n "$notes" ]]; then
message="$(printf 'Update to %s\n\nRelease notes: %s\n' "$latest" "$notes")"
else
message="$(printf 'Update to %s\n' "$latest")"
fi
git commit --message "$message" \
-- \
Dockerfile
git tag "$latest"