homebrew_automation 0.1.10 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/homebrew_automation/bintray/client.rb +1 -1
- data/lib/homebrew_automation/bintray/version.rb +5 -2
- data/lib/homebrew_automation/bottle.rb +2 -0
- data/lib/homebrew_automation/cli/workflow_commands.rb +4 -1
- data/lib/homebrew_automation/git.rb +1 -1
- data/lib/homebrew_automation/mac_os.rb +3 -1
- data/lib/homebrew_automation/source_dist.rb +9 -2
- data/lib/homebrew_automation/version.rb +1 -1
- data/lib/homebrew_automation/workflow.rb +15 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 631a391dc1b239b9195b9dd9ae7dfe554a9d622afd3437b672716e27d599b70a
|
4
|
+
data.tar.gz: 0c40e8267deb8365212d2b60d976fadbf52c81c685fdba2d1404f473b8564405
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 302c739c1028ac4255fb2bd9e15e9f2979cc0df5dd67704795d6fcb3a58f391c790763813b83bc2242a40e9fb5eedf2f5bb8e3fab60a73523ab895130117a10c
|
7
|
+
data.tar.gz: f9f41c0cee062f606391ac04e28739754c027c6b6cb6eb9643dca876b7b1dc26c2fb9a593debaebb54215bc3b1c855414cecaeff07148b884a81dc89a70809c9
|
@@ -86,7 +86,7 @@ module HomebrewAutomation::Bintray
|
|
86
86
|
safe_pkg = URI.escape(package_name)
|
87
87
|
safe_ver = URI.escape(version_name)
|
88
88
|
@http.get(
|
89
|
-
rel("/packages/#{safe_username}/#{safe_repo}/#{safe_pkg}/versions/#{safe_ver}/files"),
|
89
|
+
rel("/packages/#{safe_username}/#{safe_repo}/#{safe_pkg}/versions/#{safe_ver}/files?include_unpublished=1"),
|
90
90
|
auth_headers)
|
91
91
|
end
|
92
92
|
|
@@ -16,11 +16,13 @@ module HomebrewAutomation::Bintray
|
|
16
16
|
end
|
17
17
|
|
18
18
|
# @param client [Client] Connection to Bintray servers
|
19
|
+
# @param logger [HomebrewAutomation::Logger]
|
19
20
|
# @param repo_name [String]
|
20
21
|
# @param package_name [String]
|
21
22
|
# @param version_name [String]
|
22
|
-
def initialize(client, repo_name, package_name, version_name)
|
23
|
+
def initialize(client, logger, repo_name, package_name, version_name)
|
23
24
|
@client = client
|
25
|
+
@logger = logger
|
24
26
|
@repo_name = repo_name
|
25
27
|
@package_name = package_name
|
26
28
|
@version_name = version_name
|
@@ -67,12 +69,13 @@ module HomebrewAutomation::Bintray
|
|
67
69
|
resp = @client.get_all_files_in_version(@repo_name, @package_name, @version_name)
|
68
70
|
_assert_match((200..207), resp.code)
|
69
71
|
json = JSON.parse(resp.body)
|
72
|
+
@logger.info!("All files in Bintray Version: #{json}")
|
70
73
|
_assert_match(Array, json)
|
71
74
|
pairs = json.map do |f|
|
72
75
|
os = _parse_for_os(f['name'])
|
73
76
|
checksum = f['sha256']
|
74
77
|
[os, checksum]
|
75
|
-
end
|
78
|
+
end.select { |o, _| not o.empty? }
|
76
79
|
Hash[pairs]
|
77
80
|
end
|
78
81
|
|
@@ -81,7 +81,9 @@ module HomebrewAutomation
|
|
81
81
|
begin
|
82
82
|
@brew.tap!(@tap_name, @tap_url)
|
83
83
|
tapped = true
|
84
|
+
# TODO: @brew.list! may print a worrying "Error" message if Formula wasn't installed:
|
84
85
|
if @brew.list!([], fully_qualified_formula_name)
|
86
|
+
# TODO: This doesn't seem to work. Carefully test.
|
85
87
|
# passing `--force` to uninstall all versions
|
86
88
|
@brew.uninstall!(['--force'], fully_qualified_formula_name)
|
87
89
|
end
|
@@ -52,7 +52,9 @@ class HomebrewAutomation::CLI::WorkflowCommands < Thor
|
|
52
52
|
sdist,
|
53
53
|
tap,
|
54
54
|
formula_name,
|
55
|
-
bintray_version
|
55
|
+
bintray_version,
|
56
|
+
git,
|
57
|
+
logger)
|
56
58
|
end
|
57
59
|
|
58
60
|
private
|
@@ -90,6 +92,7 @@ class HomebrewAutomation::CLI::WorkflowCommands < Thor
|
|
90
92
|
def bintray_version
|
91
93
|
HomebrewAutomation::Bintray::Version.new(
|
92
94
|
bintray_client,
|
95
|
+
logger,
|
93
96
|
options[:bintray_repo] || "homebrew-bottles",
|
94
97
|
options[:bintray_package] || sdist.repo,
|
95
98
|
options[:bintray_version] || sdist.tag.sub(/^v/, ''))
|
@@ -49,7 +49,7 @@ module HomebrewAutomation
|
|
49
49
|
# @param keep_dir [Boolean]
|
50
50
|
# @yieldparam dir [String] name of freshly cloned dir
|
51
51
|
# @yieldreturn [a] anything
|
52
|
-
# @return [
|
52
|
+
# @return [NilClass]
|
53
53
|
def with_clone!(url, dir, keep_dir: false, &block)
|
54
54
|
begin
|
55
55
|
clone! url, dir: dir
|
@@ -6,6 +6,9 @@ module HomebrewAutomation
|
|
6
6
|
# A representation of a source distribution tarball file
|
7
7
|
class SourceDist
|
8
8
|
|
9
|
+
class Error < StandardError
|
10
|
+
end
|
11
|
+
|
9
12
|
# Assign args to attributes {#user}, {#repo}, {#tag}
|
10
13
|
def initialize user, repo, tag, http: RestClient
|
11
14
|
@user = user
|
@@ -38,6 +41,9 @@ module HomebrewAutomation
|
|
38
41
|
@sha256 ||= Digest::SHA256.hexdigest contents
|
39
42
|
end
|
40
43
|
|
44
|
+
class SdistDoesNotExist < StandardError
|
45
|
+
end
|
46
|
+
|
41
47
|
# Download and return the file contents.
|
42
48
|
#
|
43
49
|
# Lazy and memoized.
|
@@ -51,9 +57,10 @@ module HomebrewAutomation
|
|
51
57
|
when 200
|
52
58
|
resp.body.to_s
|
53
59
|
else
|
54
|
-
|
55
|
-
raise StandardError.new resp.code
|
60
|
+
raise Error.new "Other error: HTTP #{resp.code}"
|
56
61
|
end
|
62
|
+
rescue RestClient::NotFound
|
63
|
+
raise SdistDoesNotExist.new
|
57
64
|
end
|
58
65
|
end
|
59
66
|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
|
2
2
|
require_relative './mac_os.rb'
|
3
3
|
require_relative './bottle.rb'
|
4
|
+
require_relative './brew.rb'
|
5
|
+
require_relative './git.rb'
|
6
|
+
require_relative './source_dist.rb'
|
4
7
|
|
5
8
|
module HomebrewAutomation
|
6
9
|
|
@@ -40,6 +43,7 @@ module HomebrewAutomation
|
|
40
43
|
"bottles to Bintray.")
|
41
44
|
os_name = mac_os.identify_version!
|
42
45
|
logger.info!("First let's clone your Tap repo to see the Formula.")
|
46
|
+
# TODO: What if repo already exists?
|
43
47
|
git.with_clone!(tap.url, tap.repo, keep_dir: keep_tap_repo) do |cloned_dir|
|
44
48
|
tap.on_formula! formula_name do |formula|
|
45
49
|
formula.put_sdist(sdist.url, sdist.sha256)
|
@@ -77,6 +81,7 @@ module HomebrewAutomation
|
|
77
81
|
"Backtrace:",
|
78
82
|
e.backtrace.join("\n")
|
79
83
|
].join("\n"))
|
84
|
+
raise
|
80
85
|
rescue HomebrewAutomation::Brew::OlderVersionAlreadyInstalled => e
|
81
86
|
logger.error!([
|
82
87
|
"An older version of the Formula is already installed on your system. " \
|
@@ -85,16 +90,23 @@ module HomebrewAutomation
|
|
85
90
|
"Caused by: #{e.cause}",
|
86
91
|
(e.cause ? e.cause.backtrace.join("\n") : '')
|
87
92
|
].join("\n"))
|
93
|
+
raise
|
88
94
|
rescue HomebrewAutomation::Brew::UninstallFailed => e
|
89
95
|
logger.error!("brew uninstall failed:\n" + e.backtrace.join("\n"))
|
96
|
+
raise
|
90
97
|
rescue HomebrewAutomation::Brew::Error => e
|
91
98
|
logger.error!(
|
92
99
|
"Something went wrong in this Homebrew command: " +
|
93
100
|
e.message + "\n" + e.backtrace.join("\n"))
|
101
|
+
raise
|
94
102
|
rescue HomebrewAutomation::Git::Error => e
|
95
103
|
logger.error!(
|
96
104
|
"Something went wrong in this Git command: " +
|
97
105
|
e.message + "\n" + e.backtrace.join("\n"))
|
106
|
+
raise
|
107
|
+
rescue HomebrewAutomation::SourceDist::SdistDoesNotExist => e
|
108
|
+
logger.error!("The tar file from Github you named doesn't exist. Is it because you haven't pushed that tag to Github yet?")
|
109
|
+
raise
|
98
110
|
end
|
99
111
|
|
100
112
|
# Gather and publish bottles.
|
@@ -108,9 +120,10 @@ module HomebrewAutomation
|
|
108
120
|
# @param tap [Tap]
|
109
121
|
# @param formula_name [String] the name of the formula in the Tap
|
110
122
|
# @param bversion [Bintray::Version]
|
123
|
+
# @param git [HomebrewAutomation::Git]
|
111
124
|
# @param logger [HomebrewAutomation::Logger]
|
112
125
|
# @return [NilClass]
|
113
|
-
def gather_and_publish_bottles!(sdist, tap, formula_name, bversion, logger)
|
126
|
+
def gather_and_publish_bottles!(sdist, tap, formula_name, bversion, git, logger)
|
114
127
|
logger.info!(
|
115
128
|
"Hello, this is HomebrewAutomation! I will browse through your Bintray to " \
|
116
129
|
"see if there may be Bottles built earlier for your Formula, and update your " \
|
@@ -122,6 +135,7 @@ module HomebrewAutomation
|
|
122
135
|
tap.on_formula! formula_name do |formula|
|
123
136
|
logger.info!("Let's see if any files on your Bintray look like Bottles.")
|
124
137
|
bottles = bversion.gather_bottles
|
138
|
+
logger.info!("Found bottles: #{bottles}")
|
125
139
|
bottles.reduce(
|
126
140
|
formula.
|
127
141
|
put_sdist(sdist.url, sdist.sha256).
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: homebrew_automation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- easoncxz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|