Last active
August 29, 2015 14:21
-
-
Save robert-waggott/5bb6ff4d52b211c2012a to your computer and use it in GitHub Desktop.
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
module.exports = function(grunt) { | |
grunt.initConfig({ | |
adminPassword: '', | |
solution: '', | |
versionNumber: grunt.option('versionNumber'), | |
buildAgent: grunt.option('buildAgent'), | |
buildServerUrl: grunt.option('buildServerUrl'), | |
repoUrl: grunt.option('repoUrl'), | |
apiToken: grunt.option('apiToken'), | |
teamcity: { | |
all: {} // need a task even if its an empty one | |
}, | |
assemblyinfo: { | |
options: { | |
// Can be solutions, projects or individual assembly info files | |
files: ['<%= solution %>.sln'], | |
// Standard assembly info | |
info: { | |
description: 'Lorem Ipsum', | |
company: 'Lorem Ipsum', | |
product: 'Lorem Ipsum', | |
copyright: 'Copyright 2015 © Lorem Ipsum', | |
trademark: 'Lorem Ipsum', | |
version: '<%= versionNumber %>', | |
fileVersion: '<%= versionNumber %>' | |
} | |
} | |
}, | |
xmlpoke: { | |
updateAndroidManifest: { | |
options: { | |
namespaces: { 'android': 'http://schemas.android.com/apk/res/android' }, | |
xpath: '/manifest/@android:versionName', | |
value: '<%= versionNumber %>' | |
}, | |
files: { | |
'Solutions/<%= solution %>.Droid/Properties/AndroidManifest.xml': 'Solutions/<%= solution %>.Droid/Properties/AndroidManifest.xml' | |
} | |
} | |
}, | |
plistbuddy: { | |
setVersionNumber: { | |
method: 'Set', | |
entry: ':CFBundleVersion', | |
value: '<%= versionNumber %>', | |
src: 'Solutions/<%= solution %>.iOS/Info.plist' | |
}, | |
setShortVersionNumber: { | |
method: 'Set', | |
entry: ':CFBundleShortVersionString', | |
value: '<%= versionNumber %>', | |
src: 'Solutions/<%= solution %>.iOS/Info.plist' | |
} | |
}, | |
shell: { | |
nugetPackageRestore: { | |
command: 'nuget restore <%= solution %>.sln', | |
options: { | |
execOptions: { | |
maxBuffer: Infinity | |
} | |
} | |
}, | |
unlockKeychain: { | |
command: 'security -v unlock-keychain -p <%= adminPassword %> "$HOME/Library/Keychains/login.keychain"' | |
}, | |
buildAPK: { | |
command: 'xbuild /t:SignAndroidPackage /p:Configuration=Debug "Solutions/<%= solution %>.Droid/<%= solution %>.Droid.csproj"', | |
options: { | |
execOptions: { | |
maxBuffer: Infinity | |
} | |
} | |
}, | |
buildIPA: { | |
command: '"/Applications/Xamarin Studio.app/Contents/MacOS/mdtool" build "--configuration:Debug|iPhone" "<%= solution %>.sln"', | |
options: { | |
execOptions: { | |
maxBuffer: Infinity | |
} | |
} | |
}, | |
nunit: { | |
command: [ | |
'mono /Library/Frameworks/Mono.framework/Libraries/mono/4.5/nunit-console.exe', | |
'"Solutions/<%= solution %>.UnitTests/bin/Debug/<%= solution %>.UnitTests.dll"', | |
'-config:"Debug"', | |
'-xml:"TestReport.xml"', | |
'-nodots' | |
].join(' '), | |
options: { | |
execOptions: { | |
maxBuffer: Infinity | |
} | |
} | |
}, | |
uploadAPK: { | |
command: [ | |
'curl', | |
'-F "status=2"', | |
'-F "notify=0"', | |
'-F "notes=Built from TeamCity. <%= buildAgent %>."', | |
'-F "notes_type=0"', | |
'-F "build_server_url=<%= buildServerUrl %>"', | |
'-F "repository_url=<%= repoUrl %>"', | |
'-F "ipa=@Solutions/<%= solution %>.Droid/bin/Debug/com.earthware.<%= solution %>-Signed.apk"', | |
'-H "X-HockeyAppToken:<%= apiToken %>"', | |
'https://rink.hockeyapp.net/api/2/apps/upload', | |
].join(' '), | |
options: { | |
execOptions: { | |
maxBuffer: Infinity | |
} | |
} | |
}, | |
uploadIPA: { | |
command: [ | |
'curl', | |
'-F "status=2"', | |
'-F "notify=0"', | |
'-F "notes=Built from TeamCity. <%= buildAgent %>."', | |
'-F "notes_type=0"', | |
'-F "build_server_url=<%= buildServerUrl %>"', | |
'-F "repository_url=<%= repoUrl %>"', | |
'-F "ipa=@Solutions/<%= solution %>.iOS/bin/iPhone/Debug/<%= solution %>.iOS-<%= versionNumber %>.ipa"', | |
'-H "X-HockeyAppToken:<%= apiToken %>"', | |
'https://rink.hockeyapp.net/api/2/apps/upload', | |
].join(' '), | |
options: { | |
execOptions: { | |
maxBuffer: Infinity | |
} | |
} | |
} | |
}, | |
}); | |
grunt.loadNpmTasks('grunt-teamcity'); | |
grunt.loadNpmTasks('grunt-nunit-runner'); | |
grunt.loadNpmTasks('grunt-dotnet-assembly-info'); | |
grunt.loadNpmTasks('grunt-http-upload'); | |
grunt.loadNpmTasks('grunt-shell'); | |
grunt.loadNpmTasks('grunt-xmlpoke'); | |
grunt.loadNpmTasks('grunt-plistbuddy'); | |
grunt.registerTask('default', [ | |
'assemblyinfo', | |
'teamcity', | |
'xmlpoke:updateAndroidManifest', | |
'plistbuddy:setVersionNumber', | |
'plistbuddy:setShortVersionNumber', | |
'shell:nugetPackageRestore', | |
'shell:unlockKeychain', | |
'shell:buildAPK', | |
'shell:buildIPA', | |
'shell:nunit'//, | |
'shell:uploadAPK', | |
'shell:uploadIPA' | |
]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment