Skip to content

Commit

Permalink
Compress artifacts when passing --compress-artifacts to script/build
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Scandurra committed Aug 9, 2016
1 parent 2db3ee9 commit 6d803ed
Showing 5 changed files with 60 additions and 9 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -25,10 +25,9 @@ install:
- nvm use --delete-prefix $NODE_VERSION
- npm install -g npm
- script/bootstrap
- script/build
- script/build --compress-artifacts

script:
- echo 'Run tests at some point.'
script: false

cache:
directories:
4 changes: 3 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ install:
build_script:
- cd %APPVEYOR_BUILD_FOLDER%
- script\bootstrap.cmd
- script\build.cmd --code-sign
- script\build.cmd --code-sign --compress-artifacts

test: off
deploy: off
@@ -34,6 +34,8 @@ artifacts:
name: AtomSetup.exe
- path: out\AtomSetup.msi
name: AtomSetup.msi
- path: out\atom-windows.zip
name: atom-windows.zip
- path: out\RELEASES
name: RELEASES
- path: out\atom-*-delta.nupkg
6 changes: 1 addition & 5 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -22,11 +22,7 @@ dependencies:

override:
- script/bootstrap
- script/build --code-sign

post:
- cd out && zip -r ./atom-mac.zip ./Atom.app
- cd out && zip -r ./atom-mac-symbols.zip ./symbols
- script/build --code-sign --compress-artifacts

cache_directories:
- cache
7 changes: 7 additions & 0 deletions script/build
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ require('colors')
const argv = require('yargs').argv
const cleanOutputDirectory = require('./lib/clean-output-directory')
const codeSignOnMac = require('./lib/code-sign-on-mac')
const compressArtifacts = require('./lib/compress-artifacts')
const copyAssets = require('./lib/copy-assets')
const createWindowsInstaller = require('./lib/create-windows-installer')
const dumpSymbols = require('./lib/dump-symbols')
@@ -52,6 +53,12 @@ dumpSymbols()
return createWindowsInstaller(packagedAppPath, argv.codeSign).then(() => packagedAppPath)
}
}).then(packagedAppPath => {
if (argv.compressArtifacts) {
compressArtifacts(packagedAppPath)
} else {
console.log('Skipping artifacts compression. Specify the --compress-artifacts option to compress Atom binaries (and symbols on macOS)'.gray)
}

if (argv.install) {
installApplication(packagedAppPath)
} else {
47 changes: 47 additions & 0 deletions script/lib/compress-artifacts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict'

const childProcess = require('child_process')
const fs = require('fs-extra')
const path = require('path')

const CONFIG = require('../config')

module.exports = function (packagedAppPath) {
let appArchiveName
if (process.platform === 'darwin') {
appArchiveName = 'atom-mac.zip'
} else if (process.platform === 'win32') {
appArchiveName = 'atom-windows.zip'
} else {
appArchiveName = 'atom-amd64.tar.gz'
}
const appArchivePath = path.join(CONFIG.buildOutputPath, appArchiveName)
compress(packagedAppPath, appArchivePath)

if (process.platform === 'darwin') {
const symbolsArchivePath = path.join(CONFIG.buildOutputPath, 'atom-mac-symbols.zip')
compress(CONFIG.symbolsPath, symbolsArchivePath)
}
}

function compress (inputDirPath, outputArchivePath) {
if (fs.existsSync(outputArchivePath)) {
console.log(`Deleting "${outputArchivePath}"`)
fs.removeSync(outputArchivePath)
}

console.log(`Compressing "${inputDirPath}" to "${outputArchivePath}"`)
let compressCommand, compressArguments
if (process.platform === 'darwin') {
compressCommand = 'zip'
compressArguments = ['-r', '--symlinks']
} else if (process.platform === 'win32') {
compressCommand = '7z.exe'
compressArguments = ['a', '-r']
} else {
compressCommand = 'tar'
compressArguments = ['caf']
}
compressArguments.push(outputArchivePath, path.basename(inputDirPath))
childProcess.spawnSync(compressCommand, compressArguments, {cwd: path.dirname(inputDirPath)})
}

0 comments on commit 6d803ed

Please sign in to comment.