rubinjam 0.7.0 → 0.7.1
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/rubinjam/tasks.rb +16 -5
- data/lib/rubinjam/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e06de995feb8307490da8528ef5d7957724debe
|
4
|
+
data.tar.gz: 673f477361bf072a13ab392edfc5a57aa40a42af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f6432af7dee559bbf17d9251471a1f726052b789e0a0bd37f3c91912ce97b00519de47e75e3b8e44f401b99e7f6864d36f371eab6d75327492f2f4165847151
|
7
|
+
data.tar.gz: 19bfd9b4a81ca92fc491763a5181787e765b2f255d1f0ae399ee14617faf28d2bc60c6fa9bffc2f2aafa4ead605bd7f9020b06960cf8098f1e8776ecb58d52ab
|
data/lib/rubinjam/tasks.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rubinjam'
|
1
2
|
require 'shellwords'
|
2
3
|
require 'json'
|
3
4
|
|
@@ -8,20 +9,19 @@ module Rubinjam
|
|
8
9
|
class << self
|
9
10
|
def upload_binary(tag, github_token)
|
10
11
|
# https://github.com/foo/bar or git@github.com:foo/bar.git -> foo/bar
|
11
|
-
repo = sh("git", "remote", "get-url", "origin")
|
12
|
+
repo = sh("git", "remote", "get-url", "origin").strip
|
12
13
|
repo.sub!(/\.git$/, "")
|
13
14
|
repo = repo.split(/[:\/]/).last(2).join("/")
|
14
15
|
|
15
16
|
auth = ["-H", "Authorization: token #{github_token}"]
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
reply = sh("curl", *auth, "--data", {tag_name: tag}.to_json, "https://api.github.com/repos/#{repo}/releases")
|
20
|
-
id = JSON.parse(reply).fetch("id") # fails when release already exists
|
18
|
+
id = find_or_create_release(auth, repo, tag)
|
19
|
+
puts "Release #{id}"
|
21
20
|
|
22
21
|
# upload binary
|
23
22
|
begin
|
24
23
|
name = Rubinjam.write(Dir.pwd)
|
24
|
+
puts "Uploading #{name} release asset"
|
25
25
|
sh(
|
26
26
|
"curl",
|
27
27
|
"-X", "POST",
|
@@ -41,6 +41,17 @@ module Rubinjam
|
|
41
41
|
raise "Command failed:\n#{command}\n#{result}" unless $?.success?
|
42
42
|
result
|
43
43
|
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def find_or_create_release(auth, repo, tag)
|
48
|
+
reply = sh("curl", *auth, "--data", {tag_name: tag}.to_json, "https://api.github.com/repos/#{repo}/releases")
|
49
|
+
unless id = JSON.parse(reply)["id"]
|
50
|
+
reply = sh("curl", *auth, "https://api.github.com/repos/#{repo}/releases/tags/#{tag}")
|
51
|
+
id = JSON.parse(reply).fetch("id")
|
52
|
+
end
|
53
|
+
id
|
54
|
+
end
|
44
55
|
end
|
45
56
|
end
|
46
57
|
end
|
data/lib/rubinjam/version.rb
CHANGED