Reputation: 637
For my discord.js bot I want a way to get the latest GitHub release date, but the repo is private on an organization and I want a simple way, maybe using child_process.exec
could do that but I don't find anything on the Internet.
I just want the date, in timestamp or in a string.
Upvotes: 1
Views: 1307
Reputation: 1323363
You could use a HTTP request to the GitHub release API
GET /repos/{owner}/{repo}/releases/latest
// Example
https://api.github.com/repos/{owner}/{repo}/releases/latest
Then answer will include:
"created_at": "2013-02-27T19:35:32Z",
"published_at": "2013-02-27T19:35:32Z",
The publication date should be the one you want.
Using the more recent GitHub CLI gh
:
# GitHub CLI api
# https://cli.github.com/manual/gh_api
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/OWNER/REPO/releases/latest
Example for genotrance/px
releases:
gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/genotrance/px/releases/latest --jq ".published_at"
2023-02-07T15:59:14Z
Upvotes: 1