commit-and-tag-version 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- commit_and_tag_version-0.0.1/.claude/settings.local.json +19 -0
- commit_and_tag_version-0.0.1/.github/workflows/ci.yml +40 -0
- commit_and_tag_version-0.0.1/.github/workflows/publish.yml +22 -0
- commit_and_tag_version-0.0.1/.gitignore +18 -0
- commit_and_tag_version-0.0.1/LICENSE +21 -0
- commit_and_tag_version-0.0.1/Makefile +37 -0
- commit_and_tag_version-0.0.1/PKG-INFO +349 -0
- commit_and_tag_version-0.0.1/README.md +332 -0
- commit_and_tag_version-0.0.1/pyproject.toml +45 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/__init__.py +68 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/checkpoint.py +18 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/cli.py +76 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/commit_parser.py +77 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/config.py +109 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/defaults.py +68 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/format_commit_message.py +2 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/git.py +115 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/lifecycles/__init__.py +0 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/lifecycles/bump.py +179 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/lifecycles/changelog.py +149 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/lifecycles/commit.py +43 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/lifecycles/tag.py +36 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/models.py +71 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/run_lifecycle_script.py +30 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/updaters/__init__.py +80 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/updaters/base.py +8 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/updaters/csproj.py +19 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/updaters/gradle.py +19 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/updaters/json_updater.py +44 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/updaters/maven.py +36 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/updaters/openapi.py +19 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/updaters/plain_text.py +9 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/updaters/python_updater.py +25 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/updaters/yaml_updater.py +19 -0
- commit_and_tag_version-0.0.1/src/commit_and_tag_version/write_file.py +7 -0
- commit_and_tag_version-0.0.1/tests/__init__.py +0 -0
- commit_and_tag_version-0.0.1/tests/conftest.py +50 -0
- commit_and_tag_version-0.0.1/tests/fixtures/Project-6.3.1.csproj +12 -0
- commit_and_tag_version-0.0.1/tests/fixtures/build-6.3.1.gradle.kts +11 -0
- commit_and_tag_version-0.0.1/tests/fixtures/openapi-1.2.3.yaml +5 -0
- commit_and_tag_version-0.0.1/tests/fixtures/package-1.0.0.json +5 -0
- commit_and_tag_version-0.0.1/tests/fixtures/pom-6.3.1.xml +25 -0
- commit_and_tag_version-0.0.1/tests/fixtures/pubspec-6.3.1.yaml +3 -0
- commit_and_tag_version-0.0.1/tests/fixtures/pyproject-1.0.0.toml +12 -0
- commit_and_tag_version-0.0.1/tests/integration/__init__.py +0 -0
- commit_and_tag_version-0.0.1/tests/integration/test_git_integration.py +135 -0
- commit_and_tag_version-0.0.1/tests/test_bump.py +158 -0
- commit_and_tag_version-0.0.1/tests/test_changelog.py +149 -0
- commit_and_tag_version-0.0.1/tests/test_checkpoint.py +20 -0
- commit_and_tag_version-0.0.1/tests/test_cli.py +88 -0
- commit_and_tag_version-0.0.1/tests/test_commit.py +150 -0
- commit_and_tag_version-0.0.1/tests/test_commit_parser.py +96 -0
- commit_and_tag_version-0.0.1/tests/test_config.py +78 -0
- commit_and_tag_version-0.0.1/tests/test_defaults.py +46 -0
- commit_and_tag_version-0.0.1/tests/test_format_commit_message.py +16 -0
- commit_and_tag_version-0.0.1/tests/test_git.py +148 -0
- commit_and_tag_version-0.0.1/tests/test_main.py +77 -0
- commit_and_tag_version-0.0.1/tests/test_models.py +65 -0
- commit_and_tag_version-0.0.1/tests/test_pyproject_license.py +7 -0
- commit_and_tag_version-0.0.1/tests/test_run_lifecycle_script.py +51 -0
- commit_and_tag_version-0.0.1/tests/test_tag.py +79 -0
- commit_and_tag_version-0.0.1/tests/test_updaters/__init__.py +0 -0
- commit_and_tag_version-0.0.1/tests/test_updaters/test_csproj.py +26 -0
- commit_and_tag_version-0.0.1/tests/test_updaters/test_gradle.py +26 -0
- commit_and_tag_version-0.0.1/tests/test_updaters/test_json.py +53 -0
- commit_and_tag_version-0.0.1/tests/test_updaters/test_maven.py +26 -0
- commit_and_tag_version-0.0.1/tests/test_updaters/test_openapi.py +25 -0
- commit_and_tag_version-0.0.1/tests/test_updaters/test_plain_text.py +16 -0
- commit_and_tag_version-0.0.1/tests/test_updaters/test_python_updater.py +25 -0
- commit_and_tag_version-0.0.1/tests/test_updaters/test_resolver.py +65 -0
- commit_and_tag_version-0.0.1/tests/test_updaters/test_yaml.py +25 -0
- commit_and_tag_version-0.0.1/tests/test_write_file.py +13 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"WebSearch",
|
|
5
|
+
"WebFetch(domain:python-semantic-release.readthedocs.io)",
|
|
6
|
+
"WebFetch(domain:pawamoy.github.io)",
|
|
7
|
+
"WebFetch(domain:github.com)",
|
|
8
|
+
"WebFetch(domain:pypi.org)",
|
|
9
|
+
"Bash(python3:*)",
|
|
10
|
+
"Bash(tail:*)",
|
|
11
|
+
"Bash(pytest:*)",
|
|
12
|
+
"Bash(python:*)",
|
|
13
|
+
"Bash(git add tests/fixtures/pom-6.3.1.xml && git status tests/fixtures/ 2>&1)"
|
|
14
|
+
],
|
|
15
|
+
"additionalDirectories": [
|
|
16
|
+
"/Users/jthines.s/sc-repository/commit-and-tag-version"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
strategy:
|
|
11
|
+
matrix:
|
|
12
|
+
os: [ubuntu-latest, windows-latest]
|
|
13
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
14
|
+
runs-on: ${{ matrix.os }}
|
|
15
|
+
timeout-minutes: 10
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0
|
|
20
|
+
- uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
- run: |
|
|
24
|
+
git config --global user.email "test@test.com"
|
|
25
|
+
git config --global user.name "Test"
|
|
26
|
+
- run: pip install -e ".[dev]"
|
|
27
|
+
- run: pytest --cov --cov-report=xml -v
|
|
28
|
+
- uses: codecov/codecov-action@v4
|
|
29
|
+
if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest'
|
|
30
|
+
|
|
31
|
+
lint:
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v4
|
|
35
|
+
- uses: actions/setup-python@v5
|
|
36
|
+
with:
|
|
37
|
+
python-version: "3.12"
|
|
38
|
+
- run: pip install -e ".[dev]"
|
|
39
|
+
- run: ruff check .
|
|
40
|
+
- run: ruff format --check .
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
- run: pip install build
|
|
19
|
+
- run: python -m build
|
|
20
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
21
|
+
with:
|
|
22
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 thines jai shankar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.PHONY: install install-dev test test-unit test-integration lint format check clean build release
|
|
2
|
+
|
|
3
|
+
install:
|
|
4
|
+
pip install -e .
|
|
5
|
+
|
|
6
|
+
install-dev:
|
|
7
|
+
pip install -e ".[dev]"
|
|
8
|
+
|
|
9
|
+
test:
|
|
10
|
+
pytest -v
|
|
11
|
+
|
|
12
|
+
test-unit:
|
|
13
|
+
pytest -v -m "not integration"
|
|
14
|
+
|
|
15
|
+
test-integration:
|
|
16
|
+
pytest -v -m integration
|
|
17
|
+
|
|
18
|
+
lint:
|
|
19
|
+
ruff check .
|
|
20
|
+
ruff format --check .
|
|
21
|
+
|
|
22
|
+
format:
|
|
23
|
+
ruff check --fix .
|
|
24
|
+
ruff format .
|
|
25
|
+
|
|
26
|
+
check: lint test
|
|
27
|
+
|
|
28
|
+
clean:
|
|
29
|
+
rm -rf build/ dist/ *.egg-info src/*.egg-info
|
|
30
|
+
find . -type d -name __pycache__ -exec rm -rf {} +
|
|
31
|
+
find . -type f -name "*.pyc" -delete
|
|
32
|
+
|
|
33
|
+
build: clean
|
|
34
|
+
python3 -m build
|
|
35
|
+
|
|
36
|
+
release: build
|
|
37
|
+
twine upload dist/*
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: commit-and-tag-version
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A utility for versioning using semver and CHANGELOG generation powered by Conventional Commits
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: click>=8.0
|
|
9
|
+
Requires-Dist: pyyaml>=6.0
|
|
10
|
+
Requires-Dist: semver>=3.0
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: mypy>=1.0; extra == 'dev'
|
|
13
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
14
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
15
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# commit-and-tag-version (Python)
|
|
19
|
+
|
|
20
|
+
A Python port of [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) — a utility for versioning using [semver](https://semver.org/) and CHANGELOG generation powered by [Conventional Commits](https://conventionalcommits.org).
|
|
21
|
+
|
|
22
|
+
[](https://github.com/thinesjs/python-commit-and-tag-version/actions)
|
|
23
|
+
[](https://pypi.org/project/commit-and-tag-version/)
|
|
24
|
+
[](https://pypi.org/project/commit-and-tag-version/)
|
|
25
|
+
[](https://conventionalcommits.org)
|
|
26
|
+
|
|
27
|
+
## How It Works
|
|
28
|
+
|
|
29
|
+
1. Follow the [Conventional Commits Specification](https://conventionalcommits.org) in your repository.
|
|
30
|
+
2. When you're ready to release, run `commit-and-tag-version`.
|
|
31
|
+
|
|
32
|
+
The tool will then:
|
|
33
|
+
|
|
34
|
+
1. Retrieve the current version from `packageFiles`, falling back to the last git tag.
|
|
35
|
+
2. **Bump** the version in `bumpFiles` based on your commits.
|
|
36
|
+
3. Generate a **changelog** based on your commits.
|
|
37
|
+
4. Create a new **commit** including your `bumpFiles` and updated CHANGELOG.
|
|
38
|
+
5. Create a new **tag** with the new version number.
|
|
39
|
+
|
|
40
|
+
### Version Bumps
|
|
41
|
+
|
|
42
|
+
| Commit Type | Version Bump |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `fix:` | Patch (1.0.0 -> 1.0.1) |
|
|
45
|
+
| `feat:` | Minor (1.0.0 -> 1.1.0) |
|
|
46
|
+
| `feat!:` or `BREAKING CHANGE` | Major (1.0.0 -> 2.0.0) |
|
|
47
|
+
|
|
48
|
+
Breaking changes before v1.0.0 bump minor instead of major.
|
|
49
|
+
|
|
50
|
+
## Installing
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
pip install commit-and-tag-version
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or with a package manager:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
# pipx (recommended for CLI tools)
|
|
60
|
+
pipx install commit-and-tag-version
|
|
61
|
+
|
|
62
|
+
# poetry
|
|
63
|
+
poetry add --group dev commit-and-tag-version
|
|
64
|
+
|
|
65
|
+
# uv
|
|
66
|
+
uv pip install commit-and-tag-version
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## CLI Usage
|
|
70
|
+
|
|
71
|
+
### First Release
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
commit-and-tag-version --first-release
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This will tag a release without bumping the version.
|
|
78
|
+
|
|
79
|
+
### Cutting Releases
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
commit-and-tag-version
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
As long as your git commit messages are conventional and accurate, the version bump is automatic and you get CHANGELOG generation for free.
|
|
86
|
+
|
|
87
|
+
After you cut a release, push the new git tag:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
git push --follow-tags origin main
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Release as a Pre-Release
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
# unnamed prerelease: 1.0.1-0
|
|
97
|
+
commit-and-tag-version --prerelease
|
|
98
|
+
|
|
99
|
+
# named prerelease: 1.0.1-alpha.0
|
|
100
|
+
commit-and-tag-version --prerelease alpha
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Prerelease tag collisions are automatically avoided by incrementing the numeric suffix.
|
|
104
|
+
|
|
105
|
+
### Release as a Target Type
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
# force a minor release
|
|
109
|
+
commit-and-tag-version --release-as minor
|
|
110
|
+
|
|
111
|
+
# force a specific version
|
|
112
|
+
commit-and-tag-version --release-as 1.1.0
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
You can combine `--release-as` and `--prerelease` to generate a pre-release for a specific version type.
|
|
116
|
+
|
|
117
|
+
### Dry Run Mode
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
commit-and-tag-version --dry-run
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
See what commands would be run, without committing to git or updating files.
|
|
124
|
+
|
|
125
|
+
### Skipping Lifecycle Steps
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
commit-and-tag-version --skip-changelog
|
|
129
|
+
commit-and-tag-version --skip-bump --skip-tag
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Or via config:
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"skip": {
|
|
137
|
+
"changelog": true
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Tag Prefix
|
|
143
|
+
|
|
144
|
+
Tags are prefixed with `v` by default. Customize with `--tag-prefix`:
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
commit-and-tag-version --tag-prefix "release/"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Signing Commits and Tags
|
|
151
|
+
|
|
152
|
+
```sh
|
|
153
|
+
commit-and-tag-version --sign
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Prevent Git Hooks
|
|
157
|
+
|
|
158
|
+
```sh
|
|
159
|
+
commit-and-tag-version --no-verify
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Committing Generated Artifacts
|
|
163
|
+
|
|
164
|
+
Use `--commit-all` to include all staged changes in the release commit:
|
|
165
|
+
|
|
166
|
+
```sh
|
|
167
|
+
commit-and-tag-version --commit-all
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Tag Replacement
|
|
171
|
+
|
|
172
|
+
Use `--tag-force` to replace an existing tag (e.g., after amending a release):
|
|
173
|
+
|
|
174
|
+
```sh
|
|
175
|
+
commit-and-tag-version --skip-bump --tag-force
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## File Type Support
|
|
179
|
+
|
|
180
|
+
`commit-and-tag-version` has built-in updaters for reading and writing versions in:
|
|
181
|
+
|
|
182
|
+
| File | Updater |
|
|
183
|
+
|---|---|
|
|
184
|
+
| `package.json`, `bower.json`, `manifest.json` | JSON |
|
|
185
|
+
| `pom.xml` | Maven |
|
|
186
|
+
| `build.gradle`, `build.gradle.kts` | Gradle |
|
|
187
|
+
| `*.csproj` | .NET |
|
|
188
|
+
| `*.yaml`, `*.yml` | YAML |
|
|
189
|
+
| `openapi.yaml`, `openapi.yml` | OpenAPI |
|
|
190
|
+
| `pyproject.toml` | Python (Poetry) |
|
|
191
|
+
| `VERSION.txt`, `version.txt` | Plain text |
|
|
192
|
+
|
|
193
|
+
Point to your project's version file(s) via config:
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"packageFiles": ["pyproject.toml"],
|
|
198
|
+
"bumpFiles": ["pyproject.toml"]
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Configuration
|
|
203
|
+
|
|
204
|
+
Configure via any of these (highest to lowest precedence):
|
|
205
|
+
|
|
206
|
+
1. CLI arguments
|
|
207
|
+
2. `.versionrc` / `.versionrc.json` (JSON)
|
|
208
|
+
3. `pyproject.toml` under `[tool.commit-and-tag-version]`
|
|
209
|
+
4. Built-in defaults
|
|
210
|
+
|
|
211
|
+
### Example `.versionrc.json`
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"tagPrefix": "v",
|
|
216
|
+
"packageFiles": ["pyproject.toml"],
|
|
217
|
+
"bumpFiles": ["pyproject.toml"],
|
|
218
|
+
"types": [
|
|
219
|
+
{"type": "feat", "section": "Features"},
|
|
220
|
+
{"type": "fix", "section": "Bug Fixes"},
|
|
221
|
+
{"type": "refactor", "section": "Refactoring", "hidden": false}
|
|
222
|
+
],
|
|
223
|
+
"releaseCommitMessageFormat": "chore(release): {{currentTag}}"
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Example `pyproject.toml`
|
|
228
|
+
|
|
229
|
+
```toml
|
|
230
|
+
[tool.commit-and-tag-version]
|
|
231
|
+
tag-prefix = "v"
|
|
232
|
+
package-files = ["pyproject.toml"]
|
|
233
|
+
bump-files = ["pyproject.toml"]
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Lifecycle Scripts
|
|
237
|
+
|
|
238
|
+
Execute custom commands at each stage of the release process:
|
|
239
|
+
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"scripts": {
|
|
243
|
+
"prerelease": "python -m pytest",
|
|
244
|
+
"prebump": "echo 9.9.9",
|
|
245
|
+
"postbump": "echo bumped!",
|
|
246
|
+
"prechangelog": "",
|
|
247
|
+
"postchangelog": "",
|
|
248
|
+
"precommit": "",
|
|
249
|
+
"postcommit": "",
|
|
250
|
+
"pretag": "",
|
|
251
|
+
"posttag": ""
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
- `prebump`: If the script outputs a valid semver version, it overrides the calculated version.
|
|
257
|
+
- `precommit`: If the script outputs a string, it overrides the release commit message format.
|
|
258
|
+
|
|
259
|
+
### Customizing CHANGELOG Generation
|
|
260
|
+
|
|
261
|
+
Customize which commit types appear in the changelog and under what heading:
|
|
262
|
+
|
|
263
|
+
```json
|
|
264
|
+
{
|
|
265
|
+
"types": [
|
|
266
|
+
{"type": "feat", "section": "Features"},
|
|
267
|
+
{"type": "fix", "section": "Bug Fixes"},
|
|
268
|
+
{"type": "chore", "hidden": true},
|
|
269
|
+
{"type": "docs", "hidden": true},
|
|
270
|
+
{"type": "style", "hidden": true},
|
|
271
|
+
{"type": "refactor", "section": "Refactoring", "hidden": false},
|
|
272
|
+
{"type": "perf", "section": "Performance", "hidden": false},
|
|
273
|
+
{"type": "test", "hidden": true}
|
|
274
|
+
]
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Code Usage
|
|
279
|
+
|
|
280
|
+
```python
|
|
281
|
+
from commit_and_tag_version import commit_and_tag_version
|
|
282
|
+
from commit_and_tag_version.defaults import get_default_config
|
|
283
|
+
|
|
284
|
+
config = get_default_config()
|
|
285
|
+
config.package_files = ["pyproject.toml"]
|
|
286
|
+
config.bump_files = ["pyproject.toml"]
|
|
287
|
+
config.dry_run = True
|
|
288
|
+
|
|
289
|
+
commit_and_tag_version(config)
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## CLI Reference
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
Usage: commit-and-tag-version [OPTIONS]
|
|
296
|
+
|
|
297
|
+
Options:
|
|
298
|
+
-r, --release-as TEXT Specify release type or exact version
|
|
299
|
+
-p, --prerelease TEXT Make a prerelease with optional tag id
|
|
300
|
+
-f, --first-release Is this the first release?
|
|
301
|
+
-s, --sign GPG sign commits and tags
|
|
302
|
+
--signoff Add Signed-off-by trailer
|
|
303
|
+
-n, --no-verify Bypass git hooks
|
|
304
|
+
-a, --commit-all Commit all staged changes
|
|
305
|
+
--dry-run Simulate without making changes
|
|
306
|
+
--silent Suppress output
|
|
307
|
+
-t, --tag-prefix TEXT Tag prefix (default: v)
|
|
308
|
+
--tag-force Replace existing tag
|
|
309
|
+
-c, --config PATH Custom config file path
|
|
310
|
+
-i, --infile TEXT Changelog file path
|
|
311
|
+
--release-count INTEGER Number of releases in changelog
|
|
312
|
+
--header TEXT Custom changelog header
|
|
313
|
+
--release-commit-message-format TEXT
|
|
314
|
+
Commit message format
|
|
315
|
+
--commit-url-format TEXT Commit URL format template
|
|
316
|
+
--compare-url-format TEXT Compare URL format template
|
|
317
|
+
--issue-url-format TEXT Issue URL format template
|
|
318
|
+
--git-tag-fallback / --no-git-tag-fallback
|
|
319
|
+
Fallback to git tags for version
|
|
320
|
+
--path TEXT Only populate commits under this path
|
|
321
|
+
--skip-bump Skip version bump
|
|
322
|
+
--skip-changelog Skip changelog generation
|
|
323
|
+
--skip-commit Skip git commit
|
|
324
|
+
--skip-tag Skip git tag
|
|
325
|
+
--version Show the version and exit.
|
|
326
|
+
--help Show this message and exit.
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## FAQ
|
|
330
|
+
|
|
331
|
+
### How is this different from `python-semantic-release`?
|
|
332
|
+
|
|
333
|
+
`commit-and-tag-version` is **branch-agnostic** and **local-only**:
|
|
334
|
+
|
|
335
|
+
- No per-branch version strategies or branch-specific config
|
|
336
|
+
- No automatic pushing or publishing
|
|
337
|
+
- Deterministic bumps based solely on commit messages
|
|
338
|
+
- Prerelease is explicit via `--prerelease`, not inferred from branch names
|
|
339
|
+
- You control when and where to push
|
|
340
|
+
|
|
341
|
+
This makes it predictable across any git workflow — `feat:` always means minor, regardless of which branch you're on.
|
|
342
|
+
|
|
343
|
+
### Can I use this with non-Python projects?
|
|
344
|
+
|
|
345
|
+
Yes. Despite being written in Python, `commit-and-tag-version` supports version files for many ecosystems (Maven, Gradle, .NET, YAML, JSON, etc.). Install it as a global CLI tool and point it at your project's version file(s).
|
|
346
|
+
|
|
347
|
+
## License
|
|
348
|
+
|
|
349
|
+
MIT
|