chore: initialize qiming workspace repository
This commit is contained in:
43
qimingclaw/.github/scripts/commits.py
vendored
Normal file
43
qimingclaw/.github/scripts/commits.py
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import argparse
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
CONVENTIONAL_COMMIT_PATTERN = r"^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)"
|
||||
|
||||
|
||||
def check_pr_title(title: str, pattern: str) -> bool:
|
||||
if re.match(pattern, title):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Check if a PR title matches a regex pattern."
|
||||
)
|
||||
parser.add_argument("pr_title", type=str, help="Pull request title")
|
||||
parser.add_argument(
|
||||
"--pattern",
|
||||
type=str,
|
||||
default=CONVENTIONAL_COMMIT_PATTERN,
|
||||
help="Regex pattern to match PR title",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
pr_title = args.pr_title
|
||||
regex_pattern = args.pattern
|
||||
|
||||
is_matched = check_pr_title(pr_title, regex_pattern)
|
||||
if not is_matched:
|
||||
print(
|
||||
f"PR '{pr_title}' title does not match the required pattern: {regex_pattern}"
|
||||
)
|
||||
sys.exit(1)
|
||||
else:
|
||||
print(f"PR '{pr_title}' title matches the required pattern: {regex_pattern}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
33
qimingclaw/.github/scripts/package.sh
vendored
Normal file
33
qimingclaw/.github/scripts/package.sh
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
|
||||
# When run in a container, the ownership will be messed up, so mark the
|
||||
# checkout dir as safe regardless of our env
|
||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
|
||||
# Normally we'll only do this on tags, but add --always to fallback to the revision
|
||||
# if we're iterating or the like
|
||||
tag=$(git describe --tags --abbrev=0 --always)
|
||||
release_name="$NAME-$tag-$TARGET"
|
||||
release_tar="${release_name}.tar.gz"
|
||||
mkdir "$release_name"
|
||||
|
||||
if [[ "$TARGET" =~ windows ]]; then
|
||||
bin="$NAME.exe"
|
||||
else
|
||||
bin="$NAME"
|
||||
fi
|
||||
|
||||
cp "target/$TARGET/release/$bin" "$release_name/"
|
||||
cp README.md LICENSE "$release_name/"
|
||||
tar czf "$release_tar" "$release_name"
|
||||
|
||||
rm -r "$release_name"
|
||||
|
||||
# Windows environments in github actions don't have the gnu coreutils installed,
|
||||
# which includes the shasum exe, so we just use powershell instead
|
||||
if [[ "$TARGET" =~ windows ]]; then
|
||||
echo "(Get-FileHash \"${release_tar}\" -Algorithm SHA256).Hash | Out-File -Encoding ASCII -NoNewline \"${release_tar}.sha256\"" | pwsh -c -
|
||||
else
|
||||
echo -n "$(shasum -ba 256 "${release_tar}" | cut -d " " -f 1)" > "${release_tar}.sha256"
|
||||
fi
|
||||
Reference in New Issue
Block a user