Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions tasks/update_components.rake
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ def github_owner_repo(url)
[Regexp.last_match(1), Regexp.last_match(2).sub(/\.git$/, '')]
end

# Normalize a version string by stripping common tag prefixes.
# Normalize a version string by stripping common tag prefixes and
# replacing underscores with .
def normalize_version(tag)
return nil if tag.nil?

tag.sub(/\Av(?=\d)/, '')
.sub(/\Arefs\/tags\/v?/, '')
.sub(/\Arelease-/, '')
.sub(/\Aopenssl-/, '')
.sub(/\Acurl-/, '')
.gsub('_', '.')
end

# Try to parse a version from a normalized string, returning nil if unparseable.
Expand All @@ -50,11 +55,12 @@ end
# and somme people, like openssl, maintain multiple streams. So the latest tag might not be the highest version
# We do some version comparison to find the actual highest version
def latest_github_tag(owner, repo)
github_client.tags("#{owner}/#{repo}", per_page: 100)
.map { |tag| [tag.name, try_version(normalize_version(tag.name))] }
.reject { |_, version| version.nil? || version.prerelease? }
.max_by { |_, version| version }
.first
tags = github_client.tags("#{owner}/#{repo}", per_page: 100)
.map { |tag| [tag.name, try_version(normalize_version(tag.name))] }
.reject { |_, version| version.nil? || version.prerelease? }
.max_by { |_, version| version }

tags.nil? ? tags : tags.first
end

def current_version(data)
Expand Down