From 8c05441d9fe6fa01c388906ceb6a6afdc3fbee08 Mon Sep 17 00:00:00 2001 From: Santiago Bernhardt Date: Sun, 25 Dec 2022 20:01:00 +1300 Subject: [PATCH 1/2] Get the baster branch from env vars also allow to overwrite as parameter --- README.md | 1 + entrypoint.sh | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9fb029dd..36260c41 100755 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ _NOTE: set the fetch-depth for `actions/checkout@v2` or newer to be sure you ret - **GITHUB_TOKEN** **_(required)_** - Required for permission to tag the repo. - **DEFAULT_BUMP** _(optional)_ - Which type of bump to use when none explicitly provided (default: `minor`). +- **DEFAULT_BRANCH** _(optional)_ - Overwrite the default branch its read from Github Runner env var but can be overwritten (default: `$GITHUB_BASE_REF`). - **WITH_V** _(optional)_ - Tag version with `v` character. - **RELEASE_BRANCHES** _(optional)_ - Comma separated list of branches (bash reg exp accepted) that will generate the release tags. Other branches and pull-requests generate versions postfixed with the commit hash and do not generate any tag. Examples: `master` or `.*` or `release.*,hotfix.*,master` ... - **CUSTOM_TAG** _(optional)_ - Set a custom tag, useful when generating tag based on f.ex FROM image in a docker image. **Setting this tag will invalidate any other settings set!** diff --git a/entrypoint.sh b/entrypoint.sh index d5e00237..9e9a1560 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,6 +4,7 @@ set -o pipefail # config default_semvar_bump=${DEFAULT_BUMP:-minor} +default_branch=${DEFAULT_BRANCH:-$GITHUB_BASE_REF} # get the default branch from github runner env vars with_v=${WITH_V:-false} release_branches=${RELEASE_BRANCHES:-master,main} custom_tag=${CUSTOM_TAG:-} @@ -26,6 +27,7 @@ cd "${GITHUB_WORKSPACE}/${source}" || exit 1 echo "*** CONFIGURATION ***" echo -e "\tDEFAULT_BUMP: ${default_semvar_bump}" +echo -e "\tDEFAULT_BRANCH: ${default_branch}" echo -e "\tWITH_V: ${with_v}" echo -e "\tRELEASE_BRANCHES: ${release_branches}" echo -e "\tCUSTOM_TAG: ${custom_tag}" @@ -127,7 +129,7 @@ fi # get the merge commit message looking for #bumps declare -A history_type=( ["last"]="$(git show -s --format=%B)" \ - ["full"]="$(git log master..HEAD --format=%B)" \ + ["full"]="$(git log ${default_branch}..HEAD --format=%B)" \ ) log=${history_type[${branch_history}]} printf "History:\n---\n%s\n---\n" "$log" From f19dbe12fdf6484d1b42e3143084e2589f957d5d Mon Sep 17 00:00:00 2001 From: Santiago Bernhardt Date: Sun, 25 Dec 2022 20:02:37 +1300 Subject: [PATCH 2/2] Update entrypoint.sh Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 9e9a1560..10e17316 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -129,7 +129,7 @@ fi # get the merge commit message looking for #bumps declare -A history_type=( ["last"]="$(git show -s --format=%B)" \ - ["full"]="$(git log ${default_branch}..HEAD --format=%B)" \ + ["full"]="$(git log "${default_branch}"..HEAD --format=%B)" \ ) log=${history_type[${branch_history}]} printf "History:\n---\n%s\n---\n" "$log"