Skip to content

Commit

Permalink
move redhat packaging out to own step (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey committed Jun 3, 2020
1 parent 8060dd2 commit b24b46e
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 27 deletions.
3 changes: 1 addition & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,14 @@ jobs:
docker run -v $(Build.SourcesDirectory):/src -v
/tmp/local/.cache:/.cache -v /tmp/local/.yarn:/.yarn -v
/tmp/local/.node-gyp:/.node-gyp -v /tmp/local/.local:/.local -w /src
shiftkey/desktop:snapcraft-node-yarn sh -c "yarn run package"
shiftkey/desktop:packaging-node-yarn sh -c "yarn run package"
displayName: 'Package in Container'
- task: CopyFiles@2
inputs:
contents: |
dist/*.AppImage
dist/*.deb
dist/*.rpm
dist/*.snap
dist/*.txt
targetFolder: $(Build.ArtifactStagingDirectory)
flattenFolders: true
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"electron-winstaller": "4.0.0"
},
"optionalDependencies": {
"electron-installer-debian": "3.0.0"
"electron-installer-debian": "3.0.0",
"electron-installer-redhat": "3.0.0"
}
}
1 change: 0 additions & 1 deletion script/electron-builder-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ linux:
- x-scheme-handler/x-github-client
- x-scheme-handler/x-github-desktop-auth
target:
- rpm
- AppImage
maintainer: 'GitHub, Inc <opensource+desktop@github.com>'
rpm:
Expand Down
17 changes: 2 additions & 15 deletions script/package-electron-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function packageElectronBuilder(): Promise<Array<string>> {

const appImageInstaller = `${distRoot}/GitHubDesktop-linux-*.AppImage`

let files = await globPromise(appImageInstaller)
const files = await globPromise(appImageInstaller)
if (files.length !== 1) {
return Promise.reject(
`Expected one AppImage installer but instead found '${files.join(
Expand All @@ -51,18 +51,5 @@ export async function packageElectronBuilder(): Promise<Array<string>> {

const appImageInstallerPath = files[0]

const rpmInstaller = `${distRoot}/GitHubDesktop-linux-*.rpm`

files = await globPromise(rpmInstaller)
if (files.length !== 1) {
return Promise.reject(
`Expected one RPM installer but instead found '${files.join(
', '
)}' - exiting...`
)
}

const rpmInstallerPath = files[0]

return Promise.resolve([appImageInstallerPath, rpmInstallerPath])
return Promise.resolve([appImageInstallerPath])
}
102 changes: 102 additions & 0 deletions script/package-redhat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { promisify } from 'util'
import { join } from 'path'

import * as glob from 'glob'
const globPromise = promisify(glob)

import { rename } from 'fs-extra'

import { getVersion } from '../app/package-info'
import { getDistPath, getDistRoot } from './dist-info'

const distRoot = getDistRoot()

// best guess based on documentation
type RedhatOptions = {
// required
src: string
dest: string
arch: 'x86_64'
// optional
description?: string
productDescription?: string
categories?: Array<string>
icon?: any
scripts?: {
pre?: string
post?: string
preun?: string
postun?: string
}
homepage?: string
mimeType?: Array<string>
requires?: Array<string>
}

const options: RedhatOptions = {
src: getDistPath(),
dest: distRoot,
arch: 'x86_64',
description: 'Simple collaboration from your desktop',
productDescription:
'This is the unofficial port of GitHub Desktop for Linux distributions',
categories: ['GNOME', 'GTK', 'Development'],
requires: [
// default Electron dependencies
'libXScrnSaver',
'libappindicator',
'libX11-xcb',
'alsa-lib',
// dugite-native dependencies
'libcurl',
// keytar dependencies
'libsecret',
'gnome-keyring',
],
icon: {
'256x256': 'app/static/logos/256x256.png',
'512x512': 'app/static/logos/512x512.png',
'1024x1024': 'app/static/logos/1024x1024.png',
},
scripts: {
post: 'script/resources/rpm/post.sh',
preun: 'script/resources/rpm/preun.sh',
},
homepage: 'https://github.com/shiftkey/desktop',
mimeType: [
'x-scheme-handler/x-github-client',
'x-scheme-handler/x-github-desktop-auth',
// workaround for handling OAuth flow until we figure out what we're doing
// with the development OAuth details
//
// see https://github.com/shiftkey/desktop/issues/72 for more details
'x-scheme-handler/x-github-desktop-dev-auth',
],
}

export async function packageRedhat(): Promise<string> {
if (process.platform === 'win32') {
return Promise.reject('Windows is not supported')
}

const installer = require('electron-installer-redhat')

await installer(options)
const installersPath = `${distRoot}/github-desktop*.rpm`

const files = await globPromise(installersPath)

if (files.length !== 1) {
return Promise.reject(
`Expected one file but instead found '${files.join(', ')}' - exiting...`
)
}

const oldPath = files[0]

const newFileName = `GitHubDesktop-linux-${getVersion()}.rpm`
const newPath = join(distRoot, newFileName)
await rename(oldPath, newPath)

return Promise.resolve(newPath)
}
22 changes: 14 additions & 8 deletions script/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { isAppveyor } from './build-platforms'

import { packageElectronBuilder } from './package-electron-builder'
import { packageDebian } from './package-debian'
import { packageRedhat } from './package-redhat'

const distPath = getDistPath()
const productName = getProductName()
Expand Down Expand Up @@ -178,16 +179,21 @@ async function packageLinux() {
console.log('Updating file mode for chrome-sandbox…')
fs.chmodSync(helperPath, 0o4755)
}
try {
const files = await packageElectronBuilder()
const debianPackage = await packageDebian()
const redhatPackage = await packageRedhat()

const files = await packageElectronBuilder()
const debianPackage = await packageDebian()
const installers = [...files, debianPackage, redhatPackage]

const installers = [...files, debianPackage]
console.log(`Installers created:`)
for (const installer of installers) {
console.log(` - ${installer}`)
}

console.log(`Installers created:`)
for (const installer of installers) {
console.log(` - ${installer}`)
generateChecksums(installers)
} catch (err) {
console.error('A problem occurred with the packaging step', err)
process.exit(1)
}

generateChecksums(installers)
}
12 changes: 12 additions & 0 deletions script/resources/rpm/post.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

INSTALL_DIR="/usr/lib/github-desktop"
CLI_DIR="$INSTALL_DIR/resources/app/static"

# add executable permissions for CLI interface
chmod +x "$CLI_DIR"/github || :

# create symbolic links to /usr/bin directory
ln -f -s "$CLI_DIR"/github /usr/bin || :

exit 0
8 changes: 8 additions & 0 deletions script/resources/rpm/preun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

BASE_FILE="/usr/bin/github"

# remove symbolic links in /usr/bin directory
test -f ${BASE_FILE} && unlink ${BASE_FILE}

exit 0
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3539,6 +3539,18 @@ electron-installer-debian@3.0.0:
word-wrap "^1.2.3"
yargs "^15.0.1"

electron-installer-redhat@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/electron-installer-redhat/-/electron-installer-redhat-3.0.0.tgz#0a066eb9f9b3e691d58c2b41eea1055e8d5ffa92"
integrity sha512-BtYh174AOIGq0iDges4/fihqJYw8WsWXRKuRpKvUlkqrwfeGMWqln28+kKV5IW6GPfHjRFeCO5dcMUioUDBo1A==
dependencies:
debug "^4.1.1"
electron-installer-common "^0.10.0"
fs-extra "^8.1.0"
lodash "^4.17.15"
word-wrap "^1.2.3"
yargs "^15.1.0"

electron-notarize@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/electron-notarize/-/electron-notarize-0.2.1.tgz#759e8006decae19134f82996ed910db26d9192cc"
Expand Down

0 comments on commit b24b46e

Please sign in to comment.