-
Notifications
You must be signed in to change notification settings - Fork 4
/
Gruntfile.js
142 lines (118 loc) · 4.22 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
var fs = require('fs');
module.exports = function (grunt) {
grunt.initConfig({
settings: {
releaseNotes: grunt.option('notes') || 'CI build',
appName: 'LiveViewer',
ppUuid: '3db13f29-5a82-433c-aaeb-aee2be0e7e93',
distributionName: 'Fokke Zandbergen (Y39937U7XN)',
ppUuidStore: '',
installrAppToken: '6xC0I8SdJc76kWwpqq7LhZLIyq6fBP4Z'
},
titanium: {
clean: {
options: {
command: 'clean'
}
},
ios: {
options: {
command: 'build',
projectDir: './',
platform: 'ios',
buildOnly: true,
target: 'dist-adhoc',
distributionName: '<%= settings.distributionName %>',
ppUuid: '<%= settings.ppUuid %>',
outputDir: './dist'
}
},
appstore: {
options: {
command: 'build',
projectDir: './',
platform: 'ios',
target: 'dist-appstore',
distributionName: '<%= settings.distributionName %>',
ppUuid: '<%= settings.ppUuidStore %>'
}
},
android: {
options: {
command: 'build',
projectDir: './',
platform: 'android',
buildOnly: true,
target: 'dist-playstore',
keystore: '_assets/android.keystore',
alias: 'liveviewer',
storePassword: 'appcelerator',
outputDir: './dist'
}
}
},
shell: {
ios: {
options: {
stdout: true
},
command: [
"curl -H 'X-InstallrAppToken: <%= settings.installrAppToken %>' https://www.installrapp.com/apps.json " +
"-F 'qqfile=@./dist/<%= settings.appName %>.ipa' " +
"-F 'releaseNotes=<%= settings.releaseNotes %>' " +
"-F 'notify=true'"
].join("&&")
},
android: {
options: {
stdout: true
},
command: [
"curl -H 'X-InstallrAppToken: <%= settings.installrAppToken %>' https://www.installrapp.com/apps.json " +
"-F 'qqfile=@./dist/<%= settings.appName %>.apk' " +
"-F 'releaseNotes=<%= settings.releaseNotes %>' " +
"-F 'notify=true'"
].join("&&")
}
},
});
grunt.loadNpmTasks('grunt-titanium');
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('version', function (what) {
var index = ['major', 'minor', 'patch'].indexOf(what);
var tiapp = fs.readFileSync('tiapp.xml', {
encoding: 'utf-8'
});
if (index !== -1) {
tiapp = tiapp.replace(/(<version>)([^<]+)(<\/version>)/, function (match, before, version, after) {
version = version.split('.');
// bump index and reset following
for (var i = index; i <= 2; i++) {
version[i] = (i === index) ? (parseInt(version[i], 10) + 1).toString() : '0';
}
version = version.join('.');
grunt.log.writeln('Bumped version to: ' + version);
return before + version + after;
});
}
tiapp = tiapp.replace(/(android:versionCode=")([^"]+)(")/, function (match, before, versionCode, after) {
versionCode = parseInt(versionCode, 10) + 1;
grunt.log.writeln('Bumped android:versionCode to: ' + versionCode);
return before + versionCode + after;
});
tiapp = tiapp.replace(/(<key>CFBundleVersion<\/key>\s*<string>)([^<]+)(<\/string>)/mg, function (match, before, CFBundleVersion, after) {
CFBundleVersion = parseInt(CFBundleVersion, 10) + 1;
grunt.log.writeln('Bumped CFBundleVersion to: ' + CFBundleVersion);
return before + CFBundleVersion + after;
});
fs.writeFileSync('tiapp.xml', tiapp);
});
grunt.registerTask('bump', ['version:build']);
grunt.registerTask('build', ['titanium:clean', 'titanium:ios', 'titanium:clean', 'titanium:android']);
grunt.registerTask('upload', ['shell']);
grunt.registerTask('apple', ['bump', 'titanium:clean', 'titanium:appstore']);
grunt.registerTask('google', ['bump', 'titanium:clean', 'titanium:android']);
grunt.registerTask('default', ['bump', 'build', 'upload']);
grunt.registerTask('ios', ['bump', 'titanium:clean', 'titanium:ios', 'shell:ios']);
grunt.registerTask('android', ['bump', 'titanium:clean', 'titanium:android', 'shell:android']);
};