Skip to content

Commit

Permalink
Add semver validation
Browse files Browse the repository at this point in the history
  • Loading branch information
sualeh committed Dec 22, 2024
1 parent 1de3a0e commit 1846eae
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/publish-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ on:
workflow_dispatch:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-[A-Z]
- 'v*'

permissions:
contents: read
Expand All @@ -22,6 +21,19 @@ jobs:
runs-on: ubuntu-latest
steps:

# VALIDATE TAGS
- id: validate-semver
name: Validate tag against semantic versioning
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
SEMVER_PATTERN="^refs/tags/v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$"
if [[ ! $GITHUB_REF =~ $SEMVER_PATTERN ]]
then
echo "Tag $GITHUB_REF does not follow semantic versioning"
exit 1
fi
# SETUP BUILD ENVIRONMENT
- id: prepare-maven-build
name: Prepare Maven build
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
tags:
- v[0-9]+\.[0-9]+\.[0-9]+(-[A-Z])?
- 'v*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -16,6 +16,19 @@ jobs:
runs-on: ubuntu-latest
steps:

# VALIDATE TAGS
- id: validate-semver
name: Validate tag against semantic versioning
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
SEMVER_PATTERN="^refs/tags/v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$"
if [[ ! $GITHUB_REF =~ $SEMVER_PATTERN ]]
then
echo "Tag $GITHUB_REF does not follow semantic versioning"
exit 1
fi
# SETUP BUILD ENVIRONMENT
- id: prepare-maven-build
name: Prepare Maven build
Expand Down

0 comments on commit 1846eae

Please sign in to comment.