Skip to content

Commit

Permalink
change pep440 call from python to regex
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-dot committed Oct 31, 2024
1 parent 12b4ef0 commit 76ae77e
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions .github/workflows/_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
env:
GCR_IMAGE: ghcr.io/diamondlightsource/blueapi
HELM_VERSION: 3.10.3
PEP_440_REGEX: v?(?:(?:(?<epoch>[0-9]+)!)?(?<release>[0-9]+(?:\.[0-9]+)*)(?<pre>[-_\.]?(?<preLabel>(a|b|c|rc|alpha|beta|pre|preview))[-_\.]?(?<preNumber>[0-9]+)?)?(?<post>(?:-(?<postNumber0>[0-9]+))|(?:[-_\.]?(?<postLabel>post|rev|r)[-_\.]?(?<postNumber1>[0-9]+)?))?(?<dev>[-_\.]?(?<devLabel>dev)[-_\.]?(?<devNumber>[0-9]+)?)?)(?:\+(?<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))?
# https://regex101.com/library/M7QMAp

jobs:
build_container:
Expand All @@ -18,21 +20,14 @@ jobs:
fetch-depth: 0
- name: Validate PEP 440 version compliance
run: |
python -m pip install packaging
python -c "
import re
from packaging.version import Version, InvalidVersion

ref = '${GITHUB_REF##*/}'
try:
version = Version(ref)
print(f'PEP 440 compliant version: {version}')
except InvalidVersion:
print(f'Invalid PEP 440 version: {ref}')
exit(1)
"
ref="${{ github.ref_name }}"
my_regex=${{env.PEP_440_REGEX}}
if [[ "$ref" =~ $my_regex ]]; then
echo "PEP 440 compliant version: $ref"
else
echo "Invalid PEP 440 version: $ref"
exit 1
fi
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
Expand Down

0 comments on commit 76ae77e

Please sign in to comment.