2018-01-17 14:15:44 +00:00
|
|
|
import * as Path from 'path'
|
|
|
|
import * as Fs from 'fs'
|
2016-05-25 14:37:27 +00:00
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
import { getProductName, getVersion } from '../app/package-info'
|
2018-09-16 20:45:50 +00:00
|
|
|
import { getReleaseBranchName } from './build-platforms'
|
2016-05-25 14:37:27 +00:00
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
const productName = getProductName()
|
|
|
|
const version = getVersion()
|
2017-11-20 01:30:35 +00:00
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
const projectRoot = Path.join(__dirname, '..')
|
2016-05-25 14:37:27 +00:00
|
|
|
|
2019-11-04 18:41:06 +00:00
|
|
|
const publishChannels = ['production', 'test', 'beta']
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getDistRoot() {
|
|
|
|
return Path.join(projectRoot, 'dist')
|
2017-09-23 03:30:36 +00:00
|
|
|
}
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getDistPath() {
|
|
|
|
return Path.join(
|
2017-09-23 03:30:36 +00:00
|
|
|
getDistRoot(),
|
2021-04-26 16:44:09 +00:00
|
|
|
`${getExecutableName()}-${process.platform}-${getDistArchitecture()}`
|
2017-07-13 15:11:04 +00:00
|
|
|
)
|
2016-05-25 14:37:27 +00:00
|
|
|
}
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getExecutableName() {
|
2017-07-14 14:20:20 +00:00
|
|
|
const suffix = process.env.NODE_ENV === 'development' ? '-dev' : ''
|
|
|
|
|
2017-12-10 23:31:14 +00:00
|
|
|
if (process.platform === 'win32') {
|
|
|
|
return `${getWindowsIdentifierName()}${suffix}`
|
2017-12-11 23:24:16 +00:00
|
|
|
} else if (process.platform === 'linux') {
|
2017-12-10 23:31:14 +00:00
|
|
|
return 'desktop'
|
2017-12-11 23:24:16 +00:00
|
|
|
} else {
|
|
|
|
return productName
|
2017-12-10 23:31:14 +00:00
|
|
|
}
|
2016-05-25 14:37:27 +00:00
|
|
|
}
|
2016-05-25 14:47:51 +00:00
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getOSXZipName() {
|
2021-04-26 16:44:09 +00:00
|
|
|
return `${productName}-${getDistArchitecture()}.zip`
|
2016-06-16 19:42:35 +00:00
|
|
|
}
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getOSXZipPath() {
|
|
|
|
return Path.join(getDistPath(), '..', getOSXZipName())
|
2016-06-16 19:42:35 +00:00
|
|
|
}
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getWindowsInstallerName() {
|
2017-07-14 14:20:20 +00:00
|
|
|
const productName = getExecutableName()
|
2021-04-26 16:44:09 +00:00
|
|
|
return `${productName}Setup-${getDistArchitecture()}.msi`
|
2016-05-25 20:48:45 +00:00
|
|
|
}
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getWindowsInstallerPath() {
|
|
|
|
return Path.join(getDistPath(), '..', 'installer', getWindowsInstallerName())
|
2016-06-16 19:42:35 +00:00
|
|
|
}
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getWindowsStandaloneName() {
|
2017-07-14 14:20:20 +00:00
|
|
|
const productName = getExecutableName()
|
2021-04-26 16:44:09 +00:00
|
|
|
return `${productName}Setup-${getDistArchitecture()}.exe`
|
2016-06-16 19:42:35 +00:00
|
|
|
}
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getWindowsStandalonePath() {
|
|
|
|
return Path.join(getDistPath(), '..', 'installer', getWindowsStandaloneName())
|
2016-06-16 19:42:35 +00:00
|
|
|
}
|
|
|
|
|
2021-04-08 11:30:14 +00:00
|
|
|
export function getWindowsFullNugetPackageName(
|
|
|
|
includeArchitecture: boolean = false
|
|
|
|
) {
|
2021-04-26 16:44:09 +00:00
|
|
|
const architectureInfix = includeArchitecture
|
|
|
|
? `-${getDistArchitecture()}`
|
|
|
|
: ''
|
2021-04-08 11:30:14 +00:00
|
|
|
return `${getWindowsIdentifierName()}-${version}${architectureInfix}-full.nupkg`
|
2016-06-16 19:42:35 +00:00
|
|
|
}
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getWindowsFullNugetPackagePath() {
|
|
|
|
return Path.join(
|
2017-07-13 15:11:04 +00:00
|
|
|
getDistPath(),
|
|
|
|
'..',
|
|
|
|
'installer',
|
|
|
|
getWindowsFullNugetPackageName()
|
|
|
|
)
|
2016-05-25 20:48:45 +00:00
|
|
|
}
|
|
|
|
|
2021-04-08 11:30:14 +00:00
|
|
|
export function getWindowsDeltaNugetPackageName(
|
|
|
|
includeArchitecture: boolean = false
|
|
|
|
) {
|
2021-04-26 16:44:09 +00:00
|
|
|
const architectureInfix = includeArchitecture
|
|
|
|
? `-${getDistArchitecture()}`
|
|
|
|
: ''
|
2021-04-08 11:30:14 +00:00
|
|
|
return `${getWindowsIdentifierName()}-${version}${architectureInfix}-delta.nupkg`
|
2017-07-13 15:49:16 +00:00
|
|
|
}
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getWindowsDeltaNugetPackagePath() {
|
|
|
|
return Path.join(
|
2017-07-13 15:49:16 +00:00
|
|
|
getDistPath(),
|
|
|
|
'..',
|
|
|
|
'installer',
|
|
|
|
getWindowsDeltaNugetPackageName()
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getWindowsIdentifierName() {
|
2017-05-12 18:32:51 +00:00
|
|
|
return 'GitHubDesktop'
|
|
|
|
}
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getBundleSizes() {
|
2018-05-21 06:29:48 +00:00
|
|
|
// eslint-disable-next-line no-sync
|
2018-01-17 14:15:44 +00:00
|
|
|
const rendererStats = Fs.statSync(
|
|
|
|
Path.join(projectRoot, 'out', 'renderer.js')
|
2017-07-13 15:11:04 +00:00
|
|
|
)
|
2018-05-21 06:29:48 +00:00
|
|
|
// eslint-disable-next-line no-sync
|
2018-01-17 14:15:44 +00:00
|
|
|
const mainStats = Fs.statSync(Path.join(projectRoot, 'out', 'main.js'))
|
2017-06-19 20:35:46 +00:00
|
|
|
return { rendererSize: rendererStats.size, mainSize: mainStats.size }
|
|
|
|
}
|
|
|
|
|
2019-11-04 18:41:06 +00:00
|
|
|
export function isPublishable(): boolean {
|
|
|
|
const channelFromBranch = getChannelFromBranch()
|
|
|
|
return channelFromBranch !== undefined
|
|
|
|
? publishChannels.includes(channelFromBranch)
|
|
|
|
: false
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getChannel() {
|
|
|
|
const channelFromBranch = getChannelFromBranch()
|
|
|
|
return channelFromBranch !== undefined
|
|
|
|
? channelFromBranch
|
|
|
|
: process.env.NODE_ENV || 'development'
|
|
|
|
}
|
|
|
|
|
|
|
|
function getChannelFromBranch(): string | undefined {
|
2017-07-13 14:28:20 +00:00
|
|
|
// Branch name format: __release-CHANNEL-DEPLOY_ID
|
2017-07-13 18:39:33 +00:00
|
|
|
const pieces = getReleaseBranchName().split('-')
|
2017-07-13 14:28:20 +00:00
|
|
|
if (pieces.length < 3 || pieces[0] !== '__release') {
|
2019-11-04 18:41:06 +00:00
|
|
|
return
|
2017-07-13 14:28:20 +00:00
|
|
|
}
|
|
|
|
return pieces[1]
|
|
|
|
}
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getReleaseSHA() {
|
2017-09-21 06:56:49 +00:00
|
|
|
// Branch name format: __release-CHANNEL-DEPLOY_ID
|
|
|
|
const pieces = getReleaseBranchName().split('-')
|
|
|
|
if (pieces.length < 3 || pieces[0] !== '__release') {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return pieces[2]
|
|
|
|
}
|
|
|
|
|
2021-04-26 16:44:09 +00:00
|
|
|
export function getDistArchitecture(): 'arm64' | 'x64' {
|
2021-03-03 16:55:06 +00:00
|
|
|
// If a specific npm_config_arch is set, we use that one instead of the OS arch (to support cross compilation)
|
|
|
|
if (
|
|
|
|
process.env.npm_config_arch === 'arm64' ||
|
|
|
|
process.env.npm_config_arch === 'x64'
|
|
|
|
) {
|
|
|
|
return process.env.npm_config_arch
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process.arch === 'arm64') {
|
|
|
|
return 'arm64'
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Check if it's x64 running on an arm64 Windows with IsWow64Process2
|
|
|
|
// More info: https://www.rudyhuyn.com/blog/2017/12/13/how-to-detect-that-your-x86-application-runs-on-windows-on-arm/
|
|
|
|
// Right now (March 3, 2021) is not very important because support for x64
|
|
|
|
// apps on an arm64 Windows is experimental. See:
|
|
|
|
// https://blogs.windows.com/windows-insider/2020/12/10/introducing-x64-emulation-in-preview-for-windows-10-on-arm-pcs-to-the-windows-insider-program/
|
|
|
|
|
|
|
|
return 'x64'
|
|
|
|
}
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function getUpdatesURL() {
|
2021-04-23 09:10:24 +00:00
|
|
|
// It is also possible to use a `x64/` path, but for now we'll leave the
|
|
|
|
// original URL without architecture in it (which will still work for
|
|
|
|
// compatibility reasons) in case anything goes wrong until we have everything
|
|
|
|
// sorted out.
|
2021-04-26 16:44:09 +00:00
|
|
|
const architecturePath = getDistArchitecture() === 'arm64' ? 'arm64/' : ''
|
2021-04-23 09:10:24 +00:00
|
|
|
return `https://central.github.com/api/deployments/desktop/desktop/${architecturePath}latest?version=${version}&env=${getChannel()}`
|
2017-07-13 14:28:20 +00:00
|
|
|
}
|
|
|
|
|
2018-01-17 14:15:44 +00:00
|
|
|
export function shouldMakeDelta() {
|
2017-07-13 18:09:07 +00:00
|
|
|
// Only production and beta channels include deltas. Test releases aren't
|
|
|
|
// necessarily sequential so deltas wouldn't make sense.
|
|
|
|
const channelsWithDeltas = ['production', 'beta']
|
2019-11-04 18:41:06 +00:00
|
|
|
return channelsWithDeltas.indexOf(getChannel()) > -1
|
2017-07-13 18:09:07 +00:00
|
|
|
}
|
2019-11-20 17:44:01 +00:00
|
|
|
|
|
|
|
export function getIconFileName(): string {
|
|
|
|
const baseName = 'icon-logo'
|
|
|
|
return getChannel() === 'development' ? `${baseName}-yellow` : baseName
|
|
|
|
}
|