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

Adds latest #2

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
version:
- 0.16.2
- 0.16.3
- latest
steps:
- uses: actions/checkout@v4
- uses: ./
Expand All @@ -62,6 +63,7 @@ jobs:
version:
- 0.16.2
- 0.16.3
- latest
steps:
- uses: actions/checkout@v4
- uses: ./
Expand Down
5 changes: 3 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ inputs:
nimble-version:
description: >-
The Nimble version to download.
Examples: '0.16.2', '0.16.3'
required: true
Examples: '0.16.3', 'latest'
default: 'latest'
required: false
nimble-install-directory:
description: >-
The Nimble installation directory.
Expand Down
20 changes: 17 additions & 3 deletions install_nimble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ fetch_tags() {
-H "Authorization: Bearer ${repo_token}" \
-H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/nim-lang/nimble/git/refs/tags |
jq -r '.[].ref' |
sed -E 's:^refs/tags/v::'
sed -E 's:^refs/tags/v::' |
sed -E 's:^refs/tags/::' |
grep -E '^[0-9]+\.[0-9]+(\.[0-9]+)?$'
}

tag_regexp() {
Expand All @@ -35,6 +37,13 @@ latest_version() {
sort -V | tail -n 1
}

print_available_versions() {
info "Available Nimble versions:"
fetch_tags | while read -r version; do
echo " - $version"
done
}

# parse commandline args
nimble_version=""
nimble_install_dir=".nimble_runtime"
Expand Down Expand Up @@ -75,9 +84,14 @@ fi

cd "$parent_nimble_install_dir"

# get exact version if stable
if [[ "$nimble_version" = "stable" ]]; then
# Print available versions
# print_available_versions

# get exact version
if [[ "$nimble_version" = "latest" ]]; then
info "Finding latest version..."
nimble_version=$(fetch_tags | latest_version)
info "Latest version is: $nimble_version"
elif [[ "$nimble_version" =~ ^[0-9]+\.[0-9]+\.x$ ]] || [[ "$nimble_version" =~ ^[0-9]+\.x$ ]]; then
nimble_version="$(fetch_tags | grep -E "$(tag_regexp "$nimble_version")" | latest_version)"
fi
Expand Down
Loading