Skip to content

Commit

Permalink
Fix wrong fetching semver latest tag (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
micnncim authored Sep 6, 2020
1 parent 51c1bae commit 4c70a61
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ git fetch --prune --unshallow
latest_tag=''

if [ "${INPUT_SEMVER_ONLY}" = 'false' ]; then
# Get a actual latest tag.
latest_tag=$(git describe --abbrev=0 --tags)
# Get a actual latest tag.
latest_tag=$(git describe --abbrev=0 --tags)
else
# Get a latest tag in the shape of semver.
for tag in $(git tag | sort -r); do
if echo "${tag}" | grep -Eq '^v?([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$'; then
latest_tag="${tag}"
break
fi
done
# Get a latest tag in the shape of semver.
for ref in $(git for-each-ref --sort=-creatordate --format '%(refname)' refs/tags); do
tag="${ref#refs/tags/}"
if echo "${tag}" | grep -Eq '^v?([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$'; then
latest_tag="${tag}"
break
fi
done
fi

if [ "${latest_tag}" = '' ] && [ "${INPUT_WITH_INITIAL_VERSION}" = 'true' ]; then
latest_tag="${INPUT_INITIAL_VERSION}"
latest_tag="${INPUT_INITIAL_VERSION}"
fi

echo "::set-output name=tag::${latest_tag}"

0 comments on commit 4c70a61

Please sign in to comment.