-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fac2696
commit 7066c45
Showing
4 changed files
with
30 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const semver = require('semver'); | ||
const { execSync } = require('child_process'); | ||
|
||
const branch = process.env.GITHUB_BRANCH || 'refs/heads/master'; | ||
const masterCommitsCount = execSync(`git rev-list --count ${branch}`) | ||
.toString() | ||
.trim(); | ||
|
||
function getVersion(version) { | ||
const currentVersion = semver.parse(version); | ||
if (Array.isArray(currentVersion.prerelease) && currentVersion.prerelease.length > 0) { | ||
return semver.coerce(version).version.replace(/.[0-9]$/, `.${masterCommitsCount}`); | ||
} | ||
return version; | ||
} | ||
|
||
module.exports = getVersion; |
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