diff --git a/README.md b/README.md index 5d8f6970..0095f663 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ jobs: * **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`). * **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` ... #### Outputs diff --git a/entrypoint.sh b/entrypoint.sh index f5cc5fea..8a60bb43 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,6 +3,18 @@ # config default_semvar_bump=${DEFAULT_BUMP:-minor} with_v=${WITH_V:-false} +release_branches=${RELEASE_BRANCHES:-master} + +pre_release="true" +IFS=',' read -ra branch <<< "$release_branches" +for b in "${branch[@]}"; do + echo "Is $b a match for ${GITHUB_REF#'refs/heads/'}" + if [[ "${GITHUB_REF#'refs/heads/'}" =~ $b ]] + then + pre_release="false" + fi +done +echo "pre_release = $pre_release" # get latest tag tag=$(git describe --tags `git rev-list --tags --max-count=1`) @@ -40,11 +52,22 @@ then new="v$new" fi +if $pre_release +then + new="$new-${commit:0:7}" +fi + echo $new # set output echo ::set-output name=new_tag::$new +if $pre_release +then + echo "This branch is not a release branch. Skipping the tag creation." + exit 0 +fi + # push new tag ref to github dt=$(date '+%Y-%m-%dT%H:%M:%SZ') full_name=$GITHUB_REPOSITORY