Skip to content

Commit

Permalink
Merge pull request #723 from karlomedallo/HockeyAppHelperNotify
Browse files Browse the repository at this point in the history
Added more parameters for HockeyApp Upload API
  • Loading branch information
forki committed Apr 1, 2015
2 parents 6f535f9 + 8219d43 commit f1388ed
Showing 1 changed file with 76 additions and 2 deletions.
78 changes: 76 additions & 2 deletions src/app/FakeLib/HockeyAppHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -45,30 +65,63 @@ 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

/// (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]
Expand All @@ -81,16 +134,37 @@ 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]
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"
}

Expand Down

0 comments on commit f1388ed

Please sign in to comment.