instabug-xcodebot-upload 1.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/instabug-xcodebot-upload +107 -0
  3. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6bb7a39cb04719f09c25ffae805c84f12bba66c5
4
+ data.tar.gz: 7fcaf0b36ae31abfca75db3c1930c7d98fdb4b03
5
+ SHA512:
6
+ metadata.gz: ba7f1bd46883e536b275f2a12104b3c43592371cedfd69cca87f3b37eda320712d305d2d3261e5be597b390d23c0fde4bc1ace39543e3145e1db22c0e8771644
7
+ data.tar.gz: c7bb18f35264e75f59a30691eb8575642611ae1f05f08ac04deab920ecc1c2301599ddcdbe7ae93bdd7219d78927becb1479d4198c3d31f5393a4d8d7e1debaa
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+
5
+ # Instabug options
6
+ INSTABUG_ENDPOINT = "https://api.instabug.com/api/ios/v1/dsym"
7
+
8
+ options = {}
9
+ OptionParser.new do |opts|
10
+ opts.banner = "Usage: instabug-upload [options]"
11
+
12
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
13
+ options[:verbose] = v
14
+ end
15
+ opts.on("-k", "--key=API_KEY", "Instabug API Key") do |k|
16
+ options[:api_key] = k
17
+ end
18
+ end.parse!
19
+
20
+ # API Key is required
21
+ raise OptionParser::MissingArgument, "API Key is required" if options[:api_key].nil?
22
+
23
+ # Get path to xcarchive
24
+ archive_path = ENV["XCS_ARCHIVE"]
25
+
26
+ if archive_path.nil?
27
+ puts "$XCS_ARCHIVE is not set. Cannot find path to the output archive"
28
+ exit 1
29
+ end
30
+
31
+ # Check that there is an archive there
32
+ unless File.exist?(archive_path)
33
+ puts "xcarchive doesn't exist. Make sure $XCS_ARCHIVE path is correct"
34
+ exit 1
35
+ end
36
+
37
+ # Check that there are dSYMs
38
+ dsym_path = File.join(archive_path, "dSYMs")
39
+ unless File.exist?(dsym_path)
40
+ puts "No dSYMs outputted. Check your Xcode build settings"
41
+ exit 1
42
+ end
43
+
44
+ # Get a list of the dSYMs
45
+ dsym_list = Dir.glob(File.join(dsym_path, "*.dSYM"))
46
+
47
+ # Change to dsym dir
48
+ Dir.chdir dsym_path do
49
+
50
+ # Read project version
51
+ version = IO.popen(["/usr/libexec/PlistBuddy",
52
+ "-c",
53
+ "Print :ApplicationProperties:CFBundleShortVersionString",
54
+ File.join(archive_path, "Info.plist")]).read.strip
55
+
56
+ # Loop through dSYMs, zip and upload each
57
+ dsym_list.each do |dsym|
58
+ dsym_base_name = File.basename(dsym)
59
+
60
+ # Zip it
61
+ dsym_zip_name = "#{dsym_base_name}-#{version}.zip"
62
+
63
+ puts "Zipping #{dsym_zip_name}..." if options[:verbose]
64
+
65
+ success = system("/usr/bin/zip", "-rq9", dsym_zip_name, dsym_base_name)
66
+
67
+ # If it failed, make sure to delete it
68
+ unless success
69
+ File.unlink(dsym_zip_name) if File.exists?(dsym_zip_name)
70
+ puts "Failed to create zip file: #{dsym_zip_name}. Aborting"
71
+ exit 1
72
+ end
73
+
74
+ # Upload the zip
75
+ output = IO.popen(["curl",
76
+ INSTABUG_ENDPOINT,
77
+ "-w %{http_code}",
78
+ "--silent",
79
+ "-o /dev/null",
80
+ "-F",
81
+ "dsym=@\"#{dsym_zip_name}\"",
82
+ "-F",
83
+ "token=#{options[:api_key]}"]).read.strip
84
+
85
+ # Remove zip file
86
+ File.unlink(dsym_zip_name)
87
+
88
+ if output == "000"
89
+ puts "Failed to upload zip file. No internet connection. Aborting"
90
+ exit 1
91
+ elsif output == "422"
92
+ puts "Failed to upload zip file: #{dsym_zip_name}. Make sure you are using the correct token. Aborting"
93
+ exit 1
94
+ elsif output != "200"
95
+ puts "Failed to upload zip file: #{dsym_zip_name}. #{output}. Aborting"
96
+ exit 1
97
+ end
98
+
99
+ puts "Completed uploading #{dsym_zip_name}" if options[:verbose]
100
+ end
101
+ end
102
+
103
+ if options[:verbose]
104
+ puts "Uploaded the following dSYMs: #{dsym_list.join(', ')}"
105
+ else
106
+ puts "Uploaded #{dsym_list.count} dSYM(s)"
107
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: instabug-xcodebot-upload
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jason Gabriele
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Uploads dSYMs from the xcarchive to Instabug via an After-Integration
14
+ Trigger
15
+ email: jason.gabriele@gmail.com
16
+ executables:
17
+ - instabug-xcodebot-upload
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - bin/instabug-xcodebot-upload
22
+ homepage: https://github.com/niveus/instabug-xcodebot-upload
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '2.0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.5.1
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Upload dSYMs to Instabug via Xcode bots
46
+ test_files: []