-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathautoupdate
executable file
·81 lines (64 loc) · 1.62 KB
/
autoupdate
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
#!/bin/bash
# This script automatically creates commits and tags for each Docker version
export DOCKERHOST="docker.io"
export DOCKERHUB="koalaman/shellcheck"
commit_message="ShellCheck \$VERSION"
info() {
# shellcheck disable=SC2059
printf >&2 "$1\\n" "${@:2}"
}
die() {
info "$@"
exit 1
}
should_regenerate=0
for arg
do
case "$arg" in
--regenerate-all) should_regenerate=1 ;;
*)
die "Unknown option: %s" "$arg"
exit 1
;;
esac
done
has_tag() {
git rev-parse "$1" > /dev/null 2>&1
}
make_tag() {
if has_tag "$VERSION"
then
if (( should_regenerate ))
then
info "Deleting existing tag %s, but leaving commit alone." "$VERSION"
git tag -d "$VERSION" || die "Failed to delete tag"
else
info "Skipping existing tag %s" "$VERSION"
return 0
fi
fi
{
echo "# This file was autogenerated, see pre-commit-hooks.yaml.template and autoupdate"
envsubst < "pre-commit-hooks.yaml.template"
} > ".pre-commit-hooks.yaml" || die "Failed to fill in hook template"
envsubst < "README.md.template" > "README.md" ||
die "Failed to fill in README template"
git commit -a -m "$(envsubst <<< "$commit_message")" ||
die "Failed to commit"
git tag "$VERSION" ||
die "Failed to tag"
}
fetch_tags() {
curl "https://registry.hub.docker.com/v2/repositories/$DOCKERHUB/tags" |
jq -r '.results[].name' |
grep '^v' |
sort -V
}
while read -r version
do
export VERSION=$version
make_tag
done < <(fetch_tags)
latest=$(git describe FETCH_HEAD --tags --abbrev=0) ||
die "git describe failed"
info "Done: the latest version is %s" "$latest"