From 8219d432551100788abcf0ef884e54f8b349f42c Mon Sep 17 00:00:00 2001 From: Karlo Medallo Date: Thu, 2 Apr 2015 00:57:25 +1100 Subject: [PATCH] Added more parameters for HockeyApp Upload API --- src/app/FakeLib/HockeyAppHelper.fs | 78 +++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/src/app/FakeLib/HockeyAppHelper.fs b/src/app/FakeLib/HockeyAppHelper.fs index 520cc95709e..2cdd0022b66 100644 --- a/src/app/FakeLib/HockeyAppHelper.fs +++ b/src/app/FakeLib/HockeyAppHelper.fs @@ -12,7 +12,27 @@ open Fake open Newtonsoft.Json /// The release type of the app -type ReleaseType = Beta = 0 | Store = 1 | Alpha = 2 | Enterprise = 3 +type ReleaseType = + | Beta = 0 + | Store = 1 + | Alpha = 2 + | Enterprise = 3 + +/// The notification options +type NotifyOption = + | None = 0 + | CanInstallApp = 1 + | All = 2 + +/// The note types +type NoteType = + | Textile = 0 + | Markdown = 1 + +/// The mandatory options +type MandatoryOption = + | NotMandatory = 0 + | Mandatory = 1 /// HockeyApp's success response type HockeyResponse = { @@ -45,6 +65,7 @@ type HockeyResponse = { } /// The HockeyApp parameter type +/// Based on http://support.hockeyapp.net/kb/api/api-apps#upload-app type HockeyAppUploadParams = { /// (Required) API token ApiToken: string @@ -52,23 +73,55 @@ type HockeyAppUploadParams = { /// (Required) file data for the build (.ipa or .apk) File: string + /// file data for dsym (IOS: *.dysm.zip or Android: mapping.txt) + Dsym: string + /// Release notes for the build - Notes: string + Notes: string + + /// Release notes type for the build + NotesType: NoteType /// Set the release type of the app ReleaseType: ReleaseType /// Set the owner of the app OwnerId: string + + /// Set the notify option + Notify: NotifyOption + + /// Set version as mandatory + Mandatory: MandatoryOption + + /// Set to true to enable the private download page (default is false) + Private: bool + + /// Set to the git commit sha for this build + CommitSHA: string + + /// Set to the URL of the build job on your build server + BuildServerUrl: string + + /// Set to your source repository + RepositoryUrl: string } /// The default HockeyApp parameters let HockeyAppUploadDefaults = { ApiToken = String.Empty File = String.Empty + Dsym = String.Empty Notes = String.Empty + NotesType = NoteType.Textile ReleaseType = ReleaseType.Beta OwnerId = String.Empty + Notify = NotifyOption.None + Mandatory = MandatoryOption.NotMandatory + Private = false + CommitSHA = String.Empty + BuildServerUrl = String.Empty + RepositoryUrl = String.Empty } /// [omit] @@ -81,6 +134,19 @@ let private validateParams param = if not <| File.Exists param.File then failwithf "No such file: %s" param.File + if not (String.IsNullOrEmpty param.Dsym) then + if not (param.Dsym.EndsWith(".dsym.zip", StringComparison.InvariantCultureIgnoreCase) + || param.Dsym.Equals("mapping.txt", StringComparison.InvariantCultureIgnoreCase)) then + failwith "DSYM files should only be: IOS: *.dsym.zip Android: mapping.txt" + + if param.File.EndsWith(".ipa") + && not (param.Dsym.EndsWith(".dsym.zip", StringComparison.InvariantCultureIgnoreCase)) then + failwith "DSYM for an .ipa file can only only be: *.dsym.zip" + + if param.File.EndsWith(".apk") + && not (param.Dsym.Equals("mapping.txt", StringComparison.InvariantCultureIgnoreCase)) then + failwith "DSYM for an .apk file can only only be: mapping.txt" + param /// [omit] @@ -88,9 +154,17 @@ let private toCurlArgs param = seq { yield (String.Format("-sL -w \"{0}%{{http_code}}{0}\"", Regex.Escape(nl))) yield sprintf "-H \"X-HockeyAppToken:%s\"" param.ApiToken yield sprintf "-F \"ipa=@%s\"" param.File + if not (String.IsNullOrEmpty param.Dsym) then yield sprintf "-F \"dsym=@%s\"" param.Dsym yield sprintf "-F \"notes=%s\"" param.Notes + yield sprintf "-F \"notes_type=%i\"" (int param.NotesType) yield sprintf "-F \"release_type=%i\"" (int param.ReleaseType) + yield sprintf "-F \"notify=%i\"" (int param.Notify) + yield sprintf "-F \"mandatory=%i\"" (int param.Mandatory) + yield sprintf "-F \"private=%b\"" param.Private if not (String.IsNullOrEmpty param.OwnerId) then yield sprintf "-F \"owner_id=%s\"" param.OwnerId + if not (String.IsNullOrEmpty param.CommitSHA) then yield sprintf "-F \"commit_sha=%s\"" param.CommitSHA + if not (String.IsNullOrEmpty param.BuildServerUrl) then yield sprintf "-F \"build_server_url=%s\"" param.BuildServerUrl + if not (String.IsNullOrEmpty param.RepositoryUrl) then yield sprintf "-F \"repository_url=%s\"" param.RepositoryUrl yield "https://rink.hockeyapp.net/api/2/apps/upload" }