-
Notifications
You must be signed in to change notification settings - Fork 237
/
Gruntfile.coffee
executable file
·265 lines (232 loc) · 10.2 KB
/
Gruntfile.coffee
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#
# Wire
# Copyright (C) 2016 Wire Swiss GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
electron_packager = require 'electron-packager'
ELECTRON_PACKAGE_JSON = 'electron/package.json'
PACKAGE_JSON = 'package.json'
INFO_JSON = 'info.json'
module.exports = (grunt) ->
require('load-grunt-tasks') grunt, pattern: ['grunt-*']
path = require 'path'
grunt.initConfig
pkg: grunt.file.readJSON PACKAGE_JSON
info: grunt.file.readJSON INFO_JSON
clean:
wrap: 'wrap'
build: 'wrap/build'
dist: 'wrap/dist'
win: 'wrap/**/<%= info.name %>-win*'
macos: 'wrap/**/<%= info.name %>-darwin*'
linux: ['wrap/**/<%= info.name %>-linux*', 'wrap/dist']
pkg: '*.pkg'
'update-keys':
options:
config: 'electron/js/config.js'
productbuild:
options:
sign:
app: '<%= info.sign.app %>'
package: '<%= info.sign.package %>'
parent: 'resources/macos/entitlements/parent.plist'
child: 'resources/macos/entitlements/child.plist'
dir: 'wrap/dist/<%= info.name %>-mas-x64/<%= info.name %>.app'
name: '<%= info.name %>'
electron:
options:
name: '<%= info.name %>'
dir: 'electron'
out: 'wrap/build'
overwrite: true
arch: 'all'
asar: true
'app-copyright': '<%= info.copyright %>'
'app-version': '<%= info.version %>'
'build-version': '<%= info.build %>'
'min-version': '10.9.0'
protocols: [
{name: '', schemes: ['wire']}
]
macos_internal:
options:
name: '<%= info.nameInternal %>'
platform: 'mas'
icon: 'resources/macos/wire.internal.icns'
'app-bundle-id': 'com.wearezeta.zclient.mac.internal'
'dev-region': 'en'
macos_prod:
options:
platform: 'mas'
out: 'wrap/dist/'
icon: 'resources/macos/wire.icns'
'app-category-type': 'public.app-category.social-networking'
'app-bundle-id': 'com.wearezeta.zclient.mac'
'helper-bundle-id': 'com.wearezeta.zclient.mac.helper'
'dev-region': 'en'
'extend-info': 'resources/macos/custom.plist'
win_internal:
options:
name: '<%= info.nameInternal %>'
platform: 'win32'
icon: 'resources/win/wire.internal.ico'
arch: 'ia32'
win32metadata:
CompanyName: '<%= info.name %>'
FileDescription: '<%= info.description %>'
OriginalFilename: '<%= info.nameInternal %>.exe'
ProductName: '<%= info.nameInternal %>'
InternalName: '<%= info.nameInternal %>.exe'
win_prod:
options:
platform: 'win32'
icon: 'resources/win/wire.ico'
arch: 'ia32'
win32metadata:
CompanyName: '<%= info.name %>'
FileDescription: '<%= info.description %>'
OriginalFilename: '<%= info.name %>.exe'
ProductName: '<%= info.name %>'
InternalName: '<%= info.name %>.exe'
'create-windows-installer':
internal:
title: '<%= info.nameInternal %>'
description: '<%= info.description %>'
version: '<%= info.version %>.<%= info.build %>'
appDirectory: 'wrap/build/<%= info.nameInternal %>-win32-ia32'
outputDirectory: 'wrap/internal/<%= info.nameInternal %>-win32-ia32'
authors: '<%= info.nameInternal %>'
exe: '<%= info.nameInternal %>.exe'
setupIcon: 'resources/win/wire.internal.ico'
noMsi: true
loadingGif: 'resources/win/icon.internal.256x256.png'
iconUrl: 'https://wire-app.wire.com/win/internal/wire.internal.ico'
prod:
title: '<%= info.name %>'
description: '<%= info.description %>'
version: '<%= info.version %>.<%= info.build %>'
appDirectory: 'wrap/build/<%= info.name %>-win32-ia32'
outputDirectory: 'wrap/prod/<%= info.name %>-win32-ia32'
authors: '<%= info.name %>'
exe: '<%= info.name %>.exe'
setupIcon: 'resources/win/wire.ico'
noMsi: true
loadingGif: 'resources/win/icon.256x256.png'
iconUrl: 'https://wire-app.wire.com/win/prod/wire.ico'
gitcommit:
release:
options:
message: 'Release <%= info.version %>.<%= info.build %>'
files:
src: [INFO_JSON, ELECTRON_PACKAGE_JSON]
gittag:
release:
options:
tag: 'release/<%= info.version %>.<%= info.build %>'
message: 'Release <%= info.version %>.<%= info.build %>'
gitpush:
task:
options:
tags: true
branch: 'master'
githubChanges:
release:
options:
auth: true
onlyPulls: true
useCommitBody: true
owner : 'wireapp'
repository : 'wire-desktop'
shell:
linux64:
command: 'yarn run linux64'
linux32:
command: 'yarn run linux32'
###############################################################################
# Tasks
###############################################################################
grunt.registerTask 'build-inc', ->
info = grunt.config.get 'info'
info.build = "#{parseInt(info.build, 10) + 1 }"
grunt.config.set 'info', info
grunt.file.write INFO_JSON, JSON.stringify(info, null, 2) + '\n'
electron_pkg = grunt.file.readJSON ELECTRON_PACKAGE_JSON
electron_pkg.version = "#{info.version}.#{info.build}"
grunt.file.write ELECTRON_PACKAGE_JSON, JSON.stringify(electron_pkg, null, 2) + '\n'
grunt.log.write("Build number increased to #{info.build} ").ok();
grunt.registerTask 'release-internal', ->
info = grunt.config.get 'info'
electron_pkg = grunt.file.readJSON ELECTRON_PACKAGE_JSON
electron_pkg.updateWinUrl = info.updateWinUrlInternal
electron_pkg.environment = 'internal'
electron_pkg.name = info.nameInternal.toLowerCase()
electron_pkg.productName = info.nameInternal
grunt.file.write ELECTRON_PACKAGE_JSON, JSON.stringify(electron_pkg, null, 2) + '\n'
grunt.log.write("Releases URL points to #{electron_pkg.updateWinUrl} ").ok();
grunt.registerTask 'release-prod', ->
info = grunt.config.get 'info'
electron_pkg = grunt.file.readJSON ELECTRON_PACKAGE_JSON
electron_pkg.updateWinUrl = info.updateWinUrlProd
electron_pkg.environment = 'production'
electron_pkg.name = info.name.toLowerCase()
electron_pkg.productName = info.name
grunt.file.write ELECTRON_PACKAGE_JSON, JSON.stringify(electron_pkg, null, 2) + '\n'
grunt.log.write("Releases URL points to #{electron_pkg.updateWinUrl} ").ok();
grunt.registerMultiTask 'electron', 'Package Electron apps', ->
done = this.async()
electron_packager @options(), (error) ->
if (error)
grunt.warn error
else
done()
grunt.registerTask 'update-keys', ->
options = @options()
config_string = grunt.file.read options.config
if config_string?
new_config_string = config_string
.replace "RAYGUN_API_KEY: ''", "RAYGUN_API_KEY: '#{process.env.RAYGUN_API_KEY or ''}'"
.replace "GOOGLE_CLIENT_ID: ''", "GOOGLE_CLIENT_ID: '#{process.env.GOOGLE_CLIENT_ID or ''}'"
.replace "GOOGLE_CLIENT_SECRET: ''", "GOOGLE_CLIENT_SECRET: '#{process.env.GOOGLE_CLIENT_SECRET or ''}'"
grunt.file.write options.config, new_config_string
else
grunt.warn 'Failed updating keys in config'
grunt.registerTask 'productbuild', 'Build Mac Appstore package', ->
execSync = require('child_process').execSync
options = @options()
[
'Electron Framework.framework/Versions/A/Electron Framework'
'Electron Framework.framework/Versions/A/Libraries/libffmpeg.dylib'
'Electron Framework.framework/Versions/A/Libraries/libnode.dylib'
'Electron Framework.framework/'
"#{options.name} Helper.app/Contents/MacOS/#{options.name} Helper"
"#{options.name} Helper.app/"
"#{options.name} Helper EH.app/Contents/MacOS/#{options.name} Helper EH"
"#{options.name} Helper EH.app/"
"#{options.name} Helper NP.app/Contents/MacOS/#{options.name} Helper NP"
"#{options.name} Helper NP.app/"
].forEach (framework) ->
execSync "codesign --deep -fs '#{options.sign.app}' --entitlements '#{options.child}' '#{options.dir}/Contents/Frameworks/#{framework}'"
execSync "codesign -fs '#{options.sign.app}' --entitlements '#{options.child}' '#{options.dir}/Contents/MacOS/#{options.name}'"
execSync "codesign -fs '#{options.sign.app}' --entitlements '#{options.parent}' '#{options.dir}'"
execSync "productbuild --component '#{options.dir}' /Applications --sign '#{options.sign.package}' '#{options.name}.pkg'"
grunt.registerTask 'release', ['build-inc', 'gitcommit', 'gittag', 'gitpush']
grunt.registerTask 'macos', ['clean:macos', 'update-keys', 'release-internal', 'electron:macos_internal']
grunt.registerTask 'macos-prod', ['clean:macos', 'update-keys', 'release-prod', 'electron:macos_prod', 'productbuild']
grunt.registerTask 'win', ['clean:win', 'update-keys', 'release-internal', 'electron:win_internal', 'create-windows-installer:internal']
grunt.registerTask 'win-prod', ['clean:win', 'update-keys', 'release-prod', 'electron:win_prod', 'create-windows-installer:prod']
grunt.registerTask 'linux-32', ['clean:linux', 'update-keys', 'release-internal', 'shell:linux32']
grunt.registerTask 'linux-64', ['clean:linux', 'update-keys', 'release-internal', 'shell:linux64']
grunt.registerTask 'linux-32-prod', ['clean:linux', 'update-keys', 'release-prod', 'shell:linux32']
grunt.registerTask 'linux-64-prod', ['clean:linux', 'update-keys', 'release-prod', 'shell:linux64']