-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a helper for uploading mobile apps to HockeyApp. #656
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/// Contains tasks to interact with [HockeyApp](http://hockeyapp.com) | ||
module Fake.HockeyAppHelper | ||
|
||
open Microsoft.FSharp.Core | ||
open System | ||
open System.Collections.Generic | ||
open System.IO | ||
open System.Net | ||
open System.Text | ||
open Fake | ||
open Newtonsoft.Json | ||
|
||
type ReleaseType = Beta = 0 | Store = 1 | Alpha = 2 | Enterprise = 3 | ||
|
||
type HockeyResponse = { | ||
Title : string | ||
|
||
[<JsonProperty("Bundle_Identifier")>] | ||
BundleIdentifier: string | ||
|
||
[<JsonProperty("Public_Identifier")>] | ||
PublicIdentifier: string | ||
|
||
[<JsonProperty("Device_Family")>] | ||
DeviceFamily: string | ||
|
||
[<JsonProperty("Minimum_OS_Version")>] | ||
MinimumOSVersion: string | ||
|
||
[<JsonProperty("Release_Type")>] | ||
ReleaseType : ReleaseType | ||
|
||
Platform : string | ||
|
||
Status : int | ||
|
||
[<JsonProperty("Config_Url")>] | ||
ConfigUrl : string | ||
|
||
[<JsonProperty("Public_Url")>] | ||
PublicUrl : string | ||
} | ||
|
||
/// The HockeyApp parameter type | ||
type HockeyAppUploadParams = { | ||
/// (Required) API token | ||
ApiToken: string | ||
|
||
/// (Required) file data for the build (.ipa or .apk) | ||
File: string | ||
|
||
/// Release notes for the build | ||
Notes: string | ||
|
||
/// set the release type of the app | ||
ReleaseType: ReleaseType | ||
} | ||
|
||
/// The default HockeyApp parameters | ||
let HockeyAppUploadDefaults = { | ||
ApiToken = String.Empty | ||
File = String.Empty | ||
Notes = String.Empty | ||
ReleaseType = ReleaseType.Beta | ||
} | ||
|
||
/// [omit] | ||
let validateParams param = | ||
if param.ApiToken = "" then failwith "You must provide your API token" | ||
if param.File = "" then failwith "You must provide an app file to upload" | ||
if not <| File.Exists param.File then | ||
failwithf "No such file: %s" param.File | ||
|
||
param | ||
|
||
/// [omit] | ||
let private toCurlArgs param = seq { | ||
yield sprintf "-H \"X-HockeyAppToken:%s\"" param.ApiToken | ||
yield sprintf "-F \"ipa=@%s\"" param.File | ||
yield sprintf "-F \"notes=%s\"" param.Notes | ||
yield sprintf "-F \"release_type=%i\"" (int param.ReleaseType) | ||
yield "https://rink.hockeyapp.net/api/2/apps/upload" | ||
} | ||
|
||
/// Uploads an app to HockeyApp | ||
/// ## Parameters | ||
/// - `setParams` - Function used to override the default parameters | ||
let HockeyApp (setParams: HockeyAppUploadParams -> HockeyAppUploadParams) = | ||
HockeyAppUploadDefaults | ||
|> setParams | ||
|> validateParams | ||
|> toCurlArgs | ||
|> fun args -> | ||
ExecProcessAndReturnMessages (fun p -> | ||
p.FileName <- "curl" | ||
p.Arguments <- (String.concat " " args) | ||
) (TimeSpan.FromMinutes 2.) | ||
|> fun response -> | ||
match response.ExitCode with | ||
| 0 -> JsonConvert.DeserializeObject<HockeyResponse>(response.Messages.[0]) | ||
| _ -> failwithf "Error while posting to HockeyApp.\r\nMessages: %s\r\nErrors: %s\r\n" (String.concat "; " response.Messages) (String.concat "; " response.Errors) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ FSharp.Core | |
FSharp.Compiler.Service | ||
Mono.Web.Xdt | ||
Mono.Cecil | ||
Nuget.Core | ||
Nuget.Core | ||
Newtonsoft.Json |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was so happy that I got rid of NewtonSoft.Json ;-)
Seems it coming back over and over again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we have to fix the NuGet task in FAKE's build.fsx to include the dll.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, we asked whether you wanted a different serializer up front! Keeping Json.Net makes sense, though, given that it's included elsewhere. =)
I'm actually able to build from both mac and windows without any additional modifications. This might be a side effect of NewtonSoft.Json being included in the Deploy and Deploy.Lib projects... Or I might be totally misunderstanding your comment!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I forgot about that ;-)
All is well.