|
| 1 | +# |
| 2 | +# Wire |
| 3 | +# Copyright (C) 2016 Wire Swiss GmbH |
| 4 | +# |
| 5 | +# This program is free software: you can redistribute it and/or modify |
| 6 | +# it under the terms of the GNU General Public License as published by |
| 7 | +# the Free Software Foundation, either version 3 of the License, or |
| 8 | +# (at your option) any later version. |
| 9 | +# |
| 10 | +# This program is distributed in the hope that it will be useful, |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +# GNU General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU General Public License |
| 16 | +# along with this program. If not, see http://www.gnu.org/licenses/. |
| 17 | +# |
| 18 | + |
| 19 | +electron_packager = require 'electron-packager' |
| 20 | + |
| 21 | +ELECTRON_PACKAGE_JSON = 'electron/package.json' |
| 22 | +PACKAGE_JSON = 'package.json' |
| 23 | +INFO_JSON = 'info.json' |
| 24 | + |
| 25 | +module.exports = (grunt) -> |
| 26 | + require('load-grunt-tasks') grunt, pattern: ['grunt-*'] |
| 27 | + path = require 'path' |
| 28 | + |
| 29 | + grunt.initConfig |
| 30 | + pkg: grunt.file.readJSON PACKAGE_JSON |
| 31 | + info: grunt.file.readJSON INFO_JSON |
| 32 | + |
| 33 | + clean: |
| 34 | + wrap: 'wrap' |
| 35 | + build: 'wrap/build' |
| 36 | + dist: 'wrap/dist' |
| 37 | + win: 'wrap/**/<%= info.name %>-win*' |
| 38 | + osx: 'wrap/**/<%= info.name %>-darwin*' |
| 39 | + linux: 'wrap/**/<%= info.name %>-linux*' |
| 40 | + pkg: '*.pkg' |
| 41 | + |
| 42 | + productbuild: |
| 43 | + options: |
| 44 | + sign: |
| 45 | + app: '<%= info.sign.app %>' |
| 46 | + package: '<%= info.sign.package %>' |
| 47 | + parent: 'resources/osx/entitlements/parent.plist' |
| 48 | + child: 'resources/osx/entitlements/child.plist' |
| 49 | + dir: 'wrap/dist/<%= info.name %>-mas-x64/<%= info.name %>.app' |
| 50 | + name: '<%= info.name %>' |
| 51 | + |
| 52 | + electron: |
| 53 | + options: |
| 54 | + name: '<%= info.name %>' |
| 55 | + dir: 'electron' |
| 56 | + out: 'wrap/build' |
| 57 | + version: '1.3.1' |
| 58 | + overwrite: true |
| 59 | + arch: 'all' |
| 60 | + asar: true |
| 61 | + 'app-copyright': '<%= info.copyright %>' |
| 62 | + 'app-version': '<%= info.version %>' |
| 63 | + 'build-version': '<%= info.build %>' |
| 64 | + 'min-version': '10.9.0' |
| 65 | + protocols: [ |
| 66 | + {name: '', schemes: ['wire']} |
| 67 | + ] |
| 68 | + osx_internal: |
| 69 | + options: |
| 70 | + name: '<%= info.nameInternal %>' |
| 71 | + platform: 'mas' |
| 72 | + icon: 'resources/osx/wire.internal.icns' |
| 73 | + 'app-bundle-id': 'com.wearezeta.zclient.mac.internal' |
| 74 | + 'dev-region': 'en' |
| 75 | + osx_prod: |
| 76 | + options: |
| 77 | + platform: 'mas' |
| 78 | + out: 'wrap/dist/' |
| 79 | + icon: 'resources/osx/wire.icns' |
| 80 | + 'app-category-type': 'public.app-category.social-networking' |
| 81 | + 'app-bundle-id': 'com.wearezeta.zclient.mac' |
| 82 | + 'helper-bundle-id': 'com.wearezeta.zclient.mac.helper' |
| 83 | + 'dev-region': 'en' |
| 84 | + 'extend-info': 'resources/osx/custom.plist' |
| 85 | + win_internal: |
| 86 | + options: |
| 87 | + name: '<%= info.nameInternal %>' |
| 88 | + platform: 'win32' |
| 89 | + icon: 'resources/win/wire.internal.ico' |
| 90 | + arch: 'ia32' |
| 91 | + 'version-string': |
| 92 | + CompanyName: '<%= info.name %>' |
| 93 | + FileDescription: '<%= info.description %>' |
| 94 | + OriginalFilename: '<%= info.nameInternal %>.exe' |
| 95 | + ProductName: '<%= info.nameInternal %>' |
| 96 | + InternalName: '<%= info.nameInternal %>.exe' |
| 97 | + |
| 98 | + win_prod: |
| 99 | + options: |
| 100 | + platform: 'win32' |
| 101 | + icon: 'resources/win/wire.ico' |
| 102 | + arch: 'ia32' |
| 103 | + 'version-string': |
| 104 | + CompanyName: '<%= info.name %>' |
| 105 | + FileDescription: '<%= info.description %>' |
| 106 | + OriginalFilename: '<%= info.name %>.exe' |
| 107 | + ProductName: '<%= info.name %>' |
| 108 | + InternalName: '<%= info.name %>.exe' |
| 109 | + |
| 110 | + linux: |
| 111 | + options: |
| 112 | + platform: 'linux' |
| 113 | + |
| 114 | + 'create-windows-installer': |
| 115 | + internal: |
| 116 | + title: '<%= info.nameInternal %>' |
| 117 | + description: '<%= info.description %>' |
| 118 | + version: '<%= info.version %>.<%= info.build %>' |
| 119 | + appDirectory: 'wrap/build/<%= info.nameInternal %>-win32-ia32' |
| 120 | + outputDirectory: 'wrap/internal/<%= info.nameInternal %>-win32-ia32' |
| 121 | + authors: '<%= info.nameInternal %>' |
| 122 | + exe: '<%= info.nameInternal %>.exe' |
| 123 | + setupIcon: 'resources/win/wire.internal.ico' |
| 124 | + noMsi: true |
| 125 | + loadingGif: 'resources/win/icon.internal.256x256.png' |
| 126 | + iconUrl: 'https://wire-app.wire.com/win/internal/wire.internal.ico' |
| 127 | + prod: |
| 128 | + title: '<%= info.name %>' |
| 129 | + description: '<%= info.description %>' |
| 130 | + version: '<%= info.version %>.<%= info.build %>' |
| 131 | + appDirectory: 'wrap/build/<%= info.name %>-win32-ia32' |
| 132 | + outputDirectory: 'wrap/prod/<%= info.name %>-win32-ia32' |
| 133 | + authors: '<%= info.name %>' |
| 134 | + exe: '<%= info.name %>.exe' |
| 135 | + setupIcon: 'resources/win/wire.ico' |
| 136 | + noMsi: true |
| 137 | + loadingGif: 'resources/win/icon.256x256.png' |
| 138 | + iconUrl: 'https://wire-app.wire.com/win/prod/wire.ico' |
| 139 | + |
| 140 | + gitcommit: |
| 141 | + release: |
| 142 | + options: |
| 143 | + message: 'Release <%= info.version %>.<%= info.build %>' |
| 144 | + files: |
| 145 | + src: [INFO_JSON, ELECTRON_PACKAGE_JSON] |
| 146 | + |
| 147 | + gittag: |
| 148 | + release: |
| 149 | + options: |
| 150 | + tag: 'release/<%= info.version %>.<%= info.build %>' |
| 151 | + message: 'Release <%= info.version %>.<%= info.build %>' |
| 152 | + |
| 153 | + gitpush: |
| 154 | + task: |
| 155 | + options: |
| 156 | + tags: true |
| 157 | + branch: 'master' |
| 158 | + |
| 159 | + githubChanges: |
| 160 | + release: |
| 161 | + options: |
| 162 | + auth: true |
| 163 | + onlyPulls: true |
| 164 | + useCommitBody: true |
| 165 | + owner : 'wireapp' |
| 166 | + repository : 'wire-desktop' |
| 167 | + |
| 168 | + |
| 169 | +############################################################################### |
| 170 | +# Tasks |
| 171 | +############################################################################### |
| 172 | + grunt.registerTask 'build-inc', -> |
| 173 | + info = grunt.config.get 'info' |
| 174 | + info.build = "#{parseInt(info.build, 10) + 1 }" |
| 175 | + grunt.config.set 'info', info |
| 176 | + grunt.file.write INFO_JSON, JSON.stringify(info, null, 2) + '\n' |
| 177 | + |
| 178 | + electron_pkg = grunt.file.readJSON ELECTRON_PACKAGE_JSON |
| 179 | + electron_pkg.version = "#{info.version}.#{info.build}" |
| 180 | + grunt.file.write ELECTRON_PACKAGE_JSON, JSON.stringify(electron_pkg, null, 2) + '\n' |
| 181 | + |
| 182 | + grunt.log.write("Build number increased to #{info.build} ").ok(); |
| 183 | + |
| 184 | + grunt.registerTask 'release-internal', -> |
| 185 | + info = grunt.config.get 'info' |
| 186 | + electron_pkg = grunt.file.readJSON ELECTRON_PACKAGE_JSON |
| 187 | + electron_pkg.updateWinUrl = info.updateWinUrlInternal |
| 188 | + electron_pkg.environment = 'internal' |
| 189 | + electron_pkg.name = info.nameInternal.toLowerCase() |
| 190 | + electron_pkg.productName = info.nameInternal |
| 191 | + grunt.file.write ELECTRON_PACKAGE_JSON, JSON.stringify(electron_pkg, null, 2) + '\n' |
| 192 | + grunt.log.write("Releases URL points to #{electron_pkg.updateWinUrl} ").ok(); |
| 193 | + |
| 194 | + grunt.registerTask 'release-prod', -> |
| 195 | + info = grunt.config.get 'info' |
| 196 | + electron_pkg = grunt.file.readJSON ELECTRON_PACKAGE_JSON |
| 197 | + electron_pkg.updateWinUrl = info.updateWinUrlProd |
| 198 | + electron_pkg.environment = 'production' |
| 199 | + electron_pkg.name = info.name.toLowerCase() |
| 200 | + electron_pkg.productName = info.name |
| 201 | + grunt.file.write ELECTRON_PACKAGE_JSON, JSON.stringify(electron_pkg, null, 2) + '\n' |
| 202 | + grunt.log.write("Releases URL points to #{electron_pkg.updateWinUrl} ").ok(); |
| 203 | + |
| 204 | + grunt.registerMultiTask 'electron', 'Package Electron apps', -> |
| 205 | + done = this.async() |
| 206 | + electron_packager @options(), (error) -> |
| 207 | + if (error) |
| 208 | + grunt.warn error |
| 209 | + else |
| 210 | + done() |
| 211 | + |
| 212 | + grunt.registerTask 'productbuild', 'Build Mac Appstore package', -> |
| 213 | + execSync = require('child_process').execSync |
| 214 | + options = @options() |
| 215 | + |
| 216 | + [ |
| 217 | + 'Electron Framework.framework/Versions/A/Electron Framework' |
| 218 | + 'Electron Framework.framework/Versions/A/Libraries/libffmpeg.dylib' |
| 219 | + 'Electron Framework.framework/Versions/A/Libraries/libnode.dylib' |
| 220 | + 'Electron Framework.framework/' |
| 221 | + "#{options.name} Helper.app/Contents/MacOS/#{options.name} Helper" |
| 222 | + "#{options.name} Helper.app/" |
| 223 | + "#{options.name} Helper EH.app/Contents/MacOS/#{options.name} Helper EH" |
| 224 | + "#{options.name} Helper EH.app/" |
| 225 | + "#{options.name} Helper NP.app/Contents/MacOS/#{options.name} Helper NP" |
| 226 | + "#{options.name} Helper NP.app/" |
| 227 | + ].forEach (framework) -> |
| 228 | + execSync "codesign --deep -fs '#{options.sign.app}' --entitlements '#{options.child}' '#{options.dir}/Contents/Frameworks/#{framework}'" |
| 229 | + |
| 230 | + execSync "codesign -fs '#{options.sign.app}' --entitlements '#{options.child}' '#{options.dir}/Contents/MacOS/#{options.name}'" |
| 231 | + execSync "codesign -fs '#{options.sign.app}' --entitlements '#{options.parent}' '#{options.dir}'" |
| 232 | + execSync "productbuild --component '#{options.dir}' /Applications --sign '#{options.sign.package}' '#{options.name}.pkg'" |
| 233 | + |
| 234 | + |
| 235 | + grunt.registerTask 'release', ['build-inc', 'gitcommit', 'gittag', 'gitpush'] |
| 236 | + |
| 237 | + grunt.registerTask 'osx', ['clean:osx', 'release-internal', 'electron:osx_internal'] |
| 238 | + grunt.registerTask 'osx-prod', ['clean:osx', 'release-prod', 'electron:osx_prod', 'productbuild'] |
| 239 | + |
| 240 | + grunt.registerTask 'win', ['clean:win', 'release-internal', 'electron:win_internal', 'create-windows-installer:internal'] |
| 241 | + grunt.registerTask 'win-prod', ['clean:win', 'release-prod', 'electron:win_prod', 'create-windows-installer:prod'] |
| 242 | + |
| 243 | + grunt.registerTask 'linux', ['clean:linux', 'release-internal', 'electron:linux'] |
0 commit comments