Skip to content

Commit

Permalink
add CD releasing [PATCH]
Browse files Browse the repository at this point in the history
  • Loading branch information
iuccio committed Feb 24, 2024
1 parent 853a318 commit ef0a069
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/nodejs.yml → .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ jobs:
npm install
npm ci
npm test
- name: release
run: |
npm run release
env:
CI: true
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"test-debug": "node --inspect-brk node_modules/.bin/jest --runInBand --detectOpenHandles",
"version-patch": "npm version patch --force && npm publish && git push --follow-tags",
"version-minor": "npm version minor --force && npm publish && git push --follow-tags",
"version-major": "npm version major --force && npm publish && git push --follow-tags"
"version-major": "npm version major --force && npm publish && git push --follow-tags",
"release": "./semantic-versioning.sh"
},
"repository": {
"type": "git",
Expand Down
23 changes: 23 additions & 0 deletions semantic-versioning.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
echo "Start Semantic Versioning release...";
echo "Checking branch...";
RELEASE_BRANCH="master";
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD);
if [ $RELEASE_BRANCH != $CURRENT_BRANCH ]; then
echo "A new release version is only bumped on branch: $RELEASE_BRANCH.";
echo "Exiting...";
exit 0;
fi
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..."
elif [[ $COMMIT_MSG == *"$MAJOR_MSG"* ]]; then
echo "Executing new MAJOR release..."
else
echo "Executing new MINOR release...";
fi
echo "End Semantic Versioning release.";

0 comments on commit ef0a069

Please sign in to comment.