Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch list of available versions from scala github repo #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 48 additions & 24 deletions bin/list-all
Original file line number Diff line number Diff line change
@@ -1,29 +1,53 @@
#!/usr/bin/env bash

versions_list=(
2.12.0-M4
2.12.0-M3
2.12.0-M2
2.12.0-M1
2.11.8
2.11.7
2.11.6
2.11.5
2.11.4
2.11.2
2.11.1
2.11.0
2.11.0-RC4
2.11.0-RC3
2.11.0-RC1
2.11.0-M8
)
# Setup: Pretty much the same as https://github.com/asdf-vm/asdf-elixir/blob/master/bin/list-all
# Note that the DMD repository returns an empty array for releases, so I used tags instead
releases_path="https://api.github.com/repos/scala/scala/tags?per_page=100"
cmd="curl -s"
if [ -n "$OAUTH_TOKEN" ]; then
cmd="$cmd -H 'Authorization: token $OAUTH_TOKEN'"
fi
cmd="$cmd \"$releases_path\""

versions = ""

for version in "${versions_list[@]}"
do
versions="${versions} ${version}"
done
sort_cmd='sort'
if sort --help | grep -q -- '-V'; then
sort_cmd='sort -V'
fi

# Extract only Version 2 releases that are not beta or rc.
# Note that line numbers need to be removed from the grep result.
versions=$(eval $cmd | grep -oE "name\": \"v2\..{1,6}\"," | sed 's/name\": \"v//;s/\",//;s/-b.*$//;s/-rc.*$//;s/beta.*$//' | uniq | $sort_cmd)
if [ -z "$versions" ]; then
# In some unknown occasion, versions happen to be empty.
# To avoid this, if versions is empty, show hard-coded list of versions
# from 2.12.0 up to 2.13.6.
versions_list=(
2.13.6
2.13.5
2.13.3
2.13.2
2.13.2
2.13.1
2.12.14
2.12.13
2.12.12
2.12.11
2.12.10
2.12.9
2.12.8
2.12.7
2.12.6
2.12.5
2.12.4
2.12.3
2.12.2
2.12.1
2.12.0
)
versions=""
for version in "${versions_list[@]}"
do
versions="${versions} ${version}"
done
fi
echo $versions