Skip to content

lfreleng-actions/tag-validate-semantic-action

Repository files navigation

🏷️ Check Semantic Versioning String/Tag

Validates a given string for conformity to Semantic Versioning.

Refer to the site/documentation: Semantic Versioning

tag-validate-semantic-action

Usage Example

Pass the string to check as input to the action:

steps:
  - name: "Check string for: SemVer"
    if: startsWith(github.ref, 'refs/tags/')
    uses: lfreleng-actions/tag-validate-semantic-action@main
    with:
      string: ${{ github.ref_name }}

Inputs

Name Required Default Description
string True N/A Tag/version string to check for conformity
exit_on_fail False false Exits/aborts with error if check fails

Outputs

Name Description
valid Set true when tag/string conforms to Semantic Versioning
dev_version Set true when tag contains pre-release/development strings

Implementation Details

For further details: https://regex101.com/r/vkijKf/1/

The RegEx used for semantic compliance is:

pattern="^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"

The RegEx used for development compliance is:

pattern="(dev|pre|alpha|beta|rc|snapshot|nightly|canary|preview)"

For further details: https://regex101.com/r/d6KWNO/1

The second RegEx uses the grep flags "-Eqi" which makes the match case-insensitive and allows for partial matches.

About

Validates a given version/string for conformity to semantic versioning

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors