Supporting semvers
This commit is contained in:
41
action.yml
41
action.yml
@@ -2,12 +2,49 @@ name: Retrieve version
|
|||||||
description: Uses the tags and git commit to find a unique version and sets it as NEW_VERSION
|
description: Uses the tags and git commit to find a unique version and sets it as NEW_VERSION
|
||||||
author: Skydust
|
author: Skydust
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
semver:
|
||||||
|
description: "The semver type to use if this is a release"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
- name: Get commit version
|
- name: Getting version
|
||||||
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
if [[ -n "${{ inputs.semver }}" ]]; then
|
||||||
|
SEMVER_UPDATE="${{ inputs.semver }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${SEMVER_UPDATE}" ]]; then
|
||||||
|
git fetch --tags --force
|
||||||
|
|
||||||
|
last_version="$(git describe --tags --abbrev=0 --match "v*" 2> /dev/null || echo "")"
|
||||||
|
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
|
||||||
|
IFS='.' read -r major minor patch <<< "${last_version%%-*}"
|
||||||
|
|
||||||
|
# Increment the appropriate part of the version
|
||||||
|
case "${SEMVER_UPDATE}" in
|
||||||
|
"Major"*) NEW_VERSION="$((major + 1)).0.0"
|
||||||
|
;;
|
||||||
|
"Minor"*) NEW_VERSION="$major.$((minor + 1)).0"
|
||||||
|
;;
|
||||||
|
"Patch"*) NEW_VERSION="$major.$minor.$((patch + 1))"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
log_info "Requested ${SEMVER_UPDATE} update"
|
||||||
|
|
||||||
|
NEW_VERSION="v${NEW_VERSION}"
|
||||||
|
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
||||||
NEW_VERSION="${GITHUB_REF##refs/tags/}"
|
NEW_VERSION="${GITHUB_REF##refs/tags/}"
|
||||||
log_info "This is a tag push: $(yellow)${NEW_VERSION}"
|
log_info "This is a tag push: $(yellow)${NEW_VERSION}"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user