Skip to content

Commit

Permalink
Select last commit or full branch history for analysis of #bumps (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbe-arg committed Dec 20, 2022
1 parent 11ca940 commit 2fa4983
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -49,7 +49,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
ref: ${{ github.sha }}
fetch-depth: '0'

- name: Bump version and push tag
Expand Down Expand Up @@ -83,6 +83,7 @@ _NOTE: set the fetch-depth for `actions/checkout@v2` or newer to be sure you ret
- **MINOR_STRING_TOKEN** _(optional)_ - Change the default `#minor` commit message string tag.
- **PATCH_STRING_TOKEN** _(optional)_ - Change the default `#patch` commit message string tag.
- **NONE_STRING_TOKEN** _(optional)_ - Change the default `#none` commit message string tag.
- **BRANCH_HISTORY** _(optional)_ - Set the history of the branch for finding `#bumps`. Possible values `last` and `full` defaults to full history of the new branch.

#### Outputs

Expand Down
10 changes: 8 additions & 2 deletions entrypoint.sh
Expand Up @@ -18,6 +18,7 @@ major_string_token=${MAJOR_STRING_TOKEN:-#major}
minor_string_token=${MINOR_STRING_TOKEN:-#minor}
patch_string_token=${PATCH_STRING_TOKEN:-#patch}
none_string_token=${NONE_STRING_TOKEN:-#none}
branch_history=${BRANCH_HISTORY:-full}
# since https://github.blog/2022-04-12-git-security-vulnerability-announced/ runner uses?
git config --global --add safe.directory /github/workspace

Expand All @@ -39,6 +40,7 @@ echo -e "\tMAJOR_STRING_TOKEN: ${major_string_token}"
echo -e "\tMINOR_STRING_TOKEN: ${minor_string_token}"
echo -e "\tPATCH_STRING_TOKEN: ${patch_string_token}"
echo -e "\tNONE_STRING_TOKEN: ${none_string_token}"
echo -e "\tBRANCH_HISTORY: ${branch_history}"

# verbose, show everything
if $verbose
Expand Down Expand Up @@ -123,8 +125,12 @@ then
fi

# get the merge commit message looking for #bumps
log=$(git show -s --format=%B)
echo "Last commit message: $log"
declare -A history_type=(
["last"]="$(git show -s --format=%B)" \
["full"]="$(git log master..HEAD --format=%B)" \
)
log=${history_type[${branch_history}]}
printf "History:\n---\n%s\n---\n" "$log"

case "$log" in
*$major_string_token* ) new=$(semver -i major "$tag"); part="major";;
Expand Down

0 comments on commit 2fa4983

Please sign in to comment.