Skip to content

Commit

Permalink
chore(project): build distro via Travis
Browse files Browse the repository at this point in the history
* build distributions on Travis CI
* publish to GitHub releases

Related to #787
  • Loading branch information
nikku committed Jun 4, 2018
1 parent 9e69f66 commit 21f0ea2
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 29 deletions.
73 changes: 69 additions & 4 deletions .travis.yml
@@ -1,5 +1,70 @@
language: node_js
node_js: 'node'
language:
- node_js

script:
- npm run all
node_js:
- node

cache:
directories:
- node_modules
- $HOME/.cache/electron
- $HOME/.cache/electron-builder

jobs:
include:
- stage: test
script: npm run all -- --x64
- stage: "distro [windows+linux]"
os: linux
services: docker
language: generic
script:
- |
docker run --rm \
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS|APPVEYOR_|WIN_CSC_|CSC_|_TOKEN|_KEY|AWS_|STRIP|BUILD_') \
-v ${PWD}:/project \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:wine \
/bin/bash -c "npm install && npm run build -- --win --linux"
- stage: "distro [macos]"
os: osx
osx_image: xcode9
env:
- ELECTRON_CACHE=$HOME/.cache/electron
- ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder
script: npm install && npm run build -- --mac
- stage: "nightly build [windows+linux]"
os: linux
services: docker
language: generic
script:
- |
docker run --rm \
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS|APPVEYOR_|WIN_CSC_|CSC_|_TOKEN|_KEY|AWS_|STRIP|BUILD_') \
-v ${PWD}:/project \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:wine \
/bin/bash -c "npm install && npm run build -- --win --linux --nightly --no-publish"
- stage: "nightly build [macos]"
os: osx
osx_image: xcode9
env:
- ELECTRON_CACHE=$HOME/.cache/electron
- ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder
script: npm install && npm run build -- --mac --nightly --no-publish

before_cache:
- rm -rf $HOME/.cache/electron-builder/wine

stages:
- test
- name: "distro [windows+linux]"
if: tag =~ ^v\d
- name: "distro [macos]"
if: tag =~ ^v\d
- name: "nightly build [windows+linux]"
if: type IN (cron)
- name: "nightly build [macos]"
if: type IN (cron)
2 changes: 1 addition & 1 deletion app/package.json
@@ -1,6 +1,6 @@
{
"name": "camunda-modeler",
"version": "1.14.0",
"version": "1.15.1",
"description": "Camunda Modeler for BPMN, DMN and CMMN, based on bpmn.io",
"private": true,
"main": "lib/index.js",
Expand Down
4 changes: 2 additions & 2 deletions client/Gruntfile.js
Expand Up @@ -128,15 +128,15 @@ module.exports = function(grunt) {

grunt.registerTask('auto-test', [ 'karma:unit' ]);

grunt.registerTask('build-client', [
grunt.registerTask('build', [
'browserify:client',
'less',
'copy'
]);

grunt.registerTask('default', [
'test',
'build-client'
'build'
]);

grunt.registerTask('auto-build', [
Expand Down
3 changes: 2 additions & 1 deletion client/package.json
@@ -1,12 +1,13 @@
{
"name": "camunda-modeler-client",
"version": "1.14.0",
"version": "1.15.1",
"description": "Camunda Modeler client application",
"private": true,
"scripts": {
"test": "cross-env NODE_ENV=test grunt test",
"auto-test": "cross-env NODE_ENV=test grunt auto-test",
"all": "cross-env NODE_ENV=production grunt",
"build": "cross-env NODE_ENV=production grunt build",
"dev": "cross-env NODE_ENV=development grunt auto-build"
},
"dependencies": {
Expand Down
4 changes: 3 additions & 1 deletion electron-builder.json
@@ -1,5 +1,6 @@
{
"artifactName": "${productName}-${version}-${os}-${arch}.${ext}",
"appId": "com.camunda.CamundaModeler",
"productName": "Camunda Modeler",
"directories": {
"output": "distro"
},
Expand All @@ -24,6 +25,7 @@
"win": {
"target": [
"nsis",
"nsis-web",
"zip"
]
},
Expand Down
7 changes: 4 additions & 3 deletions package.json
Expand Up @@ -6,15 +6,16 @@
"app:auto-test": "npm run app:test -- --watch",
"app:dev": "electron app/dev",
"app:test": "mocha -r ./app/test/expect --recursive app/test",
"client:all": "(cd client && npm run all)",
"client:build": "(cd client && npm run build)",
"client:auto-test": "(cd client && npm run auto-test)",
"client:dev": "(cd client && npm run dev)",
"client:test": "(cd client && npm run test)",
"all": "run-s clean lint test client:all \"build -- {@}\" --",
"all": "run-s clean lint test \"build -- {@}\" --",
"auto-test": "run-p *:auto-test",
"clean": "del distro/*",
"clean": "del 'distro/*' app/public",
"dev": "run-p *:dev",
"distro": "node tasks/distro.js",
"build": "run-s client:build \"distro -- {@}\" --",
"lint": "eslint .",
"postinstall": "lerna bootstrap",
"release": "lerna publish",
Expand Down
79 changes: 62 additions & 17 deletions tasks/distro.js
@@ -1,5 +1,21 @@
#!/usr/bin/env node
const argv = require('yargs').argv

const argv = require('yargs')
.option('nightly', {
describe: 'build nightly distro',
type: 'boolean'
})
.option('publish', {
describe: 'publish distro',
type: 'boolean'
})
.option('targets', {
describe: 'target platforms to build distributions for',
coerce: function(val) {
return val.split(/,/g);
}
})
.argv;

const exec = require('execa').sync;

Expand All @@ -12,46 +28,75 @@ const {
publish
} = argv;

const availablePlatforms = {
win: 1,
linux: 1,
mac: 1
};

var nightlyOptions = [];
let nightlyOptions = [];

let nightlyVersion = nightly && getVersion(pkg, nightly && {
let nightlyVersion = nightly && getVersion(pkg, {
nightly: 'nightly'
});

if (nightlyVersion) {

nightlyOptions = [
`-c.buildVersion=${nightlyVersion}`,
'-c.artifactName=${productName}-${os}-${arch}.${ext}'
];

const publishNightlyArgs = [
'publish',
`--repo-version=${nightlyVersion}`,
'--skip-npm',
'--skip-git',
'--yes'
];

console.log(`
Setting ${pkg.name} version to nightly
---
lerna ${ publishNightlyArgs.join(' ') }
---
`);

exec('lerna', publishNightlyArgs, {
stdio: 'inherit'
});
}

const platforms =
Object.keys(availablePlatforms)
.map(k => argv[k] && k)
.filter(k => k);
// interpret shorthand target options
// --win, --linux, --mac(os)
const platforms = argv.targets || [
argv.win ? 'win' : null,
argv.linux ? 'linux': null,
(argv.macos || argv.mac) ? 'macos' : null
].filter(f => f);

const platformOptions = platforms.map(p => `--${p}`);

const publishOptions = publish ? [ '--publish=always' ] : [];
const publishOptions = typeof publish !== undefined ? [
`--publish=${ publish ? 'always' : 'never' }`
] : [];

const archOptions = 'x64' in argv ? [ '--x64' ] : [
'--ia32',
'--x64',
];

const args = [
...archOptions,
...platformOptions,
...nightlyOptions,
...publishOptions
...publishOptions,
...nightlyOptions
];

console.log(`
Building ${pkg.name} distro
---
version: ${nightlyVersion || pkg.version}
platforms: [${ platforms }]
platforms: [${ platforms.length && platforms || 'current' }]
publish: ${publish || false}
---
Expand Down

0 comments on commit 21f0ea2

Please sign in to comment.