Skip to content

Commit

Permalink
Merge pull request desktop#3563 from desktop/more-flexible-package-ge…
Browse files Browse the repository at this point in the history
…neration

use electron-builder directly for Linux builds
  • Loading branch information
joshaber authored Dec 12, 2017
2 parents e2069f8 + f8902f7 commit 767b90b
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 392 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ cache:
- node_modules
- $HOME/.electron
- .eslintcache
- $HOME/.cache/electron-builder

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.3.2
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"productName": "GitHub Desktop",
"bundleID": "com.github.GitHubClient",
"companyName": "GitHub, Inc.",
"version": "1.0.11-beta0",
"version": "1.0.11-test0",
"main": "./main.js",
"repository": {
"type": "git",
Expand Down
3 changes: 3 additions & 0 deletions changelog.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"releases": {
"1.0.11-test0": [
"[Improved] now with a new major version of electron-packager"
],
"1.0.11-beta0": [
"[Improved] Refresh the pull requests list after fetching - #3503",
"[Improved] Rename the \"Install Update\" button to \"Quit and Install Update\" - #3494. Thanks @say25!",
Expand Down
15 changes: 2 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,9 @@
"@types/winston": "^2.2.0",
"@types/xml2js": "^0.4.0",
"electron": "1.7.9",
"electron-builder": "19.45.5",
"electron-installer-appimage": "^1.0.1",
"electron-builder": "19.48.3",
"electron-mocha": "^5.0.0",
"electron-packager": "^8.7.2",
"electron-packager": "^10.1.0",
"electron-winstaller": "2.5.2"
},
"optionalDependencies": {
"electron-installer-debian": "^0.7.1",
"electron-installer-redhat": "^0.5.0"
},
"build": {
"linux": {
"category": "Development",
"icon": "app/static/logos"
}
}
}
10 changes: 7 additions & 3 deletions script/dist-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ function getDistPath() {
function getExecutableName() {
const suffix = process.env.NODE_ENV === 'development' ? '-dev' : ''

return process.platform === 'win32'
? `${getWindowsIdentifierName()}${suffix}`
: productName
if (process.platform === 'win32') {
return `${getWindowsIdentifierName()}${suffix}`
} else if (process.platform === 'linux') {
return 'desktop'
} else {
return productName
}
}

function getOSXZipName() {
Expand Down
11 changes: 11 additions & 0 deletions script/electron-builder-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
productName: "GitHubDesktop"
artifactName: "${productName}-${os}-${arch}-${version}.${ext}"
linux:
category: "GNOME;GTK;Development"
packageCategory: "GNOME;GTK;Development"
icon: "app/static/logos"
target:
- deb
- rpm
- AppImage
maintainer: "GitHub, Inc <opensource+desktop@github.com>"
95 changes: 18 additions & 77 deletions script/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as path from 'path'
import * as electronInstaller from 'electron-winstaller'
import { getProductName, getCompanyName } from '../app/package-info'
import {
getDistRoot,
getDistPath,
getOSXZipPath,
getWindowsIdentifierName,
Expand Down Expand Up @@ -124,83 +123,25 @@ function packageWindows() {
})
}

function packageRedhat() {
const installer: ElectronInstallerRedhat = require('electron-installer-redhat')

const options = {
src: distPath,
dest: outputDir,
arch: 'amd64',
}

return new Promise((resolve, reject) => {
console.log('Creating .rpm package...')
installer(options, err => {
if (err) {
reject(err)
} else {
resolve()
}
})
})
}

function packageDebian() {
const installer: ElectronInstallerDebian = require('electron-installer-debian')

const options = {
src: distPath,
dest: outputDir,
arch: 'amd64',
}

return new Promise((resolve, reject) => {
console.log('Creating .deb package...')
installer(options, err => {
if (err) {
reject(err)
} else {
resolve()
}
})
})
}
function packageLinux() {
const electronBuilder = path.resolve(
__dirname,
'..',
'node_modules',
'.bin',
'electron-builder'
)

function packageAppImage() {
// Because electron-builder's CLI has some limits, we need to
// implement a couple of workarounds.
//
// First, it'll use `dist/make` for it's output directory, which
// results in this vague error when the directory doesn't exist:
//
// libburn : SORRY : Neither stdio-path nor its directory exist
//
// so let's just trash it (if already existing) and create the directory
const makeDir = path.join(getDistRoot(), 'make')
fs.removeSync(makeDir)
fs.mkdirSync(makeDir)

const installer: ElectronInstallerAppImage = require('electron-installer-appimage')

const options = {
dir: distPath,
targetArch: 'x64',
}
const configPath = path.resolve(__dirname, 'electron-builder-linux.yml')

return installer.default(options).then(() => {
// Second, we need to move the relevant files from dist/make up to
// the installers directory so it's alongside the other packages
cp.execSync(`cp ${makeDir}/*.AppImage ${outputDir}`)
})
}
const args = [
'build',
'--prepackaged',
distPath,
'--x64',
'--config',
configPath,
]

async function packageLinux(): Promise<void> {
try {
await packageRedhat()
await packageDebian()
await packageAppImage()
console.log(`Successfully created packages at ${outputDir}`)
} catch (e) {
console.log(`error during packaging: ${e}`)
}
cp.spawnSync(electronBuilder, args, { stdio: 'inherit' })
}
Loading

0 comments on commit 767b90b

Please sign in to comment.