Skip to content

Commit

Permalink
fix versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
iuccio committed Feb 25, 2024
1 parent 50f88c2 commit 8aa7777
Showing 1 changed file with 20 additions and 30 deletions.
50 changes: 20 additions & 30 deletions semantic-versioning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,33 @@ fi
}

npm_release(){
PATCH_MSG="[PATCH]";
MAJOR_MSG="[MAJOR]";
echo "Parsing git message...";
COMMIT_MSG=$(git log -1 --pretty=format:"%s");
echo "Last commit message: ${COMMIT_MSG}";
if [[ $COMMIT_MSG == *"$PATCH_MSG"* ]]; then
echo "Executing new PATCH release..."
npm version patch --force;
elif [[ $COMMIT_MSG == *"$MAJOR_MSG"* ]]; then
echo "Executing new MAJOR release..."
npm version major --force;
else
echo "Executing new MINOR release...";
npm version minor --force;
fi
echo "Publish new version..."
npm publish;
echo "New version successfully published."
}

push_git_info(){
COMMIT_MSG="new release [skip ci]"
PATCH_MSG="[PATCH]";
MAJOR_MSG="[MAJOR]";
echo "Parsing git message...";
COMMIT_MSG=$(git log -1 --pretty=format:"%s");
echo "Last commit message: ${COMMIT_MSG}";
if [[ $COMMIT_MSG == *"$PATCH_MSG"* ]]; then
echo "Executing new PATCH release..."
npm version patch --force -m "$COMMIT_MSG";
elif [[ $COMMIT_MSG == *"$MAJOR_MSG"* ]]; then
echo "Executing new MAJOR release..."
npm version major --force -m "$COMMIT_MSG";
else
echo "Executing new MINOR release...";
npm version minor --force -m "$COMMIT_MSG";
fi
echo "Publish new version..."
npm publish;
echo "Publish git info...";
TAG=$(git describe --tags --abbrev=0);
COMMIT_ID=$(git rev-parse HEAD);
git commit --amend -m "new release $TAG [skip ci]";
echo "new commit message: $(git log -1 --pretty=format:"%s")";
git tag -d $TAG # delete the old tag locally
git tag $TAG $COMMIT_ID;
git push;
git push origin refs/tags/$TAG;
git push --follow-tags
echo "New version successfully published."
}

execute-new-release(){
echo "Start Semantic Versioning release...";
validate_is_master_branch;
npm_release;
push_git_info;
echo "End Semantic Versioning release.";
}

Expand Down

0 comments on commit 8aa7777

Please sign in to comment.