This pull request includes significant changes to the
`.github/scripts/update_mod_versions.py` script and updates to several
`meta.json` files for various mods. The changes aim to improve the
version checking mechanism and handle GitHub API rate limits more
effectively.
### Improvements to version checking and API rate limit handling:
*
[`.github/scripts/update_mod_versions.py`](diffhunk://#diff-ce76f7bf74b62aaea873670c15651b4caec6662ded3cc8e597cb7e2b1eac67c7L27-R94):
Refactored `get_latest_release` and `get_latest_commit` functions into a
single `get_version_string` function to handle both release and commit
version checks. Added logic to handle GitHub API rate limits and
retries.
[[1]](diffhunk://#diff-ce76f7bf74b62aaea873670c15651b4caec6662ded3cc8e597cb7e2b1eac67c7L27-R94)
[[2]](diffhunk://#diff-ce76f7bf74b62aaea873670c15651b4caec6662ded3cc8e597cb7e2b1eac67c7L109-R146)
*
[`.github/scripts/update_mod_versions.py`](diffhunk://#diff-ce76f7bf74b62aaea873670c15651b4caec6662ded3cc8e597cb7e2b1eac67c7L109-R146):
Modified `process_mods` function to determine the version source based
on the download URL, and updated the function signature to include a
start timestamp parameter.
*
[`.github/scripts/update_mod_versions.py`](diffhunk://#diff-ce76f7bf74b62aaea873670c15651b4caec6662ded3cc8e597cb7e2b1eac67c7L166-R198):
Updated the `generate_commit_message` function to include a start
timestamp for better logging.
### Workflow and environment updates:
*
[`.github/workflows/update-mod-versions.yml`](diffhunk://#diff-08c6175ddce4a9d49c79d12925be3c4f705913aadcd437a10b8bde3bde8fe740R29-R30):
Added `GITHUB_TOKEN` environment variable to the workflow for
authenticated API requests.
### Mod version updates:
* Updated the `version` field in `meta.json` files for multiple mods to
reflect the latest commit hashes:
* `mods/Agoraaa@FlushHotkeys/meta.json`
* `mods/Aure@SixSuits/meta.json`
* `mods/BataBata3@PampaPack/meta.json`
* `mods/Betmma@BetmmaMods/meta.json`
* `mods/Coo29@Yippie/meta.json`
* `mods/DarkAutumn2618@PlanetNine/meta.json`
* `mods/DigitalDetective47@CustomSuitOrder/meta.json`
* `mods/DigitalDetective47@NextAntePreview/meta.json`
* `mods/DigitalDetective47@StrangeLibrary/meta.json`
* `mods/DigitalDetective47@StrangePencil/meta.json`
* `mods/EnderGoodra@Textile/meta.json`
* `mods/Eremel@Galdur/meta.json`
* `mods/Eremel@Malverk/meta.json`
* `mods/GauntletGames-2086@D6Jokers/meta.json`
* `mods/GitNether@Paperback/meta.json`
* `mods/HuyTheKiller@SauKhongHuDecks/meta.json`
* `mods/HuyTheKiller@VietnameseBalatro/meta.json`
* `mods/InertSteak@Pokermon/meta.json`
Currently, the mod index will prioritise using the name of the tag from
the latest release version, regardless of the download source provided
by the mod. This is problematic for mods using a link to HEAD
(`archive/refs/heads/<main>.zip`) as their `downloadURL` but that also
have previously created a Release. This PR instead checks if the mod
links to HEAD, and uses the corresponding version.
Also included are improvements to error logging and wait time checks
when the GitHub REST API rate limits are hit, which appears to be
happening with inconsistent frequency. Hopefully these improvements will
help to narrow down the cause of the rate limit problems.
- Check if download url links to latest head, and if so, use version of
latest commit hash instead of release version
- Merge `get_latest_release` and `get_latest_commit` into
`get_version_string` for less duplicate code
- Check and print GitHub API rate limit details given by REST response
including api resource, remaining calls, and reset time
- On exceeding rate limit or 403 error, check if primary or secondary
rate limit has been reached
- On primary rate limit breach, wait until hourly rate reset time
- On secondary rate limit breach, wait for `retry-after` response time
or an exponential time, starting at 60 seconds and doubling for each
attempt (following requirements from GitHub API docs)
- Prevent program waiting for more than 30 minutes for API rate reset
time
- Check if download url links to latest head, and if so, use version of latest commit hash instead of release version
- Merge `get_latest_release` and `get_latest_commit` into `get_version_string` for less duplicate code
- Check and print GitHub API rate limit details including api resource, remaining calls, and reset time
- On exceeding rate limit or 403 error, check if primary or secondary rate limit has been reached
- On primary rate limit breach, wait until hourly rate reset time
- On secondary rate limit breach, wait for `retry-after` response time or an exponential time, starting at 60 seconds and doubling for each attempt, following GitHub API docs
- Prevent program waiting for more than 30 minutes for API rate reset time