Skip to content
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
6 changes: 6 additions & 0 deletions .simple-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class ArchgateProject extends NpmProject {
this.changedFiles.push(astroConfigPath);
}
}

// Sync docs/public/version.json (used by install scripts)
const versionJsonPath = "docs/public/version.json";
const versionPayload = `{ "version": "v${version}" }\n`;
writeFileSync(versionJsonPath, versionPayload);
this.changedFiles.push(versionJsonPath);
}

return result;
Expand Down
1 change: 1 addition & 0 deletions docs/public/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "version": "v0.17.0" }
20 changes: 18 additions & 2 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,27 @@ function Get-LatestVersion {
if ($env:ARCHGATE_VERSION) {
return $env:ARCHGATE_VERSION
}

# Primary: static version endpoint (no rate limits)
try {
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" -ErrorAction Stop
$versionInfo = Invoke-RestMethod -Uri "https://cli.archgate.dev/version.json" -ErrorAction Stop
if ($versionInfo.version) {
return $versionInfo.version
}
} catch {
# Fall through to GitHub API
}

# Fallback: GitHub releases API
try {
$headers = @{ "Accept" = "application/vnd.github+json" }
if ($env:GITHUB_TOKEN) {
$headers["Authorization"] = "token $($env:GITHUB_TOKEN)"
}
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" -Headers $headers -ErrorAction Stop
return $release.tag_name
} catch {
Write-Error "Error: failed to query GitHub for latest archgate version. Details: $($_.Exception.Message)"
Write-Error "Error: failed to query latest archgate version. Details: $($_.Exception.Message)"
return $null
}
}
Expand Down
31 changes: 29 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,39 @@ resolve_version() {
return
fi

# Primary: static version endpoint (no rate limits)
version_url="https://cli.archgate.dev/version.json"
static_response=""

if command -v curl >/dev/null 2>&1; then
static_response="$(curl -fsSL "$version_url" 2>/dev/null || true)"
elif command -v wget >/dev/null 2>&1; then
static_response="$(wget -qO- "$version_url" 2>/dev/null || true)"
fi

if [ -n "$static_response" ]; then
if command -v jq >/dev/null 2>&1; then
static_version="$(printf '%s' "$static_response" | jq -r '.version // empty')"
else
static_version="$(printf '%s' "$static_response" | grep '"version"' | sed 's/.*"version": *"//;s/".*//')"
fi
if [ -n "$static_version" ]; then
VERSION="$static_version"
return
fi
fi

# Fallback: GitHub releases API
api_url="https://api.github.com/repos/${REPO}/releases/latest"
auth_header=""
if [ -n "${GITHUB_TOKEN:-}" ]; then
auth_header="Authorization: token ${GITHUB_TOKEN}"
fi

if command -v curl >/dev/null 2>&1; then
response="$(curl -fsSL "$api_url" || true)"
response="$(curl -fsSL ${auth_header:+-H "$auth_header"} "$api_url" || true)"
elif command -v wget >/dev/null 2>&1; then
response="$(wget -qO- "$api_url" 2>/dev/null || true)"
response="$(wget -qO- ${auth_header:+--header="$auth_header"} "$api_url" 2>/dev/null || true)"
else
echo "Error: curl or wget is required." >&2
exit 1
Expand Down
Loading