forked from desktop/desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract platform-specific checks for building and packaging into new …
…build
- Loading branch information
Brendan Forster
committed
Sep 16, 2018
1 parent
dd831bc
commit 5431018
Showing
6 changed files
with
103 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
export function getSha() { | ||
if (isCircleCI() && process.env.CIRCLE_SHA1 != null) { | ||
return process.env.CIRCLE_SHA1 | ||
} | ||
|
||
if (isAppveyor() && process.env.APPVEYOR_REPO_COMMIT != null) { | ||
return process.env.APPVEYOR_REPO_COMMIT | ||
} | ||
|
||
if (isTravis() && process.env.TRAVIS_COMMIT != null) { | ||
return process.env.TRAVIS_COMMIT | ||
} | ||
|
||
const branchCommitId = process.env.BUILD_SOURCEVERSION | ||
// this check is for a CI build from a local branch | ||
if (isAzurePipelines() && branchCommitId != null) { | ||
return branchCommitId | ||
} | ||
|
||
const pullRequestCommitId = process.env.SYSTEM_PULLREQUEST_SOURCECOMMITID | ||
if (isAzurePipelines() && pullRequestCommitId != null) { | ||
return pullRequestCommitId | ||
} | ||
|
||
throw new Error( | ||
`Unable to get the SHA for the current platform. Check the documentation for the expected environment variables.` | ||
) | ||
} | ||
|
||
export function isRunningOnFork() { | ||
if (isCircleCI() && process.env.CIRCLE_PR_USERNAME == null) { | ||
return true | ||
} | ||
|
||
if ( | ||
isAppveyor() && | ||
process.env.APPVEYOR_PULL_REQUEST_NUMBER != null && | ||
process.env.APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME !== 'desktop/desktop' | ||
) { | ||
return true | ||
} | ||
|
||
if ( | ||
isTravis() && | ||
process.env.TRAVIS_PULL_REQUEST_SLUG != null && | ||
// empty string denotes a `push` build | ||
process.env.TRAVIS_PULL_REQUEST_SLUG !== '' && | ||
process.env.TRAVIS_PULL_REQUEST_SLUG !== 'desktop/desktop' | ||
) { | ||
return true | ||
} | ||
|
||
if ( | ||
isAzurePipelines() && | ||
process.env.SYSTEM_PULLREQUEST_ISFORK != null && | ||
process.env.SYSTEM_PULLREQUEST_ISFORK === 'True' | ||
) { | ||
return true | ||
} | ||
|
||
return false | ||
} | ||
|
||
export function isTravis() { | ||
return process.platform === 'linux' && process.env.TRAVIS === 'true' | ||
} | ||
|
||
export function isCircleCI() { | ||
return process.platform === 'darwin' && process.env.CIRCLECI === 'true' | ||
} | ||
|
||
export function isAppveyor() { | ||
return process.platform === 'win32' && process.env.APPVEYOR === 'True' | ||
} | ||
|
||
export function isAzurePipelines() { | ||
return ( | ||
process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI === | ||
'https://github.visualstudio.com/' | ||
) | ||
} | ||
|
||
export function getReleaseBranchName(): string { | ||
return ( | ||
process.env.CIRCLE_BRANCH || // macOS | ||
process.env.APPVEYOR_REPO_BRANCH || // Windows | ||
process.env.TRAVIS_BRANCH || // Travis CI | ||
process.env.BUILD_SOURCEBRANCHNAME || // Azure Pipelines | ||
'' | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters