releez 0.2.2__py3-none-any.whl

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.
releez/version_tags.py ADDED
@@ -0,0 +1,69 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from enum import StrEnum
5
+
6
+ from semver import VersionInfo
7
+
8
+ from releez.errors import InvalidReleaseVersionError
9
+
10
+
11
+ class AliasVersions(StrEnum):
12
+ """Which alias versions to include in addition to the exact version."""
13
+
14
+ none = 'none'
15
+ major = 'major'
16
+ minor = 'minor'
17
+
18
+
19
+ @dataclass(frozen=True)
20
+ class VersionTags:
21
+ """Computed tags for a release version.
22
+
23
+ Attributes:
24
+ exact: The exact version tag (e.g. `2.3.4`).
25
+ major: The major tag (e.g. `v2`).
26
+ minor: The major.minor tag (e.g. `v2.3`).
27
+ """
28
+
29
+ exact: str
30
+ major: str
31
+ minor: str
32
+
33
+
34
+ def compute_version_tags(*, version: str) -> VersionTags:
35
+ """Compute exact/major/minor tags for a full release version.
36
+
37
+ Args:
38
+ version: The full release version (`x.y.z`).
39
+
40
+ Returns:
41
+ The computed tag strings.
42
+
43
+ Raises:
44
+ InvalidReleaseVersionError: If the version is not a full `x.y.z` release.
45
+ """
46
+ normalized = version.strip().removeprefix('v')
47
+
48
+ try:
49
+ parsed = VersionInfo.parse(normalized)
50
+ except ValueError as exc:
51
+ raise InvalidReleaseVersionError(version) from exc
52
+
53
+ if parsed.prerelease is not None or parsed.build is not None:
54
+ raise InvalidReleaseVersionError(version)
55
+
56
+ return VersionTags(
57
+ exact=normalized,
58
+ major=f'v{parsed.major}',
59
+ minor=f'v{parsed.major}.{parsed.minor}',
60
+ )
61
+
62
+
63
+ def select_tags(*, tags: VersionTags, aliases: AliasVersions) -> list[str]:
64
+ """Select which version aliases to output/publish given an alias level."""
65
+ if aliases == AliasVersions.none:
66
+ return [tags.exact]
67
+ if aliases == AliasVersions.major:
68
+ return [tags.exact, tags.major]
69
+ return [tags.exact, tags.major, tags.minor]
@@ -0,0 +1,225 @@
1
+ Metadata-Version: 2.3
2
+ Name: releez
3
+ Version: 0.2.2
4
+ Summary: CLI tool for helping to manage release processes.
5
+ Requires-Dist: typer==0.20.0
6
+ Requires-Dist: gitpython>=3.1.45,<4
7
+ Requires-Dist: pygithub>=2.8.1,<3
8
+ Requires-Dist: git-cliff>=2.11.0,<3
9
+ Requires-Dist: semver>=3.0.1,<4
10
+ Requires-Dist: pydantic>=2.7.0,<3
11
+ Requires-Dist: pydantic-settings>=2.7.0,<3
12
+ Requires-Python: >=3.11
13
+ Description-Content-Type: text/markdown
14
+
15
+ # `releez`
16
+
17
+ `releez` is a CLI tool for managing semantic versioned releases.
18
+
19
+ `releez` uses [`git-cliff`](https://git-cliff.org/) for versioning logic and
20
+ changelog generation under the hood. You should host a `cliff.toml` or other
21
+ compatible `git-cliff` configuration in your repo. Review the `git-cliff`
22
+ documentation for deatils.
23
+
24
+ ## Usage
25
+
26
+ Start a release from your repo (requires `git` on `PATH`):
27
+
28
+ `releez release start`
29
+
30
+ Common options:
31
+
32
+ - `--bump auto|patch|minor|major`
33
+ - `--base main`
34
+ - `--changelog-path CHANGELOG.md` (or `--changelog`)
35
+ - `--no-create-pr` (skip GitHub PR creation)
36
+ - `--github-token ...` (or set `RELEEZ_GITHUB_TOKEN`, falling back to
37
+ `GITHUB_TOKEN`)
38
+ - `--dry-run`
39
+
40
+ Compute an artifact version for CI:
41
+
42
+ `releez version artifact`
43
+
44
+ Common options:
45
+
46
+ - `--scheme docker|semver|pep440`
47
+ - `--version-override ...`
48
+ - `--is-full-release`
49
+ - `--prerelease-type alpha|beta|rc`
50
+ - `--prerelease-number ...`
51
+ - `--build-number ...`
52
+ - `--alias-versions none|major|minor` (full releases only)
53
+
54
+ Examples:
55
+
56
+ - Docker PR build:
57
+ `releez version artifact --scheme docker --version-override 0.1.0 --prerelease-type alpha --prerelease-number 123 --build-number 456`
58
+ (outputs `0.1.0-alpha123-456`)
59
+ - Python PR build:
60
+ `releez version artifact --scheme pep440 --version-override 0.1.0 --prerelease-type alpha --prerelease-number 123 --build-number 456`
61
+ - Main branch RC build:
62
+ `releez version artifact --scheme docker --version-override 0.1.0 --prerelease-type rc --prerelease-number 0 --build-number 456`
63
+ (outputs `0.1.0-rc0-456`)
64
+
65
+ Create git tags for a release:
66
+
67
+ `releez release tag` (tags the git-cliff computed release version; pushes tags
68
+ to `origin` by default)
69
+
70
+ Override the tagged version if needed:
71
+
72
+ `releez release tag --version-override 2.3.4`
73
+
74
+ Optionally update major/minor tags:
75
+
76
+ - Major only:
77
+ `releez release tag --version-override 2.3.4 --alias-versions major` (creates
78
+ `2.3.4` and `v2`)
79
+ - Major + minor:
80
+ `releez release tag --version-override 2.3.4 --alias-versions minor` (creates
81
+ `2.3.4`, `v2`, `v2.3`)
82
+
83
+ Preview what will be published (version and tags):
84
+
85
+ `releez release preview` (prints markdown to stdout)
86
+
87
+ `releez release preview --output release-preview.md` (write markdown to a file)
88
+
89
+ Generate the unreleased changelog section for the release:
90
+
91
+ `releez release notes` (prints markdown to stdout)
92
+
93
+ `releez release notes --output release-notes.md` (write markdown to a file)
94
+
95
+ Regenerate the entire changelog from git history:
96
+
97
+ `releez changelog regenerate` (regenerates `CHANGELOG.md` using git-cliff)
98
+
99
+ Common options:
100
+
101
+ - `--changelog-path CHANGELOG.md` (specify a different changelog file)
102
+ - `--run-changelog-format` (run the configured format hook after regeneration)
103
+ - `--changelog-format-cmd ...` (override the configured format command)
104
+
105
+ This is useful for fixing changelog formatting issues or rebuilding the
106
+ changelog after repository changes.
107
+
108
+ ## Configuration
109
+
110
+ `releez` supports configuration via:
111
+
112
+ 1. CLI flags for a command (highest)
113
+ 2. `RELEEZ_*` environment variables
114
+ 3. `releez.toml` in the repo root
115
+ 4. `pyproject.toml` under `[tool.releez]` (lowest)
116
+
117
+ Config values are applied as defaults for relevant CLI options; passing the CLI
118
+ flag always wins.
119
+
120
+ ### Config keys
121
+
122
+ TOML config supports both `snake_case` and `kebab-case` keys.
123
+
124
+ Env vars always use `RELEEZ_` + `SNAKE_CASE`, with `__` for nesting. Example:
125
+ `RELEEZ_HOOKS__CHANGELOG_FORMAT`.
126
+
127
+ ### Supported settings
128
+
129
+ These are the settings currently loaded from config/env:
130
+
131
+ - `base_branch` (`--base` on `release start`)
132
+ - `git_remote` (`--remote` on `release start` / `release tag`)
133
+ - `pr_labels` (`--labels` on `release start`)
134
+ - `pr_title_prefix` (`--title-prefix` on `release start`)
135
+ - `changelog_path` (`--changelog-path` on `release start` /
136
+ `changelog regenerate`)
137
+ - `create_pr` (`--create-pr/--no-create-pr` on `release start`)
138
+ - `run_changelog_format` (`--run-changelog-format` on `release start` /
139
+ `changelog regenerate`)
140
+ - `hooks.changelog_format` (used by `release start` and `changelog regenerate`
141
+ when formatting is enabled)
142
+ - `alias_versions` (`--alias-versions` on `release tag` / `release preview` /
143
+ `version artifact`)
144
+
145
+ Other flags (e.g. `--version-override`, `--scheme`, `--build-number`) are
146
+ runtime inputs and are not read from config files.
147
+
148
+ ### Examples
149
+
150
+ `pyproject.toml`:
151
+
152
+ ```toml
153
+ [tool.releez]
154
+ base-branch = "master"
155
+ git-remote = "origin"
156
+ alias-versions = "minor"
157
+ run-changelog-format = true
158
+
159
+ [tool.releez.hooks]
160
+ changelog-format = ["poe", "format-dprint", "{changelog}"]
161
+ ```
162
+
163
+ `releez.toml`:
164
+
165
+ ```toml
166
+ base_branch = "main"
167
+ git_remote = "origin"
168
+ alias_versions = "minor"
169
+ run_changelog_format = true
170
+
171
+ [hooks]
172
+ changelog_format = ["poe", "format-dprint", "{changelog}"]
173
+ ```
174
+
175
+ Environment variables:
176
+
177
+ ```bash
178
+ export RELEEZ_GIT_REMOTE=origin
179
+ export RELEEZ_ALIAS_VERSIONS=major
180
+ export RELEEZ_HOOKS__CHANGELOG_FORMAT='["poe","format-dprint","{changelog}"]'
181
+ ```
182
+
183
+ Notes:
184
+
185
+ - `releez` prefers `RELEEZ_GITHUB_TOKEN` over `GITHUB_TOKEN` for PR creation;
186
+ the token is read separately and is not part of `RELEEZ_*` settings.
187
+ - `{changelog}` in `changelog_format` is replaced with the configured changelog
188
+ path before execution.
189
+
190
+ ## GitHub actions
191
+
192
+ We've built two GitHub reusable actions which use `releez` to streamline
193
+ integration with CI pipelines. Review the documentation for each action for more
194
+ details.
195
+
196
+ ### [`releez-version-artifact-action`](https://github.com/hotdog-werx/releez-version-artifact-action)
197
+
198
+ This action can be used during CI to generate artifact versions with versions
199
+ corresponding to the versions suggested by `releez` (and implicitly,
200
+ `git-cliff`).
201
+
202
+ ### [`releez-finalize-action`](https://github.com/hotdog-werx/releez-finalize-action)
203
+
204
+ This action can be run to finalize a release. You can see
205
+ [this workflow](./.github/workflows/finalize-release.yaml) for an example a
206
+ usage.
207
+
208
+ It applies tags and outputs artifact versions as well as release notes that can
209
+ be used subsequently to create a GitHub Release.
210
+
211
+ A release should first be started with `releez release start`, usually locally,
212
+ unless you've given your actions permission to create PRs, such as via a GitHub
213
+ App.
214
+
215
+ ## GitHub recommendations
216
+
217
+ If you use GitHub PRs, prefer squashing and using the PR title as the squash
218
+ commit message:
219
+
220
+ - Enable “Allow squash merging”
221
+ - Set “Default commit message” to “Pull request title”
222
+
223
+ This keeps your main branch history aligned with semantic PR titles (and works
224
+ well with `amannn/action-semantic-pull-request` and changelog generation via
225
+ `git-cliff`).
@@ -0,0 +1,18 @@
1
+ releez/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
2
+ releez/artifact_version.py,sha256=sXHjR4GyDyRabYbTVINi1WEaeaoyiyrKE5BjPZHohvc,3386
3
+ releez/cli.py,sha256=pnR6M6b0x2p-cYCVqCULKtrgpnox7fJf6UKutmIU36E,17005
4
+ releez/cliff.py,sha256=fVHyFTdrxuraZiuWW8KEWXvbRBAR_HdPJyGHLG9V-vM,5080
5
+ releez/errors.py,sha256=LVLrGtkr1gfScwwXUnlNI-kSyVBmW5nNHLXofCGFMV4,7104
6
+ releez/git_repo.py,sha256=_Np11E0LUfWutSGapzLcCclk9NT5D30SEQCTzZXF8N8,6245
7
+ releez/github.py,sha256=c-9soa457X8HzaeVM3JJcpdWzMjl_ZbQH7VN-3jx09w,3885
8
+ releez/process.py,sha256=4I-sZNDCqTG167K9xglrzhd16pPihd6jI_4wyQ4UmCw,1416
9
+ releez/release.py,sha256=TKLEsVgvvgmn_js5T8aqtoc19fTjOJI9DmgXYjkO95U,6819
10
+ releez/settings.py,sha256=eOelkqCFetZdmOPCfaNxoxHvfn3zRQtb84PUztb09Pg,2953
11
+ releez/subapps/__init__.py,sha256=pDyHecbnvOayItqUw2FFVET4H7Lj4glgTqUgMrL-S34,116
12
+ releez/subapps/changelog.py,sha256=rJpdzJocYNDzjL8YJFw0v6LyNYLtJvsxZUu3f3eIi_I,2594
13
+ releez/utils.py,sha256=19PYyrUXPYLAgvD14Q7taZMlctV7YyLT0MAtVhmn18M,1356
14
+ releez/version_tags.py,sha256=nnkdnwYADO-9tt2vYT7xAbitBFvQPUkgxvdtRVY10C0,1798
15
+ releez-0.2.2.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
16
+ releez-0.2.2.dist-info/entry_points.txt,sha256=dFRzNkEp1RC4HgqbeI7XAHDPbIkL9-7KWvp28dj_ctw,44
17
+ releez-0.2.2.dist-info/METADATA,sha256=MzGAxuPDzdV-G7RBMj202YLELvmeQ0ewN8EpNdjOG_k,6938
18
+ releez-0.2.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.9.28
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ releez = releez.cli:main
3
+