-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Use node to set npm version (will be reused with electron-packager)
- Loading branch information
Showing
4 changed files
with
57 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* eslint-disable no-console */ | ||
|
||
const errorHandler = error => { | ||
console.error(error); | ||
}; | ||
|
||
module.exports = errorHandler; |
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,31 @@ | ||
#!/usr/bin/env node | ||
/* eslint-disable no-console */ | ||
|
||
const childProcess = require('child_process'); | ||
const errorHandler = require('./error-handler'); | ||
const refPrefix = 'refs\\/tags\\/v'; | ||
|
||
const extractVersionFromTag = () => { | ||
const githubRef = process.env.GITHUB_REF; | ||
if (githubRef && githubRef.startsWith('refs\\/tags\\/v')) { | ||
return githubRef.replace(refPrefix, ''); | ||
} | ||
return null; | ||
}; | ||
|
||
const versionFromTag = () => { | ||
const version = extractVersionFromTag(); | ||
if (!version) { | ||
console.error('No version specified in $GITHUB_REF environment variable'); | ||
process.exit(1); | ||
} | ||
console.log(`Setting project version to ${version}`); | ||
childProcess.execSync(` npm version --no-git-tag-version ${version}`, { | ||
env: {...process.env}, | ||
stdio: 'inherit' | ||
}); | ||
process.exit(0); | ||
}; | ||
|
||
process.on('unhandledRejection', errorHandler); | ||
versionFromTag(); |