Files
agent/scripts/release.js
Róbert Kiss 0f558e4132 refactore: create feature modules (#387)
* add @angular/cli to the project

* increase nodejs version -> 8.2.1

* add lerna

* merge web and shared module

* move electron module into packages as uhk-agent

Electron agent functionality is not working

* delete symlinker

* convert private properties to public of component if used in html

* revert uhk-message.component

* fix component path

* fix the correct name of the uhk-message.component.scss

* building web and electron module

* delete uhk-renderer package

* handle device connect disconnect state

* add privilege detection

* fix set privilege functionality

* turn back download keymap functionality

* add bootstrap, select2 js and fix null pointer exception

* turn back upload data to keyboard

* fix send keymap

* fix test-serializer

* add missing package.json

* merging

* fix appveyor build

* fix linting

* turn back electron storage service

* commit the missing electron-datastorage-repository

* update node to 8.3.0 in .nvmrc and log node version in appveyor build

* set exact version number in appveyor build

* vertical align privilege and missing device components

* set back node version to 8 in appveyor

* move node-usb dependency from usb dir to root

maybe it is fix the appveyor build

* revert usb to root

* fix electron builder script

* fix electron builder script

* turn off electron devtools

* remove CTRL+U functionality

* fix CTRL+o

* fix lint error

* turnoff store freeze

* start process when got `Error: EPERM: operation not permitted` error

* move files from root usb dir -> packages/usb
2017-08-19 20:02:17 +02:00

144 lines
4.2 KiB
JavaScript

'use strict';
const jsonfile = require('jsonfile');
const TEST_BUILD = process.env.TEST_BUILD; // set true if you would like to test on your local machince
// electron-builder security override.
// Need if wanna create test release build from PR
process.env.PUBLISH_FOR_PULL_REQUEST = TEST_BUILD;
if (!process.env.CI && !TEST_BUILD) {
console.error('Create release only on CI server');
process.exit(1);
}
let branchName = '';
let pullRequestNr = '';
let gitTag = '';
let repoName = '';
if (process.env.TRAVIS) {
branchName = process.env.TRAVIS_BRANCH;
pullRequestNr = process.env.TRAVIS_PULL_REQUEST;
gitTag = process.env.TRAVIS_TAG;
repoName = process.env.TRAVIS_REPO_SLUG;
} else if (process.env.APPVEYOR) {
branchName = process.env.APPVEYOR_REPO_BRANCH;
pullRequestNr = process.env.APPVEYOR_PULL_REQUEST_NUMBER;
gitTag = process.env.APPVEYOR_REPO_TAG_NAME;
repoName = process.env.APPVEYOR_REPO_NAME;
}
console.log({ branchName, pullRequestNr, gitTag, repoName });
const isReleaseCommit = TEST_BUILD || branchName === gitTag && repoName === 'UltimateHackingKeyboard/agent';
if (!isReleaseCommit) {
console.log('It is not a release task. Skipping publish.');
process.exit(0)
}
const path = require('path');
const builder = require("electron-builder");
const Platform = builder.Platform;
const electron_build_folder = path.join(__dirname, '../packages/uhk-agent/dist');
let sha = '';
if (process.env.TRAVIS) {
sha = process.env.TRAVIS_COMMIT;
} else if (process.env.APPVEYOR) {
sha = process.env.APPVEYOR_REPO_COMMIT;
}
let target = '';
let artifactName = 'UHK.Agent-${version}-${os}';
let extraResources = [];
if (process.platform === 'darwin') {
target = Platform.MAC.createTarget();
artifactName += '.${ext}';
} else if (process.platform === 'win32') {
target = Platform.WINDOWS.createTarget();
// TODO: If all HID API test success then remove zadic extra resources
extraResources.push(`rules/zadic-ia32.exe`);
extraResources.push(`rules/zadic-x64.exe`);
artifactName += '-${arch}.${ext}';
extraResources.push(`rules/zadic-${process.arch}.exe`);
} else if (process.platform === 'linux') {
target = Platform.LINUX.createTarget();
artifactName += '.${ext}';
extraResources.push('rules/setup-rules.sh');
extraResources.push('rules/50-uhk60.rules');
} else {
console.error(`I dunno how to publish a release for ${process.platform} :(`);
process.exit(1);
}
if (process.platform === 'darwin') {
// TODO: Remove comment when macOS certificates boughted and exported
//require('./setup-macos-keychain').registerKeyChain();
}
let version = '';
if (TEST_BUILD || gitTag) {
const jsonVersion = require('../package.json').version;
version = gitTag;
updateVersionNumberIn2rndPackageJson(jsonVersion);
builder.build({
dir: TEST_BUILD,
targets: target,
appMetadata: {
main: 'electron-main.js',
name: 'UHK Agent',
author: {
name: 'Ultimate Gadget Laboratories'
},
version: jsonVersion
},
config: {
directories: {
app: electron_build_folder
},
appId: 'com.ultimategadgetlabs.uhk.agent',
productName: 'UHK Agent',
mac: {
category: 'public.app-category.utilities'
},
win: {
extraResources
},
linux: {
extraResources
},
publish: 'github',
artifactName,
files: [
'**/*'
]
},
})
.then(() => {
console.log('Packing success.');
})
.catch((error) => {
console.error(`${error}`);
process.exit(1);
})
}
else {
console.log('No git tag');
// TODO: Need it?
version = sha.substr(0, 8);
process.exit(1);
}
function updateVersionNumberIn2rndPackageJson(version) {
const jsonPath = path.join(__dirname,'../packages/uhk-agent/dist/package.json');
const json = require(jsonPath);
json.version = version;
jsonfile.writeFileSync(jsonPath, json, {spaces: 2})
}