What's Changed
- Make authenticated GitHub API request by @CsBigDataHub in #2
New Contributors
- @CsBigDataHub made their first contribution in #2
Full Changelog: v1.0.1...v1.0.2
Add a new helper.github_request(url) to centralize GitHub API calls with optional
authentication and improved error handling. The helper will:
- read GitHub tokens from GITHUB_TOKEN, GH_TOKEN, or GITHUB_API_TOKEN environment variables and set an Authorization Bearer header when present
- always set a User-Agent header required by the GitHub API
- perform an http.get with provided headers and return (resp, nil) on success or (nil, err_msg) on failure
- return a helpful message for 403 responses (rate limit exceeded) and suggest setting a token when unauthenticated
- return an error for non-200 status codes and propagate HTTP request errors
Use the new helper in hooks:
- hooks/available.lua: require helper and replace direct http.get with helper.github_request for release listing; simplify error handling and decoding of resp.body
- hooks/pre_install.lua: require helper and replace manual OS/arch normalization with helper.get_os() and helper.get_arch(); use helper.github_request to fetch the .sha256 checksum and handle the possibility of nil responses; remove direct http usage
Update README.md:
- add "GitHub API Rate Limiting" section explaining how to set a personal access token via environment variables (GITHUB_TOKEN, GH_TOKEN, or GITHUB_API_TOKEN) with examples and a link to create a token on GitHub
Other small changes:
- remove unused local http requires from modified hooks
- adjust error messages and condition checks around API responses to use the helper's return conventions