File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,27 @@ if [ -n "$GITHUB_TOKEN" ]; then
2020 GITHUB_AUTHORIZATION_HEADER=" Authorization: Bearer $GITHUB_TOKEN "
2121fi
2222
23- # get the tags JSON from the GitHub API and parse it manually,
24- # or output it to stderr if the server returns an error
23+ # try releases first (preferred), then fall back to tags
2524# per_page=100 is required for some repositories with a lot of beta tags
25+ github_releases=` curl \
26+ --silent --show-error --fail-with-body \
27+ --header " $GITHUB_AUTHORIZATION_HEADER " \
28+ https://api.github.com/repos/$GITHUB_REPO /releases? per_page=100`
29+
30+ if [ $? -eq 0 ]; then
31+ latest_release=` echo " $github_releases " \
32+ | grep ' "tag_name":' \
33+ | sed -E ' s/.*"([^"]+)".*/\1/' \
34+ | egrep " ^${TAG_PREFIX} [0-9]+[\\ ._-][0-9]+([\\ ._-][0-9]+)?\$ " \
35+ | head -n 1`
36+ if [ -n " $latest_release " ]; then
37+ echo " $latest_release "
38+ exit 0
39+ fi
40+ else
41+ echo " $github_releases " >&2
42+ fi
43+
2644github_tags=` curl \
2745 --silent --show-error --fail-with-body \
2846 --header " $GITHUB_AUTHORIZATION_HEADER " \
You can’t perform that action at this time.
0 commit comments