From 3ae8b061acf660241132066752d6c2bf8ed93c84 Mon Sep 17 00:00:00 2001 From: Santiago Bernhardt Date: Fri, 6 Jan 2023 22:12:06 +1300 Subject: [PATCH 1/4] validate default_branch when history type full --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index c651f777..abedd361 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -126,7 +126,7 @@ then fi # sanitize that the default_branch is set (via env var when running on PRs) else find it natively -if [ -z "${default_branch}" ] +if [ -z "${default_branch}" ] && [ "$history_type" == "full" ] then echo "The DEFAULT_BRANCH should be autodetected when tag-action runs on on PRs else must be defined, See: https://github.com/anothrNick/github-tag-action/pull/230, since is not defined we find it natively" default_branch=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@') From 66569330b87d5c59b7adddca03397145b3ccc09c Mon Sep 17 00:00:00 2001 From: Santiago Bernhardt Date: Fri, 6 Jan 2023 22:25:18 +1300 Subject: [PATCH 2/4] This var is branch_history --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index abedd361..1411a49a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -126,7 +126,7 @@ then fi # sanitize that the default_branch is set (via env var when running on PRs) else find it natively -if [ -z "${default_branch}" ] && [ "$history_type" == "full" ] +if [ -z "${default_branch}" ] && [ "$branch_history" == "full" ] then echo "The DEFAULT_BRANCH should be autodetected when tag-action runs on on PRs else must be defined, See: https://github.com/anothrNick/github-tag-action/pull/230, since is not defined we find it natively" default_branch=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@') From b9431515dc6408beaa0a402586e562ed02ed4a0f Mon Sep 17 00:00:00 2001 From: Santiago Bernhardt Date: Fri, 6 Jan 2023 23:12:58 +1300 Subject: [PATCH 3/4] there is no head in the container hence we change the strategy for filtering --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 1411a49a..95b93b58 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -129,7 +129,7 @@ fi if [ -z "${default_branch}" ] && [ "$branch_history" == "full" ] then echo "The DEFAULT_BRANCH should be autodetected when tag-action runs on on PRs else must be defined, See: https://github.com/anothrNick/github-tag-action/pull/230, since is not defined we find it natively" - default_branch=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@') + default_branch=$(git branch -rl '*/master' '*/main' | cut -d / -f2) echo "default_branch=${default_branch}" # re check this if [ -z "${default_branch}" ] From a74b3bac7707b40120024c3e6b13afced668b5eb Mon Sep 17 00:00:00 2001 From: Santiago Bernhardt Date: Fri, 6 Jan 2023 23:17:12 +1300 Subject: [PATCH 4/4] Add readme warning when combining history full without specifying the default branch an is not main or master --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d264b7ab..60df6021 100755 --- a/README.md +++ b/README.md @@ -75,7 +75,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`). +- **DEFAULT_BRANCH** _(optional)_ - Overwrite the default branch its read from Github Runner env var but can be overwritten (default: `$GITHUB_BASE_REF`). Strongly recommended to set this var if using anything else than master or main as default branch otherwise in combination with history full will error. - **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!**