fix: serve version from static endpoint to avoid GitHub API rate limits#112
Merged
Conversation
Unauthenticated requests to api.github.com are limited to 60/hour per IP. When GITHUB_TOKEN is set, both install.ps1 and install.sh now pass an Authorization header, raising the limit to 5,000/hour.
Deploying archgate-cli with
|
| Latest commit: |
f6605a2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3b7d36f8.archgate-cli.pages.dev |
| Branch Preview URL: | https://fix-install-github-token.archgate-cli.pages.dev |
Add a static `version.json` to the docs site (cli.archgate.dev) so install scripts can resolve the latest version without hitting the GitHub API, which rate-limits unauthenticated requests to 60/hour. - Add `docs/scripts/generate-version-json.ts` that reads the version from the root `package.json` and writes `docs/public/version.json` - Hook it into the docs build pipeline (`docs/package.json`) - Sync `version.json` in `.simple-release.js` during releases - Update `install.ps1` and `install.sh` to query `cli.archgate.dev/version.json` first, falling back to GitHub API (with optional GITHUB_TOKEN auth) if the static endpoint is unavailable
version.json is written by .simple-release.js on every version bump and committed to the repo, so regenerating it during docs build is redundant.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
version.jsonendpoint atcli.archgate.dev/version.jsonso install scripts can resolve the latest version without hitting the GitHub API (which rate-limits unauthenticated requests to 60/hour per IP, causing403 Forbiddenerrors)install.ps1andinstall.shnow query the static endpoint first, falling back to the GitHub API (with optionalGITHUB_TOKENauth) if unavailablepackage.jsonduring the docs build and synced by.simple-release.jsduring releasesChanges
docs/scripts/generate-version-json.ts— New script that reads version from rootpackage.jsonand writesdocs/public/version.jsondocs/package.json— Hooksgenerate-version-json.tsinto the docs build pipeline.simple-release.js— Syncsversion.jsonalongside other version references during releasesinstall.ps1— Queriescli.archgate.dev/version.jsonfirst, falls back to GitHub API with optionalGITHUB_TOKENheaderinstall.sh— Same primary/fallback strategy for both curl and wget pathsTest plan
bun run docs/scripts/generate-version-json.ts— generatesdocs/public/version.jsonwith correct versioninstall.ps1— resolves version from static endpoint (once deployed)install.sh(curl) — resolves version from static endpoint (once deployed)install.sh(wget) — resolves version from static endpoint (once deployed)cli.archgate.devand confirm GitHub API fallback worksGITHUB_TOKENauth header is passed in fallback path