Skip to content

Conversation

@hash-d
Copy link
Member

@hash-d hash-d commented Nov 24, 2025

This is one of two options for allowing to install the latest v1 CLI via install.sh

The other is #109.

On this option, an incomplete version specification (1, 1.8, 2 or 2.0, for example) triggers the discovery of the latest release in that version line.

Copy link
Member

@pwright pwright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer this approach as it can be used to test eg 2.0

However, to avoid problems in non bash, consider:

*)
        # 1. Safe write (standard POSIX)
        echo "${version}" > "${release_version_file}"

        # 2. Check if input is a partial version (X or X.Y)
        if expr "${version}" : '^[0-9]\+\(\.[0-9]\+\)\?$' > /dev/null; then
            log "Looking up the latest release in line ${version}"
            assert program_is_available jq

            # 3. Add per_page=100 to increase history limit
            # 4. Use 'try' in jq to prevents crashes on weird tag names
            run curl -sL \
                -H "Accept: application/vnd.github+json" \
                -H "X-GitHub-Api-Version: 2022-11-28" \
                "https://api.github.com/repos/skupperproject/skupper/releases?per_page=100" \
                | jq -r "map(select((.prerelease or .draft) | not)) 
                       | map(select(.name | startswith(\"${version}.\"))) 
                       | map(select(.name | test(\"^[0-9.]+\$\"))) 
                       | sort_by(.name | split(\".\") | map(try tonumber catch 0)) 
                       | .[-1].name // empty" \
                > "${release_version_file}"

            # 5. Proper empty check
            if [ ! -s "${release_version_file}" ] || [ "$(cat "${release_version_file}")" = "null" ]; then
                fail "No releases found in line '${version}'"
            fi
        fi
        ;;

@pwright pwright self-requested a review December 4, 2025 12:17
Copy link
Member

@pwright pwright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given we're only supporting bash, approving

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants