Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Commit

Permalink
add rivierabuld as a new distribution solution
Browse files Browse the repository at this point in the history
  • Loading branch information
jayztemplier committed Apr 5, 2015
1 parent 5a9f7a2 commit 10074ac
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Create `.ipa` files and distribute them from the command line, using any of the following methods:

- [iTunes Connect](https://itunesconnect.apple.com)
- [RivieraBuild](http://rivierabuild.com)
- [HockeyApp](http://www.hockeyapp.net)
- [Crashlytics Beta](http://try.crashlytics.com/beta/)
- [DeployGate](https://deploygate.com)
Expand Down Expand Up @@ -47,6 +48,7 @@ Build and distribute iOS apps (.ipa files)
Commands:
build Create a new .ipa file for your app
distribute:rivierabuild Distribute an .ipa file over [RivieraBuild](http://rivierabuild.com)
distribute:hockeyapp Distribute an .ipa file over HockeyApp
distribute:crashlytics Distribute an .ipa file over Crashlytics
distribute:deploygate Distribute an .ipa file over deploygate
Expand All @@ -72,6 +74,15 @@ $ ipa build
$ ipa distribute
```

#### RivieraBuild Distribution

```
$ ipa distribute:rivierabuild -k API_TOKEN -a AVAILABILITY
```

> Shenzhen will load credentials from the environment variable `RIVIERA_API_TOKEN` unless otherwise specified.
> To get the list of availability options, visit http://api.rivierabuild.com
#### HockeyApp Distribution

```
Expand Down
1 change: 1 addition & 0 deletions lib/shenzhen/commands.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$:.push File.expand_path('../', __FILE__)

require 'plugins/rivierabuild'
require 'plugins/hockeyapp'
require 'plugins/deploygate'
require 'plugins/itunesconnect'
Expand Down
81 changes: 81 additions & 0 deletions lib/shenzhen/plugins/rivierabuild.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
require 'json'
require 'openssl'
require 'faraday'
require 'faraday_middleware'

module Shenzhen::Plugins
module RivieraBuild
class Client
HOSTNAME = 'apps.rivierabuild.com'

def initialize(api_token)
@api_token = api_token
@connection = Faraday.new(:url => "https://#{HOSTNAME}", :request => { :timeout => 120 }) do |builder|
builder.request :multipart
builder.request :url_encoded
builder.response :json, :content_type => /\bjson$/
builder.use FaradayMiddleware::FollowRedirects
builder.adapter :net_http
end
end

def upload_build(ipa, options)
options[:file] = Faraday::UploadIO.new(ipa, 'application/octet-stream') if ipa and File.exist?(ipa)

@connection.post do |req|
req.url("/api/upload")
req.body = options
end.on_complete do |env|
yield env[:status], env[:body] if block_given?
end
end
end
end
end

command :'distribute:rivierabuild' do |c|
c.syntax = "ipa distribute:rivierabuild [options]"
c.summary = "Distribute an .ipa file over RivieraBuild"
c.description = ""
c.option '-f', '--file FILE', ".ipa file for the build"
c.option '-k', '--key KEY', "API KEY. Available at https://apps.rivierabuild.com/settings"
c.option '-a', '--availability AVAILABILITY', "For how long the build will be available? More info: http://api.rivierabuild.com"
c.option '-p', '--passcode PASSCODE', "Optional passcode required to install the build on a device"
c.option '-n', '--note NOTE', "Release notes for the build, Markdown"
c.option '--commit-sha SHA', "The Git commit SHA for this build"
c.option '--app-id', "Riviera Build Application ID"

c.action do |args, options|
determine_file! unless @file = options.file
say_warning "Missing or unspecified .ipa file" unless @file and File.exist?(@file)

determine_rivierabuild_api_token! unless @api_token = options.key || ENV['RIVIERA_API_KEY']
say_error "Missing API Token" and abort unless @api_token

determine_availability! unless @availability = options.availability
say_error "Missing availability" and abort unless @availability

parameters = {}
parameters[:api_key] = @api_token
parameters[:availability] = @availability
parameters[:passcode] = options.passcode if options.passcode
parameters[:app_id] = options.app_id if options.app_id
parameters[:note] = options.note if options.note
parameters[:commit_sha] = options.commit_sha if options.commit_sha

client = Shenzhen::Plugins::RivieraBuild::Client.new(@api_token)
response = client.upload_build(@file, parameters)
case response.status
when 200...300
say_ok "Build successfully uploaded to RivieraBuild: #{response.body['file_url']}"
else
say_error "Error uploading to RivieraBuild: #{response.body}"
end
end

private

def determine_rivierabuild_api_token!
@api_token ||= ask "API Key:"
end
end

0 comments on commit 10074ac

Please sign in to comment.