You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update documentation for automatic version resolution and publishing process
This commit enhances the documentation in PUBLISHING.md, USAGE.md, and VERSION_RESOLUTION.md to clarify the automatic version resolution feature based on conventional commits. It details how the tool determines the next version when publishing without a specified version, including behavior for subfolder builds. Additionally, it updates examples and explanations to improve user understanding of version handling and the publishing process.
-**403 Forbidden**: Usually means you used your username instead of `__token__` with an API token. The tool now auto-detects this.
42
43
-**TestPyPI vs PyPI**: TestPyPI requires a separate account and token from https://test.pypi.org/manage/account/token/
43
44
45
+
## Version Resolution
46
+
47
+
When publishing without `--version`, the tool automatically resolves the next version using [conventional commits](VERSION_RESOLUTION.md#automatic-version-resolution). This queries the target registry for the latest published version and calculates the next version based on commit messages since that version.
48
+
49
+
```bash
50
+
# Version resolved automatically from conventional commits
- Uses that file (copies it to project root temporarily, adjusting package paths and ensuring `[build-system]` uses hatchling)
80
-
-**Version handling**: The version in the subfolder's `pyproject.toml` is automatically updated to match the derived version (from conventional commits or `--version` argument). A warning is shown if versions differ.
80
+
-**Version handling**: The version in the subfolder's `pyproject.toml` is automatically updated to match the derived version (from [conventional commits](VERSION_RESOLUTION.md#automatic-version-resolution) or `--version` argument). A warning is shown if versions differ.
81
81
-**Name handling**: If the subfolder's `pyproject.toml` has a `name` field that differs from the derived name, a warning is shown but the subfolder's name is used (not the derived one).
82
82
-**Dependencies handling**: If the subfolder's `pyproject.toml` has a non-empty `dependencies` field, automatic dependency detection is skipped with a warning. To enable automatic detection, remove or empty the `dependencies` field.
83
83
-**Field merging**: Missing fields (like `description`, `authors`, `keywords`, `classifiers`, `license`, `urls`, etc.) are automatically filled from the parent `pyproject.toml` if available.
When a subfolder has its own `pyproject.toml`, the tool intelligently merges it with derived information:
119
119
120
-
1.**Version**: Always updated to match the derived version (from conventional commits or `--version`). If the subfolder's version differs, a warning is shown but the derived version is used.
120
+
1.**Version**: Always updated to match the derived version (from [conventional commits](VERSION_RESOLUTION.md#automatic-version-resolution) or `--version`). If the subfolder's version differs, a warning is shown but the derived version is used.
121
121
122
122
2.**Name**: If the subfolder's `pyproject.toml` has a `name` field, it takes precedence over the derived name. A warning is shown if they differ.
Copy file name to clipboardExpand all lines: docs/VERSION_RESOLUTION.md
+22-3Lines changed: 22 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,13 @@ The `--version` option:
29
29
30
30
When `--version` is not provided, the tool automatically determines the next version using conventional commits. This is a **Python-native implementation** that follows the same conventions as [semantic-release](https://semantic-release.gitbook.io/semantic-release/) using the Angular preset, but requires no Node.js dependencies.
31
31
32
+
**When Version Resolution Happens:**
33
+
- Version resolution is triggered when `--version` is **not** provided AND:
34
+
- You're building a **subfolder** (any directory that's not the main `src/` directory), OR
35
+
- You're using `--publish` (for main package builds)
36
+
- If `--version` is provided, it is used directly and no resolution is performed
37
+
- If `--analyze-only` is used, version resolution is skipped
38
+
32
39
**Version Resolution Flow:**
33
40
34
41
```mermaid
@@ -48,7 +55,8 @@ flowchart TD
48
55
-**Baseline version**:
49
56
-**Registry Query (Preferred)**: When publishing to a repository (PyPI, TestPyPI, or Azure Artifacts), the tool queries the target registry for the latest published version and uses it as the baseline for version calculation. This ensures version calculations are based on what's actually published, not just git tags.
50
57
-**Git Tags (Fallback)**: If the package doesn't exist on the registry yet (first release) or if registry query fails, the tool falls back to using git tags to determine the starting version.
51
-
-**New version to publish**: After determining the baseline version, the tool analyzes commits since that version to calculate the next version bump (major, minor, or patch) based on [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) messages.
58
+
-**Default Baseline**: If no registry version or git tags are found, the baseline defaults to `0.0.0` (treating it as a first release)
59
+
-**New version to publish**: After determining the baseline version, the tool analyzes commits since that version to calculate the next version bump (major, minor, or patch) based on [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) messages. If no conventional commits are found but a baseline exists (and it's not `0.0.0`), the tool automatically bumps the minor version.
- If a baseline version exists (from registry or git tags) and it's not `0.0.0`, the tool automatically bumps the **minor version** even if no conventional commits are found
127
+
- Example: Baseline `1.2.3` with only `docs:` commits → Next version: `1.3.0`
128
+
-**First release** (`0.0.0` baseline):
129
+
- If any commits exist (even without conventional format), defaults to `0.1.0`
130
+
- If no commits exist, version resolution fails and `--version` must be provided explicitly
131
+
-**No baseline found**: Version resolution fails and `--version` must be provided explicitly
132
+
115
133
**Requirements:**
116
-
- Conventional commits (e.g., `fix:`, `feat:`, `BREAKING CHANGE:`) are required for version calculation
117
-
- The tool will fall back to requiring `--version` explicitly if no baseline version is found or no relevant commits are detected
134
+
- A baseline version (from registry or git tags) is required for version calculation, OR
135
+
- For first releases, at least one commit must exist
136
+
- If no baseline is found and no commits exist, `--version` must be provided explicitly
0 commit comments