Skip to content

Commit

Permalink
Use releases to derive version list (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbode authored May 8, 2024
1 parent 95e67f5 commit 9549b24
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions bin/list-all
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,28 @@ sort_versions() {
}

list_all_versions() {
git ls-remote --tags --refs https://github.com/python-poetry/poetry.git |
grep -o 'refs/tags/.*' |
cut -d/ -f3- |
sed 's/^v//'
local RELEASES_PATH="https://api.github.com/repos/python-poetry/poetry/releases?per_page=100"
local NEXT_LINK='<([^\>]+)>; rel="next"'

local VERSION_RE='[0-9][^"]\+'
local LINE_RE
LINE_RE=$(printf '"tag_name": "%s"' "${VERSION_RE}")

if [[ -n ${GITHUB_TOKEN-} ]]; then
set -- "$@" -H "Authorization: Bearer ${GITHUB_TOKEN}"
fi

URL=${RELEASES_PATH}

while [[ -n ${URL} ]]; do
RESULT=$(curl -qsSfL --include "$@" "${URL}")
grep -o "${LINE_RE}" <<<"${RESULT}"
if LINK=$(grep -m1 '^link: ' <<<"${RESULT}") && [[ ${LINK} =~ ${NEXT_LINK} ]]; then
URL=${BASH_REMATCH[1]}
else
break
fi
done | grep -o "${VERSION_RE}"
}

list_all_versions | sort_versions | xargs echo

0 comments on commit 9549b24

Please sign in to comment.