Skip to content

Commit

Permalink
Merge pull request #21 from fabricepipart/feature/prerelease-mode3
Browse files Browse the repository at this point in the history
Pre-release mode
  • Loading branch information
anothrNick committed Oct 27, 2019
2 parents f9e1720 + 9986d61 commit d7dc092
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -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

Expand Down
23 changes: 23 additions & 0 deletions entrypoint.sh
Expand Up @@ -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`)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d7dc092

Please sign in to comment.