You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

41 lines
1.4 KiB

name: "Version Check"
description: "Checks to make sure the version matches the correct format"
inputs:
version:
description: "Version string to check"
required: true
validation_type:
description: 'Type of validation to perform: "semver" or "calver" (default)'
required: false
default: "calver"
runs:
using: "composite"
steps:
- name: Check version format
id: check-version-format
shell: bash
env:
VERSION: ${{ inputs.version }}
VALIDATION_TYPE: ${{ inputs.validation_type }}
run: |
validation_type_lower=$(echo "$VALIDATION_TYPE" | tr '[:upper:]' '[:lower:]')
if [[ $validation_type_lower == "calver" ]]; then
if [[ "$VERSION" =~ ^20[0-9]{2}\.(1[0-2]|[1-9])\.[0-9]+$ ]]; then
echo "CalVer version input validation successful."
exit 0
else
echo "CalVer version input validation failed."
exit 1
fi
elif [[ $validation_type_lower == "semver" ]]; then
if [[ "$VERSION" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9a-z.-]+)?(\+[0-9a-z.-]+)?$ ]]; then
echo "SemVer version input validation successful."
exit 0
else
echo "SemVer version input validation failed."
exit 1
fi
else
echo "Invalid validation type specified: '$VALIDATION_TYPE'. Use 'semver' or 'calver'."
exit 1
fi