import re
import sys
TYPES = "feat|fix|perf|refactor|docs|revert|ci|test|build|chore|style|release"
PATTERN = re.compile(rf"^({TYPES})(\([a-z0-9._/-]+\))?!?: \S.*$")
title = sys.argv[1] if len(sys.argv) > 1 else ""
if PATTERN.match(title):
print(f"pr-title: ok: {title}")
sys.exit(0)
print(f"::error::PR title is not a conventional commit subject: {title!r}. "
f"Use <type>(<scope>)?: <description>, type one of {TYPES.replace('|', ', ')}.")
sys.exit(1)