Skip to content

Commit

Permalink
Automate releases
Browse files Browse the repository at this point in the history
Add Gulp tasks which:

* Build a web app version
* Build a desktop version
  • Loading branch information
wwwredfish committed Dec 18, 2015
1 parent 7e685aa commit 828b2d8
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 66 deletions.
2 changes: 1 addition & 1 deletion app/scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define(['underscore'], function (_) {

var constants = {};

constants.VERSION = '0.7.1-rc';
constants.VERSION = '0.7.1-rc2';
constants.URL = location.origin + location.pathname.replace('index.html', '');

// List of hosts and urls where default dropbox API will work
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "laverna",
"version": "0.7.1-rc",
"version": "0.7.1-rc2",
"license": "MPL2",
"dependencies": {
"ace": "#79eda6d2a8c4f788530cb5e6b238af67bfcc609d",
Expand Down
60 changes: 27 additions & 33 deletions electron.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,38 @@
'use strict';

// Server port
const PORT = 9100;

var app = require('app'),
connect = require('connect'),
windowStateKeeper = require('electron-window-state'),
BrowserWindow = require('browser-window'),
menu = require('menu');

var menuTemplate = [{
label: "Application",
submenu: [{
label: "Quit",
accelerator: "CmdOrCtrl+Q",
click: function() {
app.quit();
}
}]
// Start server
require('./server');

var menuTemplate = [{
label: 'Application',
submenu: [{
label: 'Quit',
accelerator: 'CmdOrCtrl+Q',
click: function() {
app.quit();
}
}]
}, {
label: 'Edit',
submenu: [{
label: 'Cut',
accelerator: 'CmdOrCtrl+X',
selector: 'cut:'
}, {
label: 'Copy',
accelerator: 'CmdOrCtrl+C',
selector: 'copy:'
}, {
label: "Edit",
submenu: [{
label: "Cut",
accelerator: "CmdOrCtrl+X",
selector: "cut:"
}, {
label: "Copy",
accelerator: "CmdOrCtrl+C",
selector: "copy:"
}, {
label: "Paste",
accelerator: "CmdOrCtrl+V",
selector: "paste:"
}]
}];

// Start Server
connect()
.use(connect.static(__dirname + '/dist'))
.listen(PORT);
label: 'Paste',
accelerator: 'CmdOrCtrl+V',
selector: 'paste:'
}]
}];

// Report crashes to our server.
// require('crash-reporter').start();
Expand Down
76 changes: 47 additions & 29 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var gulp = require('gulp'),
manifest = require('gulp-manifest'),
htmlmin = require('gulp-minify-html'),
cssmin = require('gulp-minify-css'),
shell = require('gulp-shell'),
pkg = require('./package.json'),

// Electron
Expand Down Expand Up @@ -362,36 +363,11 @@ gulp.task('build', ['build:before', 'manifest'], function() {
* Build Electron app.
* ------------------
*/
gulp.task('electron:copy', function() {
return gulp.src([
'./node_modules/buffer-crc32/**',
'./node_modules/bytes/**',
'./node_modules/connect/**',
'./node_modules/cookie/**',
'./node_modules/cookie-signature/**',
'./node_modules/debug/**',
'./node_modules/electron-window-state/**',
'./node_modules/fresh/**',
'./node_modules/jsonfile/**',
'./node_modules/mime/**',
'./node_modules/on-headers/**',
'./node_modules/parseurl/**',
'./node_modules/range-parser/**',
'./node_modules/send/**',
'./node_modules/serve-static/**',
'./node_modules/type-is/**',
'./node_modules/open/**',
'./node_modules/mkdirp/**',
'./package.json'
], {base: './'})
.pipe(gulp.dest('./dist/'));
});

/**
* To build an electron app for a specific platform, run:
* gulp electron --platform darwin-x64
*/
gulp.task('electron', ['electron:copy'], function() {
gulp.task('electron', ['copy:release'], function() {
var platforms = [
'darwin-x64',
// 'linux-arm',
Expand All @@ -406,10 +382,10 @@ gulp.task('electron', ['electron:copy'], function() {
}

return gulp.src('./electron.js')
.pipe(replace('__dirname + \'/dist\'', '__dirname'))
.pipe(gulp.dest('./dist'))
// .pipe(replace('__dirname + \'/dist\'', '__dirname'))
.pipe(gulp.dest('./release/laverna'))
.pipe(electron({
src : './dist',
src : './release/laverna',
packageJson : pkg,
release : './release',
cache : './.tmp',
Expand All @@ -434,3 +410,45 @@ gulp.task('electron', ['electron:copy'], function() {
}
}));
});

gulp.task('clean:release', ['build'], function() {
return gulp.src('./release/*', {read: false})
.pipe(clean());
});

gulp.task('copy:release', ['copy:dist'], function() {
return gulp.src([
'./node_modules/node-static/**',
'./node_modules/mime/**',
'./node_modules/colors/**',
'./node_modules/optimist/**',
'./node_modules/electron-window-state/**',
'./node_modules/open/**',
'./node_modules/jsonfile/**',
'./node_modules/mkdirp/**',
'./server.js',
'./package.json'
], {base: './'})
.pipe(gulp.dest('./release/laverna'));
});

gulp.task('copy:dist', ['build', 'clean:release'], function() {
return gulp.src('./dist')
.pipe(shell([
'mkdir -p ./release/laverna',
'cp -R ./dist ./release/laverna/dist',
]));
});

gulp.task('release', [
'build',
'clean:release',
'copy:dist',
'copy:release',
'electron'
], function() {
return gulp.src('./release')
.pipe(shell([
'cd ./release && zip -r ../release/webapp.zip ./laverna',
]));
});
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{
"name": "laverna",
"version": "0.7.1-rc",
"version": "0.7.1-rc2",
"license": "MPL2",
"repository": {
"type": "git",
"url": "https://github.com/Laverna/laverna"
},
"scripts": {
"start": "node ./server.js"
},
"main": "electron.js",
"dependencies": {},
"dependencies": {
"node-static": "^0.7.7"
},
"devDependencies": {
"chai": "^3.4.0",
"electron-window-state": "^1.1.0",
Expand All @@ -29,6 +34,7 @@
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
"gulp-requirejs-optimize": "^0.3.0",
"gulp-shell": "^0.5.1",
"gulp-uglify": "^1.4.1",
"jshint-stylish": "^2.1.0",
"merge-stream": "^1.0.0",
Expand Down
11 changes: 11 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';
const PORT = 9100;
var nStatic = require('node-static'),
http = require('http'),
file = new nStatic.Server('./dist');

http.createServer(function(req, res) {
file.serve(req, res);
}).listen(PORT);

console.log('Server is running on port: ' + PORT);

0 comments on commit 828b2d8

Please sign in to comment.