~sumner/sublime-music

ref: faaa6503e8b11b67ab968b96b4ed8118306ab0ea sublime-music/cicd/tagged_with_version -rwxr-xr-x 591 bytes
faaa6503Sumner Evans ci: use sourcehut for PyPi deploy 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /usr/bin/env python

import re
import subprocess
import sys

version_tag_re = re.compile(r"v\d+\.\d+\.\d+")


tags = (
    subprocess.run(["git", "tag", "--contains", "HEAD"], capture_output=True)
    .stdout.decode()
    .strip()
    .split()
)

# If one of the tags is a version tag, then run the commands specified in the
# parameters.
for tag in tags:
    if match := version_tag_re.match(tag):
        print(f"VERSION TAG {tag} FOUND")
        sys.exit(0)

        # Don't run the else statement of the for loop.
        break
else:
    print("NO VERSION TAG FOUND")
    sys.exit(1)