1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-17 05:15:20 +03:00

Add support for creating a macOS .zip from gulp

This produces a nice .zip which can be distributed as is.
Unfortunately, the only way to produce a signed binary is by generating
the macOS app on macOS.
This commit is contained in:
Alberto García Hierro 2017-09-04 16:42:46 +01:00
parent 528f223a06
commit 4c41ccb719
2 changed files with 47 additions and 8 deletions

View file

@ -1,12 +1,17 @@
'use strict'; 'use strict';
var gulp = require('gulp'); var child_process = require('child_process');
var rename = require('gulp-rename'); var fs = require('fs');
var concat = require('gulp-concat'); var path = require('path');
var archiver = require('archiver');
var del = require('del'); var del = require('del');
var runSequence = require('run-sequence');
var NwBuilder = require('nw-builder'); var NwBuilder = require('nw-builder');
var gulp = require('gulp');
var concat = require('gulp-concat');
var runSequence = require('run-sequence');
// Each key in the *sources* variable must be an array of // Each key in the *sources* variable must be an array of
// the source files that will be combined into a single // the source files that will be combined into a single
@ -134,6 +139,7 @@ var output = {
var outputDir = './build/'; var outputDir = './build/';
var distDir = './dist/'; var distDir = './dist/';
var appsDir = './apps/';
function get_task_name(key) { function get_task_name(key) {
return 'build-' + key.replace(/([A-Z])/g, function($1){return "-"+$1.toLowerCase();}); return 'build-' + key.replace(/([A-Z])/g, function($1){return "-"+$1.toLowerCase();});
@ -196,11 +202,11 @@ gulp.task('dist', function() {
return runSequence('clean', 'dist-build'); return runSequence('clean', 'dist-build');
}); });
// Create app packages in ./apps // Create app directories in ./apps
gulp.task('release', ['dist'], function(done) { gulp.task('apps', ['dist'], function(done) {
var builder = new NwBuilder({ var builder = new NwBuilder({
files: './dist/**/*', files: './dist/**/*',
buildDir: './apps', buildDir: appsDir,
platforms: ['win32', 'osx64', 'linux64'], platforms: ['win32', 'osx64', 'linux64'],
flavor: 'normal', flavor: 'normal',
macIcns: './images/inav.icns', macIcns: './images/inav.icns',
@ -210,11 +216,44 @@ gulp.task('release', ['dist'], function(done) {
builder.build(function (err) { builder.build(function (err) {
if (err) { if (err) {
console.log("Error building NW apps:" + err); console.log("Error building NW apps:" + err);
done();
return;
} }
// Package apps as .zip files
done(); done();
}); });
}); });
function get_release_filename(platform, ext) {
var pkg = require('./package.json');
return 'INAV-Configurator_' + platform + '_' + pkg.version + '.' + ext;
}
gulp.task('release-macos', function() {
var pkg = require('./package.json');
var src = path.join(appsDir, pkg.name, 'osx64', pkg.name + '.app');
// Check if we want to sign the .app bundle
if (process.env.CODESIGN_IDENTITY) {
var sign_cmd = 'codesign --verbose --force --sign "' + process.env.CODESIGN_IDENTITY + '" ' + src;
child_process.execSync(sign_cmd);
}
var output = fs.createWriteStream(path.join(appsDir, get_release_filename('macOS', 'zip')));
var archive = archiver('zip', {
zlib: { level: 9 }
});
archive.on('warning', function(err) { throw err; });
archive.on('error', function(err) { throw err; });
archive.pipe(output);
archive.directory(src, 'INAV Configurator.app');
return archive.finalize();
});
// Create distributable .zip files in ./apps
gulp.task('release', function() {
// TODO: Windows, Linux
return runSequence('apps', 'release-macos');
});
gulp.task('watch', function () { gulp.task('watch', function () {
for(var k in output) { for(var k in output) {
gulp.watch(sources[k], [get_task_name(k)]); gulp.watch(sources[k], [get_task_name(k)]);

View file

@ -21,11 +21,11 @@
"author": "iNavFlight", "author": "iNavFlight",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"archiver": "^2.0.3",
"bluebird": "3.4.1", "bluebird": "3.4.1",
"del": "^3.0.0", "del": "^3.0.0",
"gulp": "~3.9.1", "gulp": "~3.9.1",
"gulp-concat": "~2.6.1", "gulp-concat": "~2.6.1",
"gulp-rename": "~1.2.2",
"inflection": "1.12.0", "inflection": "1.12.0",
"jquery": "2.1.4", "jquery": "2.1.4",
"jquery-ui-npm": "1.12.0", "jquery-ui-npm": "1.12.0",