homebrew_automation 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/homebrew_automation.rb +1 -1
- data/lib/homebrew_automation/bintray.rb +42 -6
- data/lib/homebrew_automation/bottle.rb +20 -0
- data/lib/homebrew_automation/bottle_gatherer.rb +11 -13
- data/lib/homebrew_automation/formula.rb +25 -9
- data/lib/homebrew_automation/mac-os.rb +9 -3
- data/lib/homebrew_automation/source_dist.rb +25 -8
- data/lib/homebrew_automation/tap.rb +60 -15
- data/lib/homebrew_automation/version.rb +4 -1
- data/lib/homebrew_automation/workflow.rb +37 -9
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdaeff9e52d6b0ddeefead7ebced2d97dcde3ae8e6535648c5758ad218b8d42b
|
4
|
+
data.tar.gz: bdf140bc9b706c81ee09344bcb6c36bd8d7679f84fb0757db01fb7df78b0a019
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77b8a3c5fbf0bf8488ebd6a39b2d493beb99b1ac2d2a6bfc64336cdacac2ae352dac3cd30ce62130c2de0bd898f8f9b9dcffce97bb69f6017f7110b2db5374cb
|
7
|
+
data.tar.gz: bb9add2b195407088552da55a35df30a0170fec173c437d97ef15db3cdb1237a4fb4b31b1d37f37edfaa9d124abe13beadab0ac6639048f0fdad4fffff9cb1f8
|
data/lib/homebrew_automation.rb
CHANGED
@@ -6,8 +6,14 @@ require 'rest-client'
|
|
6
6
|
|
7
7
|
module HomebrewAutomation
|
8
8
|
|
9
|
+
# A bare-bones Bintray API client that implements only the methods needed for
|
10
|
+
# Homebrew things.
|
9
11
|
class Bintray
|
10
12
|
|
13
|
+
# @param username [String] Bintray username; for me this was not my email address
|
14
|
+
# @param api_key [String] Bearer-token-like key; generated in the Bintray web UI
|
15
|
+
# @param http [RestClient.Class] The +RestClient+ class itself
|
16
|
+
# @param base_url [String] Include the +https://+; exclude the trailing slash.
|
11
17
|
def initialize(
|
12
18
|
username,
|
13
19
|
api_key,
|
@@ -20,10 +26,15 @@ module HomebrewAutomation
|
|
20
26
|
@http = http # allow injecting mocks for testing
|
21
27
|
end
|
22
28
|
|
23
|
-
# POST /packages/:subject/:repo/:package/versions
|
29
|
+
# <tt>POST /packages/:subject/:repo/:package/versions</tt>
|
24
30
|
#
|
25
31
|
# Redundant: Bintray seems to create nonexistant versions for you if you
|
26
32
|
# just try to upload files into it.
|
33
|
+
#
|
34
|
+
# @param repo_name [String]
|
35
|
+
# @param package_name [String]
|
36
|
+
# @param version_name [String]
|
37
|
+
# @return [RestClient::Response]
|
27
38
|
def create_version(repo_name, package_name, version_name)
|
28
39
|
safe_repo = URI.escape(repo_name)
|
29
40
|
safe_pkg = URI.escape(package_name)
|
@@ -34,11 +45,18 @@ module HomebrewAutomation
|
|
34
45
|
)
|
35
46
|
end
|
36
47
|
|
37
|
-
# PUT /content/:subject/:repo/:package/:version/:file_path[?publish=0/1][?override=0/1][?explode=0/1]
|
48
|
+
# <tt>PUT /content/:subject/:repo/:package/:version/:file_path[?publish=0/1][?override=0/1][?explode=0/1]</tt>
|
38
49
|
#
|
39
50
|
# Bintray seems to expect the byte sequence of the file to be written straight out into the
|
40
|
-
# HTTP request body, optionally via
|
51
|
+
# HTTP request body, optionally via <tt>Transfer-Encoding: chunked</tt>. So we pass the +content+ String
|
41
52
|
# straight through to RestClient
|
53
|
+
#
|
54
|
+
# @param repo_name [String]
|
55
|
+
# @param package_name [String]
|
56
|
+
# @param version_name [String]
|
57
|
+
# @param filename [String] The filename within one Bintray repository, e.g. +hack-assembler-0.1.1.17.high_sierra.bottle.tar.gz+
|
58
|
+
# @param content [String] The bytes for the file, e.g. from a +File.read+
|
59
|
+
# @return [RestClient::Response]
|
42
60
|
def upload_file(repo_name, package_name, version_name, filename, content, publish: 1)
|
43
61
|
safe_repo = URI.escape(repo_name)
|
44
62
|
safe_pkg = URI.escape(package_name)
|
@@ -52,7 +70,14 @@ module HomebrewAutomation
|
|
52
70
|
)
|
53
71
|
end
|
54
72
|
|
55
|
-
# GET /packages/:subject/:repo/:package/versions/:version/files[?include_unpublished=0/1]
|
73
|
+
# <tt>GET /packages/:subject/:repo/:package/versions/:version/files[?include_unpublished=0/1]</tt>
|
74
|
+
#
|
75
|
+
# Useful when seeing what bottles have already been built.
|
76
|
+
#
|
77
|
+
# @param repo_name [String]
|
78
|
+
# @param package_name [String]
|
79
|
+
# @param version_name [String]
|
80
|
+
# @return [RestClient::Response]
|
56
81
|
def get_all_files_in_version(repo_name, package_name, version_name)
|
57
82
|
safe_repo = URI.escape(repo_name)
|
58
83
|
safe_pkg = URI.escape(package_name)
|
@@ -62,21 +87,32 @@ module HomebrewAutomation
|
|
62
87
|
auth_headers)
|
63
88
|
end
|
64
89
|
|
90
|
+
# Bintray username, URI-escaped.
|
91
|
+
#
|
92
|
+
# @return [String]
|
65
93
|
def safe_username
|
66
94
|
URI.escape(@username)
|
67
95
|
end
|
68
96
|
|
69
|
-
#
|
97
|
+
# Resolve a relative path into a URL using the current base_url
|
98
|
+
#
|
99
|
+
# @param slash_subpath [String]
|
100
|
+
# @return [String]
|
70
101
|
def rel(slash_subpath)
|
71
102
|
@base_url + slash_subpath
|
72
103
|
end
|
73
104
|
|
105
|
+
# @return [Hash]
|
74
106
|
def api_headers
|
75
107
|
{ "Content-Type" => "application/json" }.update auth_headers
|
76
108
|
end
|
77
109
|
|
110
|
+
# Implement HTTP Basich Auth, as per RFC 7617.
|
111
|
+
#
|
112
|
+
# Let's not bring in a library just for these two lines.
|
113
|
+
#
|
114
|
+
# @return [Hash]
|
78
115
|
def auth_headers
|
79
|
-
# As per RFC 7617
|
80
116
|
cred = Base64.strict_encode64("#{@username}:#{@api_key}")
|
81
117
|
{ Authorization: "Basic #{cred}" }
|
82
118
|
end
|
@@ -2,8 +2,14 @@
|
|
2
2
|
|
3
3
|
module HomebrewAutomation
|
4
4
|
|
5
|
+
# A representation of a binary build of a Homebrew package
|
5
6
|
class Bottle
|
6
7
|
|
8
|
+
# @param tap_url [String] Something suitable for +git clone+, e.g. +git@github.com:easoncxz/homebrew-tap.git+ or +/some/path/to/my-git-repo+
|
9
|
+
# @param formula_name [String] As known by Homebrew
|
10
|
+
# @param os_name [String] As known by Homebrew, e.g. +el_capitan+
|
11
|
+
# @param filename [String] ???
|
12
|
+
# @param content [String] ???
|
7
13
|
def initialize(
|
8
14
|
tap_url,
|
9
15
|
formula_name,
|
@@ -19,6 +25,9 @@ module HomebrewAutomation
|
|
19
25
|
end
|
20
26
|
|
21
27
|
# Takes ages to run, just like if done manually
|
28
|
+
#
|
29
|
+
# @raise [StandardError]
|
30
|
+
# @return [nil]
|
22
31
|
def build
|
23
32
|
die unless system 'brew', 'tap', local_tap_name, @tap_url
|
24
33
|
die unless system 'brew', 'install', '--verbose', '--build-bottle', @formula_name
|
@@ -26,6 +35,7 @@ module HomebrewAutomation
|
|
26
35
|
end
|
27
36
|
|
28
37
|
# Read and analyse metadata JSON file
|
38
|
+
# @return [Array<(String, String)>] {#minus_minus} and {#filename}
|
29
39
|
def locate_tarball
|
30
40
|
json_filename = Dir['*.bottle.json'].first
|
31
41
|
unless json_filename
|
@@ -41,19 +51,29 @@ module HomebrewAutomation
|
|
41
51
|
@minus_minus, @filename = focus['local_filename'], focus['filename']
|
42
52
|
end
|
43
53
|
|
54
|
+
# The +brew bottle+ original output filename
|
55
|
+
#
|
56
|
+
# See https://github.com/Homebrew/brew/pull/4612 for details.
|
57
|
+
#
|
58
|
+
# @return [String]
|
44
59
|
def minus_minus
|
45
60
|
@minus_minus || locate_tarball.first
|
46
61
|
end
|
47
62
|
|
63
|
+
# Filename of a Bottle tarball suitable for writing into a Formula file
|
64
|
+
#
|
65
|
+
# @return [String]
|
48
66
|
def filename
|
49
67
|
@filename || locate_tarball.last
|
50
68
|
end
|
51
69
|
|
70
|
+
# @return [String] {#content}
|
52
71
|
def load_tarball_from_disk
|
53
72
|
File.rename minus_minus, filename
|
54
73
|
@content = File.read filename
|
55
74
|
end
|
56
75
|
|
76
|
+
# @return [String] bytes of the tarball of this Bottle
|
57
77
|
def content
|
58
78
|
@content || load_tarball_from_disk
|
59
79
|
end
|
@@ -4,43 +4,41 @@ require_relative './formula.rb'
|
|
4
4
|
|
5
5
|
module HomebrewAutomation
|
6
6
|
|
7
|
-
#
|
7
|
+
# See what Bottles have already been built and uploaded to Bintray
|
8
8
|
class BottleGatherer
|
9
9
|
|
10
|
-
# @param json [Hash]
|
10
|
+
# @param json [Array<Hash>] JSON from a +RestClient::Response+ containing the list of files from Bintray
|
11
11
|
def initialize(json)
|
12
12
|
@json = json
|
13
13
|
@bottles = nil
|
14
14
|
end
|
15
15
|
|
16
|
-
#
|
16
|
+
# The bottles gathered.
|
17
17
|
#
|
18
|
-
#
|
18
|
+
# @return [Hash<String, String>] with keys being OS names (in Homebrew-form) and values being SHA256 checksums
|
19
19
|
def bottles
|
20
20
|
return @bottles if @bottles
|
21
21
|
pairs = @json.map do |f|
|
22
|
-
os =
|
22
|
+
os = _parse_for_os(f['name'])
|
23
23
|
checksum = f['sha256']
|
24
24
|
[os, checksum]
|
25
25
|
end
|
26
26
|
@bottles = Hash[pairs]
|
27
27
|
end
|
28
28
|
|
29
|
-
# Formula -> Formula
|
30
|
-
#
|
31
29
|
# Put all bottles gathered here into the given formula, then return the result
|
30
|
+
#
|
31
|
+
# @param formula [HomebrewAutomation::Formula]
|
32
|
+
# @return [HomebrewAutomation::Formula]
|
32
33
|
def put_bottles_into(formula)
|
33
34
|
bottles.reduce(formula) do |formula, (os, checksum)|
|
34
35
|
formula.put_bottle(os, checksum)
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
|
-
#
|
39
|
-
|
40
|
-
|
41
|
-
#
|
42
|
-
# filename -> OS name
|
43
|
-
def parse_for_os(bottle_filename)
|
39
|
+
# @param bottle_filename [String] filename
|
40
|
+
# @return [String] OS name
|
41
|
+
def _parse_for_os(bottle_filename)
|
44
42
|
File.extname(
|
45
43
|
File.basename(bottle_filename, '.bottle.tar.gz')).
|
46
44
|
sub(/^\./, '')
|
@@ -7,16 +7,19 @@ Parser::Builders::Default.emit_procarg0 = true
|
|
7
7
|
|
8
8
|
module HomebrewAutomation
|
9
9
|
|
10
|
-
# An
|
11
|
-
# the definition of a Homebrew Bottle. See Homebrew docs for
|
12
|
-
# https://docs.brew.sh/Bottles.html
|
10
|
+
# An in-memory, programmable representation of some Formula.rb Ruby source
|
11
|
+
# file, containing the definition of a Homebrew Bottle. See Homebrew docs for
|
12
|
+
# concepts: https://docs.brew.sh/Bottles.html
|
13
13
|
#
|
14
|
-
# Instance methods produce new instances where
|
14
|
+
# Instance methods produce new instances where sensible, leaving all
|
15
15
|
# instances free from mutation.
|
16
|
+
#
|
17
|
+
# {#==} and {#hash} delegates to the underlying +Parser::AST::Node+.
|
16
18
|
class Formula
|
17
19
|
|
18
|
-
#
|
19
|
-
#
|
20
|
+
# Parse the string form of a Homebrew Formula source file into a {Formula}.
|
21
|
+
#
|
22
|
+
# {#to_s} is the inverse of this method.
|
20
23
|
#
|
21
24
|
# @return [Formula]
|
22
25
|
def self.parse_string s
|
@@ -34,15 +37,17 @@ module HomebrewAutomation
|
|
34
37
|
# Produce Homebrew Formula source code as a string, suitable for saving as
|
35
38
|
# a Ruby source file.
|
36
39
|
#
|
40
|
+
# This is the inverse of {.parse_string}.
|
41
|
+
#
|
37
42
|
# @return [String]
|
38
43
|
def to_s
|
39
44
|
Unparser.unparse @ast
|
40
45
|
end
|
41
46
|
|
42
|
-
# Update a field in the Formula
|
47
|
+
# Update a top-level field in the Formula
|
43
48
|
#
|
44
|
-
# @param field [String] Name of the Formula field, e.g.
|
45
|
-
# @param value [String] Value of the Formula field, e.g.
|
49
|
+
# @param field [String] Name of the Formula field, e.g. +url+
|
50
|
+
# @param value [String] Value of the Formula field, e.g. +https://github.com/easoncxz/homebrew-automation+
|
46
51
|
# @return [Formula] a new instance of Formula with the changes applied
|
47
52
|
def update_field field, value
|
48
53
|
Formula.new update(
|
@@ -59,6 +64,7 @@ module HomebrewAutomation
|
|
59
64
|
#
|
60
65
|
# @param url [String] URL of source tarball
|
61
66
|
# @param sha256 [String] SHA256 sum of source tarball
|
67
|
+
# @return [Formula]
|
62
68
|
def put_sdist url, sha256
|
63
69
|
update_field("url", url).
|
64
70
|
update_field("sha256", sha256)
|
@@ -76,10 +82,20 @@ module HomebrewAutomation
|
|
76
82
|
put_bottle_version(os, sha256))
|
77
83
|
end
|
78
84
|
|
85
|
+
# Both formulae are +==+, as per +Parser::AST::Node#==+.
|
86
|
+
#
|
87
|
+
# In practice, I think this means both formulae are equivalent in terms of
|
88
|
+
# Ruby semantics.
|
89
|
+
#
|
90
|
+
# @param o [Object] Expecting a {Formula}, really.
|
91
|
+
# @return [Boolean]
|
79
92
|
def == o
|
80
93
|
self.class == o.class && @ast == o.ast
|
81
94
|
end
|
82
95
|
|
96
|
+
# Hash of the +Parser::AST::Node+
|
97
|
+
#
|
98
|
+
# @return [Integer]
|
83
99
|
def hash
|
84
100
|
@ast.hash
|
85
101
|
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
|
2
2
|
module HomebrewAutomation
|
3
3
|
|
4
|
+
# Inspect version of the macOS we're running on
|
4
5
|
class MacOS
|
5
6
|
|
6
|
-
#
|
7
|
+
# Identify the version of the macOS this is run on
|
7
8
|
#
|
8
|
-
#
|
9
|
-
#
|
9
|
+
# Return a macOS version name in a convention recognised by Homebrew, in
|
10
|
+
# particular by the Formula/Bottle DSL.
|
11
|
+
#
|
12
|
+
# @return [String]
|
10
13
|
def self.identify_version
|
11
14
|
version = `sw_vers -productVersion`
|
12
15
|
mac_to_homebrew.
|
@@ -15,6 +18,9 @@ module HomebrewAutomation
|
|
15
18
|
first
|
16
19
|
end
|
17
20
|
|
21
|
+
# Lookup table of numeric version patterns to Homebrew-recognised strings
|
22
|
+
#
|
23
|
+
# @return [Hash<Regexp, String>]
|
18
24
|
def self.mac_to_homebrew
|
19
25
|
{
|
20
26
|
/^10.10/ => 'yosemite',
|
@@ -1,35 +1,52 @@
|
|
1
1
|
|
2
|
-
require '
|
2
|
+
require 'rest-client'
|
3
3
|
|
4
4
|
module HomebrewAutomation
|
5
5
|
|
6
6
|
# A representation of a source distribution tarball file
|
7
7
|
class SourceDist
|
8
8
|
|
9
|
-
#
|
9
|
+
# Assign args to attributes {#user}, {#repo}, {#tag}
|
10
10
|
def initialize user, repo, tag
|
11
11
|
@user = user
|
12
12
|
@repo = repo
|
13
13
|
@tag = tag
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
# Github username, as appears in Github URLs
|
17
|
+
#
|
18
|
+
# @return [String]
|
19
|
+
attr_reader :user
|
20
|
+
|
21
|
+
# Github repo name, as appears in Github URLs
|
22
|
+
#
|
23
|
+
# @return [String]
|
24
|
+
attr_reader :repo
|
17
25
|
|
18
|
-
#
|
26
|
+
# Git tag name, as usable in +git+ commands
|
27
|
+
#
|
28
|
+
# @return [String]
|
29
|
+
attr_reader :tag
|
30
|
+
|
31
|
+
# Calculate and return the file's checksum.
|
32
|
+
#
|
33
|
+
# Lazy and memoized. Download the file if we haven't already.
|
19
34
|
#
|
20
35
|
# @return [String] hex-encoded string representation of the checksum
|
21
36
|
def sha256
|
22
37
|
@sha256 ||= Digest::SHA256.hexdigest contents
|
23
38
|
end
|
24
39
|
|
25
|
-
#
|
40
|
+
# Download and return the file contents.
|
41
|
+
#
|
42
|
+
# Lazy and memoized.
|
26
43
|
#
|
27
|
-
# @param fake [String] fake file contents (for testing)
|
44
|
+
# @param fake [String] inject fake file contents (for testing)
|
28
45
|
# @return [String] contents of the file
|
29
46
|
def contents fake: nil
|
30
47
|
@contents = @contents || fake ||
|
31
48
|
begin
|
32
|
-
resp =
|
49
|
+
resp = RestClient.get url
|
33
50
|
case resp.code
|
34
51
|
when 200
|
35
52
|
resp.body.to_s
|
@@ -40,7 +57,7 @@ module HomebrewAutomation
|
|
40
57
|
end
|
41
58
|
end
|
42
59
|
|
43
|
-
#
|
60
|
+
# The URL to the source tarball Github generates for tagged commits
|
44
61
|
#
|
45
62
|
# @return [String]
|
46
63
|
def url
|
@@ -3,34 +3,65 @@ require_relative "formula.rb"
|
|
3
3
|
|
4
4
|
module HomebrewAutomation
|
5
5
|
|
6
|
+
# A representation of a Github repo that acts as a Homebrew Tap.
|
6
7
|
class Tap
|
7
8
|
|
8
|
-
#
|
9
|
+
# Assign params to attributes.
|
9
10
|
#
|
10
|
-
#
|
11
|
+
# See {#user}, {#repo}, {#token}.
|
12
|
+
#
|
13
|
+
# @param keep_submodule [Boolean] Avoid deleting the cloned tap Git repo
|
14
|
+
# directory when possible
|
11
15
|
def initialize(user, repo, token, keep_submodule: false)
|
12
16
|
@repo = repo
|
13
17
|
@url = "https://#{token}@github.com/#{user}/#{repo}.git"
|
14
18
|
@keep_submodule = keep_submodule
|
15
19
|
end
|
16
20
|
|
17
|
-
|
21
|
+
# Github username, as appears in Github URLs
|
22
|
+
#
|
23
|
+
# @return [String]
|
24
|
+
attr_reader :user
|
18
25
|
|
19
|
-
#
|
26
|
+
# Github repo name, as appears in Github URLs
|
27
|
+
#
|
28
|
+
# @return [String]
|
29
|
+
attr_reader :repo
|
30
|
+
|
31
|
+
# Github OAuth token
|
32
|
+
#
|
33
|
+
# Get a token for yourself here: https://github.com/settings/tokens
|
20
34
|
#
|
21
|
-
#
|
35
|
+
# @return [String]
|
36
|
+
attr_reader :token
|
37
|
+
|
38
|
+
# +pushd+ into a fresh clone, call the block, then clean-up.
|
39
|
+
#
|
40
|
+
# Haskell-y type: +forall a. &Block (() -> a) -> a+
|
41
|
+
#
|
42
|
+
# @yield [String] Basename of the Tap repo directory we've just chdir'd into
|
43
|
+
# @return Whatever the block returns
|
22
44
|
def with_git_clone(&block)
|
23
45
|
begin
|
24
|
-
|
46
|
+
_git_clone
|
25
47
|
Dir.chdir @repo, &block
|
26
48
|
ensure
|
27
|
-
|
49
|
+
_remove_git_submodule unless @keep_submodule
|
28
50
|
end
|
29
51
|
end
|
30
52
|
|
31
|
-
#
|
53
|
+
# Overwrite the specified Formula file, in-place, on-disk
|
54
|
+
#
|
55
|
+
# Haskell-y type: <tt>(String, &Block (Formula -> Formula)) -> nil</tt>
|
32
56
|
#
|
33
|
-
#
|
57
|
+
# If no block is passed, then this tries to find the formula file, but then
|
58
|
+
# does nothing.
|
59
|
+
#
|
60
|
+
# @param formula [String] Part of the name to the file within the +Formula+
|
61
|
+
# directory inside the Tap repo's directory, excluding the +.rb+ suffix.
|
62
|
+
# @yield [Formula]
|
63
|
+
# @return [Formula] as returned from the block,
|
64
|
+
# assuming it obediantly returns a {Formula}.
|
34
65
|
def on_formula(formula, &block)
|
35
66
|
name = "#{formula}.rb"
|
36
67
|
block ||= ->(n) { n }
|
@@ -47,6 +78,13 @@ module HomebrewAutomation
|
|
47
78
|
end
|
48
79
|
end
|
49
80
|
|
81
|
+
# Set Git user's name and email
|
82
|
+
#
|
83
|
+
# Reads environment variables:
|
84
|
+
# - TRAVIS_GIT_USER_NAME
|
85
|
+
# - TRAVIS_GIT_USER_EMAIL
|
86
|
+
#
|
87
|
+
# If either env var is not set, do nothing.
|
50
88
|
def git_config
|
51
89
|
name = ENV['TRAVIS_GIT_USER_NAME']
|
52
90
|
email = ENV['TRAVIS_GIT_USER_EMAIL']
|
@@ -56,26 +94,33 @@ module HomebrewAutomation
|
|
56
94
|
end
|
57
95
|
end
|
58
96
|
|
97
|
+
# Just +git commit -am "$msg"+
|
98
|
+
#
|
99
|
+
# @param msg [String] Git commit message
|
100
|
+
# @raise [StandardError]
|
59
101
|
def git_commit_am(msg)
|
60
102
|
die unless system "git", "commit", "-am", msg
|
61
103
|
end
|
62
104
|
|
105
|
+
# Just +git push+
|
106
|
+
#
|
107
|
+
# @raise [StandardError]
|
63
108
|
def git_push
|
64
109
|
die unless system "git", "push"
|
65
110
|
end
|
66
111
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
def git_clone
|
112
|
+
# @raise [StandardError]
|
113
|
+
def _git_clone
|
72
114
|
die unless system "git", "clone", @url
|
73
115
|
end
|
74
116
|
|
75
|
-
|
117
|
+
# @raise [StandardError]
|
118
|
+
def _remove_git_submodule
|
76
119
|
die unless system "rm", "-rf", @repo
|
77
120
|
end
|
78
121
|
|
122
|
+
private
|
123
|
+
|
79
124
|
def die
|
80
125
|
raise StandardError.new
|
81
126
|
end
|
@@ -4,13 +4,18 @@ require_relative './bottle_gatherer.rb'
|
|
4
4
|
|
5
5
|
module HomebrewAutomation
|
6
6
|
|
7
|
-
# Imperative glue code
|
7
|
+
# Imperative glue code.
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# Each method in this class probably makes sense to be exposed as a CLI command.
|
10
10
|
class Workflow
|
11
11
|
|
12
|
-
#
|
13
|
-
#
|
12
|
+
# Assign params to attributes.
|
13
|
+
#
|
14
|
+
# See {#tap} and {#bintray}.
|
15
|
+
#
|
16
|
+
# @param tap [Tap]
|
17
|
+
# @param bintray [Bintray]
|
18
|
+
# @param bintray_bottle_repo [String] Really should be somehow a part of the +bintray+ param
|
14
19
|
def initialize(
|
15
20
|
tap,
|
16
21
|
bintray,
|
@@ -20,7 +25,26 @@ module HomebrewAutomation
|
|
20
25
|
@bintray_bottle_repo = bintray_bottle_repo
|
21
26
|
end
|
22
27
|
|
23
|
-
#
|
28
|
+
# The Tap holding the Formulae for which we might want to build or publish bottles.
|
29
|
+
#
|
30
|
+
# @return [Tap]
|
31
|
+
attr_reader :tap
|
32
|
+
|
33
|
+
# An API client
|
34
|
+
#
|
35
|
+
# @return [Bintray]
|
36
|
+
attr_reader :bintray
|
37
|
+
|
38
|
+
# Build and upload a bottle.
|
39
|
+
#
|
40
|
+
# The Formula source comes from +source_dist+, and the Bottle tarball that
|
41
|
+
# is built goes to {#bintray}.
|
42
|
+
#
|
43
|
+
# +source_dist+ not only specifies the source tarball, but it also implies:
|
44
|
+
# - the formula name, as appears in the {#tap}, via {SourceDist#repo};
|
45
|
+
# - the Bintray package version, as to be uploaded, via {SourceDist#tag}, with any leading +v+ stripped off.
|
46
|
+
#
|
47
|
+
# The optional params overwrite the above implication.
|
24
48
|
#
|
25
49
|
# @param source_dist [HomebrewAutomation::SourceDist] Source tarball
|
26
50
|
# @param formula_name [String] Formula name as appears in the Tap, which should be the same as the Bintray "Package" name
|
@@ -55,11 +79,15 @@ module HomebrewAutomation
|
|
55
79
|
end
|
56
80
|
end
|
57
81
|
|
58
|
-
#
|
59
|
-
#
|
82
|
+
# Gather and publish bottles.
|
83
|
+
#
|
84
|
+
# Look around on Bintray to see what Bottles we've already built and
|
85
|
+
# uploaded (as such "gathering" the bottles), then push new commits into
|
86
|
+
# the {#tap} repository to make an existing Formula aware of the Bottles
|
87
|
+
# we're gathered (as such "publishing" the bottles).
|
60
88
|
#
|
61
|
-
# @param formula_name [String]
|
62
|
-
# @param version_name [String] Bintray "Version" name
|
89
|
+
# @param formula_name [String] Both the Formula name in the Tap repo, and the Package name in the Bintray repo.
|
90
|
+
# @param version_name [String] Bintray "Version" name; not a Git tag.
|
63
91
|
# @return [Formula]
|
64
92
|
def gather_and_publish_bottles(formula_name, version_name)
|
65
93
|
@tap.with_git_clone do
|
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.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- easoncxz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -53,33 +53,33 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.6'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
62
|
-
type: :
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: thor
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0.20'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0.20'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: parser
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,7 +143,8 @@ files:
|
|
143
143
|
homepage: https://github.com/easoncxz/homebrew-automation
|
144
144
|
licenses:
|
145
145
|
- GPL-3.0
|
146
|
-
metadata:
|
146
|
+
metadata:
|
147
|
+
yard.run: yri
|
147
148
|
post_install_message:
|
148
149
|
rdoc_options: []
|
149
150
|
require_paths:
|
@@ -159,8 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
160
|
- !ruby/object:Gem::Version
|
160
161
|
version: '0'
|
161
162
|
requirements: []
|
162
|
-
|
163
|
-
rubygems_version: 2.7.7
|
163
|
+
rubygems_version: 3.0.2
|
164
164
|
signing_key:
|
165
165
|
specification_version: 4
|
166
166
|
summary: Build bottles and update Formulae
|