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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41b26872945b7c2f6fc312b964accc2764e4580a
4
- data.tar.gz: a826f2d5aa67ef8520c7fd11ce98e1a50f830a3a
3
+ metadata.gz: 9e06de995feb8307490da8528ef5d7957724debe
4
+ data.tar.gz: 673f477361bf072a13ab392edfc5a57aa40a42af
5
5
  SHA512:
6
- metadata.gz: 6586b7b6e6f4394eb0c09d9b859cfcf27c8f3d657958d96d0505e6a241b7f0f2c856c207708b4585336c6dc3f2a8409569426dd39cd2722cb0330c46ed901963
7
- data.tar.gz: 624ce47a552d0b14589cc29a70950d400f8a8283ae1e246d02e87da8b82b92a34c1f48c9281c158b780d2094337d75f60c5b4dfbbb9043825ad258c66ea60827
6
+ metadata.gz: 7f6432af7dee559bbf17d9251471a1f726052b789e0a0bd37f3c91912ce97b00519de47e75e3b8e44f401b99e7f6864d36f371eab6d75327492f2f4165847151
7
+ data.tar.gz: 19bfd9b4a81ca92fc491763a5181787e765b2f255d1f0ae399ee14617faf28d2bc60c6fa9bffc2f2aafa4ead605bd7f9020b06960cf8098f1e8776ecb58d52ab
@@ -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
- # create release
18
- # TODO: fallback to finding an existing release
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
@@ -1,3 +1,3 @@
1
1
  module Rubinjam
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubinjam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser