-
Notifications
You must be signed in to change notification settings - Fork 1
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
Update release fetching to optionally match tags with a platform component #32
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,31 @@ def self.assert_branch_has_changes(release_branch) | |
|
||
changed_files.any? | ||
end | ||
|
||
def self.latest_release(repo_name, prerelease, platform = nil, github_token) | ||
client = Octokit::Client.new(access_token: github_token) | ||
|
||
current_page = 1 | ||
page_size = 25 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happy to change this to something else, but I feel that 25 should be enough to always find the latest public release for a given platform. |
||
|
||
loop do | ||
releases = client.releases(repo_name, per_page: page_size, page: current_page) | ||
break if releases.empty? | ||
|
||
# If `prerelease` is true, return the latest release that matches the platform regardless of whether it's public. | ||
# If `prerelease` is false, then ensure that the release is public. | ||
matching_release = releases.find do |release| | ||
(prerelease || !release.prerelease) && (platform.nil? || release.tag_name.end_with?("+#{platform}")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming we're fine to check for |
||
end | ||
|
||
return matching_release if matching_release | ||
break if releases.size < page_size | ||
|
||
current_page += 1 | ||
end | ||
|
||
return nil | ||
end | ||
end | ||
end | ||
end |
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.
I'll probably change the
prerelease
parameter name - what it's really doing it controlling whether the function only looks for a public release, or instead looks for the most recent available release regardless of internal/public status.