From ab316b121e69ddc05272dc710e63a8bb227f0f9d Mon Sep 17 00:00:00 2001 From: Santiago Bernhardt Date: Mon, 5 Dec 2022 09:47:15 +1300 Subject: [PATCH 1/3] POC log --- entrypoint.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index b9f7f075..f2bb7700 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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} +history=${HISTORY:-full} # since https://github.blog/2022-04-12-git-security-vulnerability-announced/ runner uses? git config --global --add safe.directory /github/workspace @@ -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 "\tHISTORY: ${history}" # verbose, show everything if $verbose @@ -123,8 +125,13 @@ then fi # get the merge commit message looking for #bumps -log=$(git show -s --format=%B) -echo "Last commit message: $log" +if [ "$history" == 'last' ] +then + log=$(git show -s --format=%B) +else + log=$(git show -s --format=%B) +fi +echo "History: $log" case "$log" in *$major_string_token* ) new=$(semver -i major "$tag"); part="major";; From db08b1c18dd3362a77b28043815da2d4fa421223 Mon Sep 17 00:00:00 2001 From: Santiago Bernhardt Date: Mon, 5 Dec 2022 10:07:35 +1300 Subject: [PATCH 2/3] history type --- entrypoint.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index f2bb7700..6346b874 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -125,13 +125,12 @@ then fi # get the merge commit message looking for #bumps -if [ "$history" == 'last' ] -then - log=$(git show -s --format=%B) -else - log=$(git show -s --format=%B) -fi -echo "History: $log" +declare -A history_type=( + ["last"]="$(git show -s --format=%B)" \ + ["full"]="$(git log master..HEAD --format=%B)" \ +) +log=${history_type[${history}]} +printf "History: \n%log" "$log" case "$log" in *$major_string_token* ) new=$(semver -i major "$tag"); part="major";; From 6aa4c1f118c6f849ee94e7414fdd729fc537fab2 Mon Sep 17 00:00:00 2001 From: Santiago Bernhardt Date: Mon, 5 Dec 2022 10:12:06 +1300 Subject: [PATCH 3/3] Branch history full|last --- README.md | 3 ++- entrypoint.sh | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 80188c9d..9fb029dd 100755 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/entrypoint.sh b/entrypoint.sh index 6346b874..d5e00237 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,7 +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} -history=${HISTORY:-full} +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 @@ -40,7 +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 "\tHISTORY: ${history}" +echo -e "\tBRANCH_HISTORY: ${branch_history}" # verbose, show everything if $verbose @@ -129,8 +129,8 @@ declare -A history_type=( ["last"]="$(git show -s --format=%B)" \ ["full"]="$(git log master..HEAD --format=%B)" \ ) -log=${history_type[${history}]} -printf "History: \n%log" "$log" +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";;