Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

lf-
Copy link

@lf- lf- commented Jan 19, 2024

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

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"
Copy link
Owner

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.

Copy link
Owner

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

Copy link
Author

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.

Copy link
Author

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!

Copy link
Author

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.

@lf-
Copy link
Author

lf- commented Feb 4, 2024

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.

@lf- lf- closed this Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants