Append sha to dev versions

This commit is contained in:
Antonio Scandurra
2016-07-29 15:57:06 +02:00
parent 3f469d77e0
commit ba0ecffcb0
3 changed files with 17 additions and 19 deletions

View File

@@ -4,6 +4,7 @@
'use strict'
const path = require('path')
const childProcess = require('child_process')
const appMetadata = require('../package.json')
@@ -11,14 +12,23 @@ const repositoryRootPath = path.resolve(__dirname, '..')
const buildOutputPath = path.join(repositoryRootPath, 'out')
const intermediateAppPath = path.join(buildOutputPath, 'app')
const cachePath = path.join(repositoryRootPath, 'cache')
const channel = getChannel()
module.exports = {
appMetadata, channel,
appMetadata, getAppVersion, getChannel,
repositoryRootPath, buildOutputPath, intermediateAppPath,
cachePath
}
function getAppVersion () {
let version = appMetadata.version
if (getChannel() === 'dev') {
const result = childProcess.spawnSync('git', ['rev-parse', '--short', 'HEAD'], {cwd: repositoryRootPath})
const commitHash = result.stdout.toString().trim()
version += '-' + commitHash
}
return version
}
function getChannel () {
if (appMetadata.version.match(/dev/) || isBuildingPR()) {
return 'dev'

View File

@@ -26,7 +26,7 @@ module.exports = function () {
}
fs.copySync(
path.join(CONFIG.repositoryRootPath, 'resources', 'app-icons', CONFIG.channel, 'png', '1024.png'),
path.join(CONFIG.repositoryRootPath, 'resources', 'app-icons', CONFIG.getChannel(), 'png', '1024.png'),
path.join(CONFIG.intermediateAppPath, 'resources', 'atom.png')
)
}

View File

@@ -12,13 +12,13 @@ const CONFIG = require('../config')
module.exports = async function () {
console.log(`Running electron-packager on ${CONFIG.intermediateAppPath}`)
const packagedAppPath = await runPackager({
'app-version': CONFIG.appMetadata.version,
'app-version': CONFIG.getAppVersion(),
'arch': process.arch,
'asar': {unpack: buildAsarUnpackGlobExpression()},
'build-version': CONFIG.appMetadata.version,
'build-version': CONFIG.getAppVersion(),
'download': {cache: CONFIG.cachePath},
'dir': CONFIG.intermediateAppPath,
'icon': path.join(CONFIG.repositoryRootPath, 'resources', 'app-icons', CONFIG.channel, 'atom.icns'),
'icon': path.join(CONFIG.repositoryRootPath, 'resources', 'app-icons', CONFIG.getChannel(), 'atom.icns'),
'out': CONFIG.buildOutputPath,
'overwrite': true,
'platform': process.platform,
@@ -73,19 +73,7 @@ function buildAsarUnpackGlobExpression () {
function runPackager (options) {
return new Promise((resolve, reject) => {
electronPackager({
'app-version': CONFIG.appMetadata.version,
'arch': process.arch,
'asar': {unpack: buildAsarUnpackGlobExpression()},
'build-version': CONFIG.appMetadata.version,
'download': {cache: CONFIG.cachePath},
'dir': CONFIG.intermediateAppPath,
'icon': path.join(CONFIG.repositoryRootPath, 'resources', 'app-icons', CONFIG.channel, 'atom.icns'),
'out': CONFIG.buildOutputPath,
'overwrite': true,
'platform': process.platform,
'version': CONFIG.appMetadata.electronVersion
}, (err, packagedAppPaths) => {
electronPackager(options, (err, packagedAppPaths) => {
if (err) {
reject(err)
throw new Error(err)