Fixing get version same commit
This commit is contained in:
41
action.yml
41
action.yml
@@ -20,28 +20,33 @@ runs:
|
|||||||
|
|
||||||
if [[ -n "${SEMVER_UPDATE}" ]]; then
|
if [[ -n "${SEMVER_UPDATE}" ]]; then
|
||||||
git fetch --tags --force
|
git fetch --tags --force
|
||||||
|
|
||||||
last_version="$(git describe --tags --abbrev=0 --match "v*" 2> /dev/null || echo "")"
|
last_version="$(git describe --tags --abbrev=0 --match "v*" 2> /dev/null || echo "")"
|
||||||
if [[ -z "$last_version" ]]; then
|
|
||||||
last_version="v0.0.0"
|
if git tag --points-at HEAD | grep -q "^${last_version}"; then
|
||||||
fi
|
log_info "A tag already exists on the current commit, using it"
|
||||||
last_version="${last_version:1}"
|
NEW_VERSION="${last_version:1}"
|
||||||
log_info "Last version: ${last_version}"
|
else
|
||||||
|
if [[ -z "$last_version" ]]; then
|
||||||
|
last_version="v0.0.0"
|
||||||
|
fi
|
||||||
|
last_version="${last_version:1}"
|
||||||
|
log_info "Last version: ${last_version}"
|
||||||
|
|
||||||
# Split the version into components
|
# Split the version into components
|
||||||
IFS='.' read -r major minor patch <<< "${last_version%%-*}"
|
IFS='.' read -r major minor patch <<< "${last_version%%-*}"
|
||||||
|
|
||||||
# Increment the appropriate part of the version
|
# Increment the appropriate part of the version
|
||||||
case "${SEMVER_UPDATE}" in
|
case "${SEMVER_UPDATE}" in
|
||||||
"Major"*) NEW_VERSION="$((major + 1)).0.0"
|
"Major"*) NEW_VERSION="$((major + 1)).0.0"
|
||||||
;;
|
;;
|
||||||
"Minor"*) NEW_VERSION="$major.$((minor + 1)).0"
|
"Minor"*) NEW_VERSION="$major.$((minor + 1)).0"
|
||||||
;;
|
;;
|
||||||
"Patch"*) NEW_VERSION="$major.$minor.$((patch + 1))"
|
"Patch"*) NEW_VERSION="$major.$minor.$((patch + 1))"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
log_info "Requested ${SEMVER_UPDATE} update"
|
log_info "Requested ${SEMVER_UPDATE} update"
|
||||||
|
fi;
|
||||||
|
|
||||||
NEW_VERSION="v${NEW_VERSION}"
|
NEW_VERSION="v${NEW_VERSION}"
|
||||||
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user