-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tools): add a script to print a dev version
- Loading branch information
Showing
1 changed file
with
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Will print a version tag taking into account the current project version and whether it's a dev version | ||
# on main branch: 1.0.0-dev.1234abcd (commit tag) | ||
# on feature branch: 1.0.0-dev.branch-name | ||
# on git tag: 1.0.0 (git tag) | ||
|
||
npmVersion=$(node --print 'require("../package.json").version') | ||
gitTag=$(git describe --exact-match --tags 2>/dev/null | sed "s/^v//") # remove "v" in front of version if any | ||
gitBranch=$(git symbolic-ref --short HEAD) | ||
gitRef=$(git rev-parse --short HEAD) | ||
|
||
# git tag defined | ||
if [ -n "${gitTag}" ]; then | ||
echo ${gitTag} | ||
exit 0 | ||
fi | ||
|
||
# main branch | ||
if [ ${gitBranch} == "main" ]; then | ||
echo "${npmVersion}.${gitRef}" | ||
exit 0 | ||
fi | ||
|
||
echo "${npmVersion}.${gitBranch}" |