Skip to content
This repository was archived by the owner on Mar 6, 2023. It is now read-only.

Commit bc2d46f

Browse files
authored
Merge pull request #347 from cloudalchemy/superq/bump_script
Fix CircleCI version bumping
2 parents 4ab97d2 + c2422c4 commit bc2d46f

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

.circleci/config.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,11 @@ jobs:
5353
- run: pip install git-semver
5454
- run: git config --global user.email "${GIT_MAIL}"
5555
- run: git config --global user.name "${GIT_USER}"
56+
- run: ./bump_version >> $BASH_ENV
5657
- run: |
57-
GIT_TAG=none
58-
echo "Last commit message: ${GIT_COMMIT_DESC}"
59-
case "${GIT_COMMIT_DESC}" in
60-
*"[patch]"*|*"[fix]"*|*"[bugfix]"* ) GIT_TAG=$(git semver --next-patch) ;;
61-
*"[minor]"*|*"[feat]"*|*"[feature]"* ) GIT_TAG=$(git semver --next-minor) ;;
62-
*"[major]"*|*"[breaking change]"* ) GIT_TAG=$(git semver --next-major) ;;
63-
*) echo "Keyword not detected. Doing nothing" && circleci-agent step halt ;;
64-
esac
65-
echo "GIT_TAG=${GIT_TAG}" >> $BASH_ENV
58+
if [[ "${NEW_TAG}" == 'none' ]]; then
59+
echo "Keyword not detected. Doing nothing" && circleci-agent step halt
60+
fi
6661
- run: |
6762
docker run -it --rm \
6863
-v "${CIRCLE_WORKING_DIRECTORY}:/role" \
@@ -73,7 +68,7 @@ jobs:
7368
--token "${GH_TOKEN}" \
7469
--release-url "https://galaxy.ansible.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME#ansible-}" \
7570
--unreleased-label "**Next release**" --no-compare-link \
76-
--future-release "${GIT_TAG}"
71+
--future-release "${NEW_TAG}"
7772
- run: git add CHANGELOG.md
7873
- run: git commit -m "[ci skip] Automatic changelog update"
7974
- run: git push "https://${GH_TOKEN}:@${GIT_URL}" || circleci-agent step halt

bump_version.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Description: Generate the next release version
4+
5+
set -uo pipefail
6+
7+
latest_tag="$(git semver)"
8+
if [[ -z "${latest_tag}" ]]; then
9+
echo "ERROR: Couldn't get latest tag from git semver, try 'pip install git-semver'" 2>&1
10+
exit 1
11+
fi
12+
13+
# Use HEAD if CIRCLE_SHA1 is not set.
14+
now="${CIRCLE_SHA1:-HEAD}"
15+
16+
new_tag='none'
17+
git_log="$(git log --format=%B "${latest_tag}..${now}")"
18+
19+
case "${git_log}" in
20+
*"[major]"*|*"[breaking change]"* ) new_tag=$(git semver --next-major) ;;
21+
*"[minor]"*|*"[feat]"*|*"[feature]"* ) new_tag=$(git semver --next-minor) ;;
22+
*"[patch]"*|*"[fix]"*|*"[bugfix]"* ) new_tag=$(git semver --next-patch) ;;
23+
esac
24+
25+
echo "NEW_TAG=${new_tag}"

0 commit comments

Comments
 (0)