Check the latest version from the LATEST text file
This commit is contained in:
parent
e0b98189eb
commit
df4c9b4ae9
5
Rakefile
5
Rakefile
@ -147,11 +147,12 @@ AUTO_UPDATABLE = {
|
||||
'php82' => SlackBuilder::GitHub.new('php', 'php-src', php_transform),
|
||||
'rdiff-backup' => SlackBuilder::GitHub.new('rdiff-backup', 'rdiff-backup'),
|
||||
'librsync' => SlackBuilder::GitHub.new('librsync', 'librsync'),
|
||||
'jitsi-meet-desktop' => SlackBuilder::GitHub.new('jitsi', 'jitsi-meet-electron')
|
||||
'jitsi-meet-desktop' => SlackBuilder::GitHub.new('jitsi', 'jitsi-meet-electron'),
|
||||
'dmd' => SlackBuilder::LatestText.new('https://downloads.dlang.org/releases/LATEST')
|
||||
}.freeze
|
||||
|
||||
task :up2date do
|
||||
AUTO_UPDATABLE.each do |key, value|
|
||||
latest_version = SlackBuilder.check_for_latest key, value
|
||||
SlackBuilder.check_for_latest key, value
|
||||
end
|
||||
end
|
||||
|
@ -20,6 +20,7 @@ module SlackBuilder
|
||||
end
|
||||
end
|
||||
|
||||
# Reads the list fo tags from the GitHub API.
|
||||
class GitHub < Repository
|
||||
GITHUB_QUERY = <<~GQL
|
||||
query ($name: String!, $owner: String!) {
|
||||
@ -66,6 +67,7 @@ module SlackBuilder
|
||||
end
|
||||
end
|
||||
|
||||
# Request the latest version from the packagist API.
|
||||
class Packagist < Repository
|
||||
def initialize(vendor, name)
|
||||
super()
|
||||
@ -74,7 +76,6 @@ module SlackBuilder
|
||||
@name = name
|
||||
end
|
||||
|
||||
# Request the latest version from the packagist API.
|
||||
def latest
|
||||
full_name = [@vendor, @name].join '/'
|
||||
uri = URI "https://repo.packagist.org/p2/#{full_name}.json"
|
||||
@ -85,6 +86,22 @@ module SlackBuilder
|
||||
end
|
||||
end
|
||||
|
||||
# Reads a remote LATEST file.
|
||||
class LatestText < Repository
|
||||
def initialize(latest_url)
|
||||
super()
|
||||
|
||||
@latest_url = URI latest_url
|
||||
end
|
||||
|
||||
def latest
|
||||
response = Net::HTTP.get @latest_url, {
|
||||
'content-type' => 'text/plain'
|
||||
}
|
||||
response.strip
|
||||
end
|
||||
end
|
||||
|
||||
module_function
|
||||
|
||||
# Checks if there is a new version for the package and returns the latest
|
||||
|
Loading…
Reference in New Issue
Block a user