-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: detect prereleases on GitHub so we can ignore them #221
Conversation
This is simple enough: we just use the GitHub releases API that does actually have the info in it. I have complained about the feed not having the info here: https://github.com/orgs/community/discussions/88765
tree = ET.fromstring(resp.read()) | ||
releases = tree.findall(".//{http://www.w3.org/2005/Atom}entry") | ||
# https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#list-releases | ||
releases_url = f"https://api.github.com/repos/{owner}/{repo}/releases?per_page=100" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we switch to the API we also need to accept GITHUB_TOKENS (potentially optional).
Otherwise people behind shared IPs will run into API limits easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also does this detect git tags? Not all projects use github releases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn, it doesn't, and that's really annoying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, we would have to use graphql to get commit info (or even date information) next to tags, and there's no way to get combined data between releases and tags aside from the very clever thing we're currently doing. This sucks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course:
query ($owner: String!, $name: String!, $curs: String!) {
repository(owner: $owner, name: $name) {
refs(
refPrefix: "refs/tags/"
after: $curs
first: 100
orderBy: {field: TAG_COMMIT_DATE, direction: DESC}
) {
nodes {
id
name
target {
oid
__typename
... on Commit {
author {
name
date
}
}
}
}
}
}
}
{
"data": {
"repository": {
"refs": {
"nodes": [
{
"id": "MDM6UmVmMjgwMTAyODYyOnJlZnMvdGFncy92MC42LjU=",
"name": "v0.6.5",
"target": {
"oid": "f0c17fdad5de2ae2d5893943bc437d56e459ea2e",
"__typename": "Commit",
"author": {
"name": "Jade Lovelace",
"date": "2024-02-03T21:34:44.000-08:00"
}
}
},
...
But I don't like this, among other reasons, because I believe it would mandate having github tokens always.
Ultimately I don't think there's a satisfactory solution here, because GitHub API sucks. Surprisingly there's not even a way to graphql the tags and get releases if present, which is the minimum I'd really expect! At best, the solution here looks to be to grab all recent tags, all recent releases, cross correlate these responses to get bonus data if present, and then stick it all together. Personally I don't have the energy for doing this at this time. |
This is simple enough: we just use the GitHub releases API that does actually have the info in it.
Uses this GitHub API which is fine to use unauthenticated: https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#list-releases
I have complained about the feed not having the info here: https://github.com/orgs/community/discussions/88765