pulsar/build/tasks/set-version-task.coffee
Joe Fitzgerald 19334be188 Add Appveyor CI
- Add Appveyor badge
- Add Appveyor.yml definition, with encrypted ATOM_ACCESS_TOKEN
- Add cibuild.cmd script to launch cibuild on Windows
- Prepare to release Atom on Windows from Appveyor (but don't do it yet)
- Reduce dependence on JANKY in ci scripts + tasks
- Suppress release activities on PRs for Travis and Appveyor
- Cache ~/.atom/.apm, ~/.atom/.node-gyp/.atom, and ~/.atom/.npm on Appveyor
2015-11-10 15:37:01 -07:00

59 lines
2.0 KiB
CoffeeScript

fs = require 'fs'
path = require 'path'
module.exports = (grunt) ->
{spawn} = require('./task-helpers')(grunt)
getVersion = (callback) ->
releasableBranches = ['stable', 'beta']
channel = grunt.config.get('atom.channel')
shouldUseCommitHash = if channel in releasableBranches then false else true
inRepository = fs.existsSync(path.resolve(__dirname, '..', '..', '.git'))
{version} = require(path.join(grunt.config.get('atom.appDir'), 'package.json'))
if shouldUseCommitHash and inRepository
cmd = 'git'
args = ['rev-parse', '--short', 'HEAD']
spawn {cmd, args}, (error, {stdout}={}, code) ->
commitHash = stdout?.trim?()
combinedVersion = "#{version}-#{commitHash}"
callback(error, combinedVersion)
else
callback(null, version)
grunt.registerTask 'set-version', 'Set the version in the plist and package.json', ->
done = @async()
getVersion (error, version) ->
if error?
done(error)
return
appDir = grunt.config.get('atom.appDir')
# Replace version field of package.json.
packageJsonPath = path.join(appDir, 'package.json')
packageJson = require(packageJsonPath)
packageJson.version = version
packageJsonString = JSON.stringify(packageJson)
fs.writeFileSync(packageJsonPath, packageJsonString)
if process.platform is 'darwin'
cmd = 'script/set-version'
args = [grunt.config.get('atom.buildDir'), version]
spawn {cmd, args}, (error, result, code) -> done(error)
else if process.platform is 'win32'
shellAppDir = grunt.config.get('atom.shellAppDir')
shellExePath = path.join(shellAppDir, 'atom.exe')
strings =
CompanyName: 'GitHub, Inc.'
FileDescription: 'Atom'
LegalCopyright: 'Copyright (C) 2015 GitHub, Inc. All rights reserved'
ProductName: 'Atom'
ProductVersion: version
rcedit = require('rcedit')
rcedit(shellExePath, {'version-string': strings}, done)
else
done()