diff --git a/install.ps1 b/install.ps1 index d946bf9..f34c17d 100644 --- a/install.ps1 +++ b/install.ps1 @@ -26,10 +26,20 @@ function Get-Arch { } function Get-LatestTag { - $url = "https://api.github.com/repos/$Repo/releases/latest" + # We publish two parallel release tracks under the same repo: + # v* — CLI binary releases (this script installs these). + # extension-v* — VS Code / Cursor extension .vsix releases. + # /releases/latest returns whichever was published most recently overall and + # can flip to an extension release any time we publish an extension after a + # CLI release — that yields the `extension-v*` tag and a 404 when this + # script tries to download `axme-code-$platform` from it. Fetch the list + # endpoint instead and filter to the first `v[0-9]…` tag. + $url = "https://api.github.com/repos/$Repo/releases?per_page=30" try { - $release = Invoke-RestMethod -Uri $url -Headers @{ 'User-Agent' = 'axme-code-installer' } - return $release.tag_name + $releases = Invoke-RestMethod -Uri $url -Headers @{ 'User-Agent' = 'axme-code-installer' } + $cliRelease = $releases | Where-Object { $_.tag_name -match '^v[0-9]' } | Select-Object -First 1 + if (-not $cliRelease) { throw "No CLI release (tag matching ^v[0-9]) found in the 30 most recent releases." } + return $cliRelease.tag_name } catch { throw "Failed to fetch latest release from $url : $($_.Exception.Message)" } diff --git a/install.sh b/install.sh index 3ae7e18..a46e817 100755 --- a/install.sh +++ b/install.sh @@ -27,11 +27,19 @@ detect_platform() { # Get latest release tag from GitHub API get_latest_version() { - local url="https://api.github.com/repos/${REPO}/releases/latest" + # We publish two parallel release tracks under the same repo: + # - `v*` — CLI binary releases (this script installs these). + # - `extension-v*` — VS Code / Cursor extension .vsix releases. + # `/releases/latest` returns the most recently published release overall and + # can flip to an extension release any time we publish an extension after a + # CLI release. That returns the `extension-v*` tag, and the binary download + # URL `axme-code-${platform}` 404s because the extension release only ships + # `.vsix` files. Fetch the recent list and filter to the first `v[0-9]…` tag. + local url="https://api.github.com/repos/${REPO}/releases?per_page=30" if command -v curl &>/dev/null; then - curl -fsSL "$url" | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"//;s/".*//' + curl -fsSL "$url" | grep '"tag_name"' | sed 's/.*"tag_name": *"//;s/".*//' | grep -E '^v[0-9]' | head -1 elif command -v wget &>/dev/null; then - wget -qO- "$url" | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"//;s/".*//' + wget -qO- "$url" | grep '"tag_name"' | sed 's/.*"tag_name": *"//;s/".*//' | grep -E '^v[0-9]' | head -1 else echo "Neither curl nor wget found" >&2; exit 1 fi