feat: Use semantic-release and automatic git hooks check

This commit is contained in:
Guilhem Lavaux 2024-05-20 17:35:25 +02:00
parent 659081ac86
commit 661b17eea1
3 changed files with 1938 additions and 0 deletions

29
git_automation/check_commit_msg Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Missing argument (commit message). Did you try to run this manually?"
exit 1
fi
commitTitle="$(cat $1 | head -n1)"
# ignore merge requests
if echo "$commitTitle" | grep -qE "Merge branch"; then
echo "Commit hook: ignoring branch merge"
exit 0
fi
# check semantic versioning scheme
if ! echo "$commitTitle" | grep -qE '^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\([a-z0-9\s\-\_\,]+\))?!?:\s\w'; then
echo "Your commit message did not follow semantic versioning: $commitTitle"
echo ""
echo "Format: <type>(<optional-scope>): <subject>"
echo "Example: feat(api): add endpoint"
echo ""
echo "Valid types: build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test"
echo ""
echo "Please see"
echo "- https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commit-message-format"
echo "- https://www.conventionalcommits.org/en/v1.0.0/#summary"
exit 1
fi

1839
poetry.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,11 @@ scipy = "^1.13.0"
matplotlib = "^3.9.0"
tensorboard = "^2.16.2"
[tool.poetry.group.dev.dependencies]
python-semantic-release = "^9.7.3"
poetry-githooks = "^3.0.1"
black = "^24.4.2"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
@ -61,3 +66,68 @@ map2map = "map2map:main"
Repository = "https://git.aquila-consortium.org/aquila-consortium/map2map.git"
Issues = "https://git.aquila-consortium.org/aquila-consortium/map2map/issues/new"
#Changelog = "https://github.com/me/spam/blob/master/CHANGELOG.md"
[tool.githooks]
pre-commit="black ."
commit-msg="git_automation/check_commit_msg"
[tool.semantic_release]
assets = []
version_toml = [
"pyproject.toml:tool.poetry.version",
]
version_variables = [
"auto_seminar/__init__.py:__version__"
]
build_command_env = []
commit_message = "{version}\n\nAutomatically generated by python-semantic-release"
commit_parser = "angular"
logging_use_named_masks = false
major_on_zero = true
allow_zero_version = true
tag_format = "v{version}"
[tool.semantic_release.branches.main]
match = "(main|master)"
prerelease_token = "rc"
prerelease = false
[tool.semantic_release.changelog]
template_dir = "templates"
changelog_file = "CHANGELOG.md"
exclude_commit_patterns = []
[tool.semantic_release.changelog.environment]
block_start_string = "{%"
block_end_string = "%}"
variable_start_string = "{{"
variable_end_string = "}}"
comment_start_string = "{#"
comment_end_string = "#}"
trim_blocks = false
lstrip_blocks = false
newline_sequence = "\n"
keep_trailing_newline = false
extensions = []
autoescape = true
[tool.semantic_release.commit_author]
env = "GIT_COMMIT_AUTHOR"
default = "semantic-release <semantic-release>"
[tool.semantic_release.commit_parser_options]
allowed_tags = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "style", "refactor", "test"]
minor_tags = ["feat"]
patch_tags = ["fix", "perf"]
default_bump_level = 0
[tool.semantic_release.remote]
name = "origin"
type = "github"
ignore_token_for_push = false
insecure = false
[tool.semantic_release.publish]
dist_glob_patterns = ["dist/*"]
upload_to_vcs_release = true