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] Find draft GitHub releases using tag #26

Merged
merged 2 commits into from
Nov 3, 2024

Conversation

MattSturgeon
Copy link
Contributor

@MattSturgeon MattSturgeon commented Nov 3, 2024

Draft releases are not found at the releases/tags/<tag> endpoint, but are still associated with the tag name.

If we can't find a release at releases/tags/<tag>, then we iterate through all releases looking for one with a matching tag name.

It may be better to come up with a GraphQL query instead of iterating through all releases via the REST API?

The GH CLI implements release fetching as: https://github.com/cli/cli/blob/30066b0042d0c5928d959e288144300cb28196c9/pkg/cmd/release/shared/fetch.go#L134-L161

The draft release lookup uses a GraphQL query: https://github.com/cli/cli/blob/30066b0042d0c5928d959e288144300cb28196c9/pkg/cmd/release/shared/fetch.go#L169-L200

Currently I'm unsure of what the best way to make a GraphQL request is in kohsuke github, although I wonder if this is fine as a stopgap here and fetching draft releases should later be implemented upstream using GraphQL?

I've opened hub4j/github-api#1983 upstream.

MattSturgeon and others added 2 commits November 3, 2024 20:37
Draft releases are not found at the `releases/tags/<tag>` endpoint, but
are still associated with the tag name.

If we can't find a release at `releases/tags/<tag>`, then we iterate
through all releases looking for one with a matching tag name.
@hypherionmc
Copy link
Member

hypherionmc commented Nov 3, 2024

Looks good :)

Currently I'm unsure of what the best way to make a GraphQL request is in kohsuke github

I think there is a whole different library required to work with GraphQL in java. I could be completely wrong about this. Will have to do some research on that

EDIT: Turns out it is possible to query GraphQL with standard HTTP libraries, but there are purpose built libraries for it

@hypherionmc hypherionmc merged commit 5f27b3c into firstdarkdev:dev Nov 3, 2024
@hypherionmc
Copy link
Member

Available on our snapshots maven as version 2.1.7+snapshot.0

@MattSturgeon MattSturgeon deleted the find-draft-releases branch November 3, 2024 23:10
@MattSturgeon
Copy link
Contributor Author

Thanks for merging and releasing so promptly 🚀

I'll try to look into getting a graphql implementation upstream, I've already documented a gql query for getting the release id in hub4j/github-api#1983.

If upstream ends up being slow or resistant to the change, then I'll look at adding a graphql implementation here instead.

If we get an upstream fix, I'll look at bumping the dependency and dropping the workaround here.


On a mostly unrelated note, maybe it would be better to use graphql for all GitHub requests and drop the dependency on hub4j/github-api? That way we end up only fetching the data we actually need. 🤔

@hypherionmc
Copy link
Member

On a mostly unrelated note, maybe it would be better to use graphql for all GitHub requests and drop the dependency on hub4j/github-api? That way we end up only fetching the data we actually need. 🤔

Hmmmm. Might not be a bad idea. We don't need all the features provided by github-api, so doing GraphQL would not only result in 1 less dependency (or well, a smaller dependency size), but giving us more control over what we want and how we want it.

I actually started working on version 3.0.0 a couple of days ago, rewriting most of the code base and implementing some of the stuff we talked about, so would be a perfect time to switch over

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.

2 participants