releez 0.2.2__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.
- releez-0.2.2/PKG-INFO +225 -0
- releez-0.2.2/README.md +211 -0
- releez-0.2.2/pyproject.toml +47 -0
- releez-0.2.2/src/releez/__init__.py +1 -0
- releez-0.2.2/src/releez/artifact_version.py +111 -0
- releez-0.2.2/src/releez/cli.py +559 -0
- releez-0.2.2/src/releez/cliff.py +186 -0
- releez-0.2.2/src/releez/errors.py +231 -0
- releez-0.2.2/src/releez/git_repo.py +232 -0
- releez-0.2.2/src/releez/github.py +145 -0
- releez-0.2.2/src/releez/process.py +52 -0
- releez-0.2.2/src/releez/release.py +241 -0
- releez-0.2.2/src/releez/settings.py +101 -0
- releez-0.2.2/src/releez/subapps/__init__.py +5 -0
- releez-0.2.2/src/releez/subapps/changelog.py +87 -0
- releez-0.2.2/src/releez/utils.py +44 -0
- releez-0.2.2/src/releez/version_tags.py +69 -0
releez-0.2.2/PKG-INFO
ADDED
|
@@ -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`).
|
releez-0.2.2/README.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# `releez`
|
|
2
|
+
|
|
3
|
+
`releez` is a CLI tool for managing semantic versioned releases.
|
|
4
|
+
|
|
5
|
+
`releez` uses [`git-cliff`](https://git-cliff.org/) for versioning logic and
|
|
6
|
+
changelog generation under the hood. You should host a `cliff.toml` or other
|
|
7
|
+
compatible `git-cliff` configuration in your repo. Review the `git-cliff`
|
|
8
|
+
documentation for deatils.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
Start a release from your repo (requires `git` on `PATH`):
|
|
13
|
+
|
|
14
|
+
`releez release start`
|
|
15
|
+
|
|
16
|
+
Common options:
|
|
17
|
+
|
|
18
|
+
- `--bump auto|patch|minor|major`
|
|
19
|
+
- `--base main`
|
|
20
|
+
- `--changelog-path CHANGELOG.md` (or `--changelog`)
|
|
21
|
+
- `--no-create-pr` (skip GitHub PR creation)
|
|
22
|
+
- `--github-token ...` (or set `RELEEZ_GITHUB_TOKEN`, falling back to
|
|
23
|
+
`GITHUB_TOKEN`)
|
|
24
|
+
- `--dry-run`
|
|
25
|
+
|
|
26
|
+
Compute an artifact version for CI:
|
|
27
|
+
|
|
28
|
+
`releez version artifact`
|
|
29
|
+
|
|
30
|
+
Common options:
|
|
31
|
+
|
|
32
|
+
- `--scheme docker|semver|pep440`
|
|
33
|
+
- `--version-override ...`
|
|
34
|
+
- `--is-full-release`
|
|
35
|
+
- `--prerelease-type alpha|beta|rc`
|
|
36
|
+
- `--prerelease-number ...`
|
|
37
|
+
- `--build-number ...`
|
|
38
|
+
- `--alias-versions none|major|minor` (full releases only)
|
|
39
|
+
|
|
40
|
+
Examples:
|
|
41
|
+
|
|
42
|
+
- Docker PR build:
|
|
43
|
+
`releez version artifact --scheme docker --version-override 0.1.0 --prerelease-type alpha --prerelease-number 123 --build-number 456`
|
|
44
|
+
(outputs `0.1.0-alpha123-456`)
|
|
45
|
+
- Python PR build:
|
|
46
|
+
`releez version artifact --scheme pep440 --version-override 0.1.0 --prerelease-type alpha --prerelease-number 123 --build-number 456`
|
|
47
|
+
- Main branch RC build:
|
|
48
|
+
`releez version artifact --scheme docker --version-override 0.1.0 --prerelease-type rc --prerelease-number 0 --build-number 456`
|
|
49
|
+
(outputs `0.1.0-rc0-456`)
|
|
50
|
+
|
|
51
|
+
Create git tags for a release:
|
|
52
|
+
|
|
53
|
+
`releez release tag` (tags the git-cliff computed release version; pushes tags
|
|
54
|
+
to `origin` by default)
|
|
55
|
+
|
|
56
|
+
Override the tagged version if needed:
|
|
57
|
+
|
|
58
|
+
`releez release tag --version-override 2.3.4`
|
|
59
|
+
|
|
60
|
+
Optionally update major/minor tags:
|
|
61
|
+
|
|
62
|
+
- Major only:
|
|
63
|
+
`releez release tag --version-override 2.3.4 --alias-versions major` (creates
|
|
64
|
+
`2.3.4` and `v2`)
|
|
65
|
+
- Major + minor:
|
|
66
|
+
`releez release tag --version-override 2.3.4 --alias-versions minor` (creates
|
|
67
|
+
`2.3.4`, `v2`, `v2.3`)
|
|
68
|
+
|
|
69
|
+
Preview what will be published (version and tags):
|
|
70
|
+
|
|
71
|
+
`releez release preview` (prints markdown to stdout)
|
|
72
|
+
|
|
73
|
+
`releez release preview --output release-preview.md` (write markdown to a file)
|
|
74
|
+
|
|
75
|
+
Generate the unreleased changelog section for the release:
|
|
76
|
+
|
|
77
|
+
`releez release notes` (prints markdown to stdout)
|
|
78
|
+
|
|
79
|
+
`releez release notes --output release-notes.md` (write markdown to a file)
|
|
80
|
+
|
|
81
|
+
Regenerate the entire changelog from git history:
|
|
82
|
+
|
|
83
|
+
`releez changelog regenerate` (regenerates `CHANGELOG.md` using git-cliff)
|
|
84
|
+
|
|
85
|
+
Common options:
|
|
86
|
+
|
|
87
|
+
- `--changelog-path CHANGELOG.md` (specify a different changelog file)
|
|
88
|
+
- `--run-changelog-format` (run the configured format hook after regeneration)
|
|
89
|
+
- `--changelog-format-cmd ...` (override the configured format command)
|
|
90
|
+
|
|
91
|
+
This is useful for fixing changelog formatting issues or rebuilding the
|
|
92
|
+
changelog after repository changes.
|
|
93
|
+
|
|
94
|
+
## Configuration
|
|
95
|
+
|
|
96
|
+
`releez` supports configuration via:
|
|
97
|
+
|
|
98
|
+
1. CLI flags for a command (highest)
|
|
99
|
+
2. `RELEEZ_*` environment variables
|
|
100
|
+
3. `releez.toml` in the repo root
|
|
101
|
+
4. `pyproject.toml` under `[tool.releez]` (lowest)
|
|
102
|
+
|
|
103
|
+
Config values are applied as defaults for relevant CLI options; passing the CLI
|
|
104
|
+
flag always wins.
|
|
105
|
+
|
|
106
|
+
### Config keys
|
|
107
|
+
|
|
108
|
+
TOML config supports both `snake_case` and `kebab-case` keys.
|
|
109
|
+
|
|
110
|
+
Env vars always use `RELEEZ_` + `SNAKE_CASE`, with `__` for nesting. Example:
|
|
111
|
+
`RELEEZ_HOOKS__CHANGELOG_FORMAT`.
|
|
112
|
+
|
|
113
|
+
### Supported settings
|
|
114
|
+
|
|
115
|
+
These are the settings currently loaded from config/env:
|
|
116
|
+
|
|
117
|
+
- `base_branch` (`--base` on `release start`)
|
|
118
|
+
- `git_remote` (`--remote` on `release start` / `release tag`)
|
|
119
|
+
- `pr_labels` (`--labels` on `release start`)
|
|
120
|
+
- `pr_title_prefix` (`--title-prefix` on `release start`)
|
|
121
|
+
- `changelog_path` (`--changelog-path` on `release start` /
|
|
122
|
+
`changelog regenerate`)
|
|
123
|
+
- `create_pr` (`--create-pr/--no-create-pr` on `release start`)
|
|
124
|
+
- `run_changelog_format` (`--run-changelog-format` on `release start` /
|
|
125
|
+
`changelog regenerate`)
|
|
126
|
+
- `hooks.changelog_format` (used by `release start` and `changelog regenerate`
|
|
127
|
+
when formatting is enabled)
|
|
128
|
+
- `alias_versions` (`--alias-versions` on `release tag` / `release preview` /
|
|
129
|
+
`version artifact`)
|
|
130
|
+
|
|
131
|
+
Other flags (e.g. `--version-override`, `--scheme`, `--build-number`) are
|
|
132
|
+
runtime inputs and are not read from config files.
|
|
133
|
+
|
|
134
|
+
### Examples
|
|
135
|
+
|
|
136
|
+
`pyproject.toml`:
|
|
137
|
+
|
|
138
|
+
```toml
|
|
139
|
+
[tool.releez]
|
|
140
|
+
base-branch = "master"
|
|
141
|
+
git-remote = "origin"
|
|
142
|
+
alias-versions = "minor"
|
|
143
|
+
run-changelog-format = true
|
|
144
|
+
|
|
145
|
+
[tool.releez.hooks]
|
|
146
|
+
changelog-format = ["poe", "format-dprint", "{changelog}"]
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`releez.toml`:
|
|
150
|
+
|
|
151
|
+
```toml
|
|
152
|
+
base_branch = "main"
|
|
153
|
+
git_remote = "origin"
|
|
154
|
+
alias_versions = "minor"
|
|
155
|
+
run_changelog_format = true
|
|
156
|
+
|
|
157
|
+
[hooks]
|
|
158
|
+
changelog_format = ["poe", "format-dprint", "{changelog}"]
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Environment variables:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
export RELEEZ_GIT_REMOTE=origin
|
|
165
|
+
export RELEEZ_ALIAS_VERSIONS=major
|
|
166
|
+
export RELEEZ_HOOKS__CHANGELOG_FORMAT='["poe","format-dprint","{changelog}"]'
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Notes:
|
|
170
|
+
|
|
171
|
+
- `releez` prefers `RELEEZ_GITHUB_TOKEN` over `GITHUB_TOKEN` for PR creation;
|
|
172
|
+
the token is read separately and is not part of `RELEEZ_*` settings.
|
|
173
|
+
- `{changelog}` in `changelog_format` is replaced with the configured changelog
|
|
174
|
+
path before execution.
|
|
175
|
+
|
|
176
|
+
## GitHub actions
|
|
177
|
+
|
|
178
|
+
We've built two GitHub reusable actions which use `releez` to streamline
|
|
179
|
+
integration with CI pipelines. Review the documentation for each action for more
|
|
180
|
+
details.
|
|
181
|
+
|
|
182
|
+
### [`releez-version-artifact-action`](https://github.com/hotdog-werx/releez-version-artifact-action)
|
|
183
|
+
|
|
184
|
+
This action can be used during CI to generate artifact versions with versions
|
|
185
|
+
corresponding to the versions suggested by `releez` (and implicitly,
|
|
186
|
+
`git-cliff`).
|
|
187
|
+
|
|
188
|
+
### [`releez-finalize-action`](https://github.com/hotdog-werx/releez-finalize-action)
|
|
189
|
+
|
|
190
|
+
This action can be run to finalize a release. You can see
|
|
191
|
+
[this workflow](./.github/workflows/finalize-release.yaml) for an example a
|
|
192
|
+
usage.
|
|
193
|
+
|
|
194
|
+
It applies tags and outputs artifact versions as well as release notes that can
|
|
195
|
+
be used subsequently to create a GitHub Release.
|
|
196
|
+
|
|
197
|
+
A release should first be started with `releez release start`, usually locally,
|
|
198
|
+
unless you've given your actions permission to create PRs, such as via a GitHub
|
|
199
|
+
App.
|
|
200
|
+
|
|
201
|
+
## GitHub recommendations
|
|
202
|
+
|
|
203
|
+
If you use GitHub PRs, prefer squashing and using the PR title as the squash
|
|
204
|
+
commit message:
|
|
205
|
+
|
|
206
|
+
- Enable “Allow squash merging”
|
|
207
|
+
- Set “Default commit message” to “Pull request title”
|
|
208
|
+
|
|
209
|
+
This keeps your main branch history aligned with semantic PR titles (and works
|
|
210
|
+
well with `amannn/action-semantic-pull-request` and changelog generation via
|
|
211
|
+
`git-cliff`).
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "releez"
|
|
3
|
+
description = "CLI tool for helping to manage release processes."
|
|
4
|
+
readme = "README.md"
|
|
5
|
+
requires-python = ">=3.11"
|
|
6
|
+
version = "0.2.2"
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
"typer ==0.20.0",
|
|
10
|
+
"GitPython >= 3.1.45, <4",
|
|
11
|
+
"PyGithub >= 2.8.1, <3",
|
|
12
|
+
"git-cliff >=2.11.0, <3",
|
|
13
|
+
"semver >=3.0.1, <4",
|
|
14
|
+
"pydantic >=2.7.0, <3",
|
|
15
|
+
"pydantic-settings >=2.7.0, <3",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[dependency-groups]
|
|
19
|
+
dev = [
|
|
20
|
+
"pytest >=9.0.2, <10",
|
|
21
|
+
"pytest-cov >=7.0.0, <8",
|
|
22
|
+
"pytest-mock >=3.15.1, <4",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
releez = "releez.cli:main"
|
|
27
|
+
|
|
28
|
+
[tool.ruff]
|
|
29
|
+
extend = ".codeguide/configs/ruff.toml"
|
|
30
|
+
|
|
31
|
+
[tool.pyright]
|
|
32
|
+
typeCheckingMode = "standard"
|
|
33
|
+
|
|
34
|
+
[tool.pytest.ini_options]
|
|
35
|
+
testpaths = ["tests"]
|
|
36
|
+
|
|
37
|
+
[tool.uv.build-backend]
|
|
38
|
+
module-name = "releez"
|
|
39
|
+
module-root = "src"
|
|
40
|
+
|
|
41
|
+
[tool.releez]
|
|
42
|
+
create-pr = true
|
|
43
|
+
hooks = { changelog-format = ["mise", "exec", "--", "poe", "format-dprint", "{changelog}"] }
|
|
44
|
+
|
|
45
|
+
[build-system]
|
|
46
|
+
requires = ["uv_build"]
|
|
47
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from enum import StrEnum
|
|
5
|
+
|
|
6
|
+
from releez.cliff import GitCliff
|
|
7
|
+
from releez.errors import (
|
|
8
|
+
BuildNumberRequiredError,
|
|
9
|
+
PrereleaseNumberRequiredError,
|
|
10
|
+
)
|
|
11
|
+
from releez.git_repo import open_repo
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ArtifactVersionScheme(StrEnum):
|
|
15
|
+
"""Output scheme for artifact versions."""
|
|
16
|
+
|
|
17
|
+
semver = 'semver'
|
|
18
|
+
docker = 'docker'
|
|
19
|
+
pep440 = 'pep440'
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class PrereleaseType(StrEnum):
|
|
23
|
+
"""Supported prerelease types.
|
|
24
|
+
|
|
25
|
+
These are deliberately limited so we can reliably map to PEP 440.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
alpha = 'alpha'
|
|
29
|
+
beta = 'beta'
|
|
30
|
+
rc = 'rc'
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass(frozen=True)
|
|
34
|
+
class ArtifactVersionInput:
|
|
35
|
+
"""Inputs for computing an artifact version.
|
|
36
|
+
|
|
37
|
+
Attributes:
|
|
38
|
+
scheme: Output scheme for the artifact version.
|
|
39
|
+
version_override: If set, use this instead of computing via git-cliff.
|
|
40
|
+
is_full_release: If true, output a full release version without prerelease markers.
|
|
41
|
+
prerelease_type: Prerelease label (e.g. alpha, beta, rc).
|
|
42
|
+
prerelease_number: Optional prerelease number (e.g. PR number for alpha123).
|
|
43
|
+
build_number: Build identifier for prerelease builds.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
scheme: ArtifactVersionScheme
|
|
47
|
+
version_override: str | None
|
|
48
|
+
is_full_release: bool
|
|
49
|
+
prerelease_type: PrereleaseType
|
|
50
|
+
prerelease_number: int | None
|
|
51
|
+
build_number: int | None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
_PEP440_PRERELEASE_MARKERS: dict[PrereleaseType, str] = {
|
|
55
|
+
PrereleaseType.alpha: 'a',
|
|
56
|
+
PrereleaseType.beta: 'b',
|
|
57
|
+
PrereleaseType.rc: 'rc',
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def compute_artifact_version(artifact_input: ArtifactVersionInput) -> str:
|
|
62
|
+
"""Compute an artifact version string.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
artifact_input: The inputs for computing the version.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
The version string to apply to the artifact.
|
|
69
|
+
|
|
70
|
+
Raises:
|
|
71
|
+
BuildNumberRequiredError: If a prerelease build is missing a build number.
|
|
72
|
+
ReleezError: If git or git-cliff are unavailable, or git-cliff fails.
|
|
73
|
+
"""
|
|
74
|
+
next_version = artifact_input.version_override or _compute_next_version()
|
|
75
|
+
if artifact_input.is_full_release:
|
|
76
|
+
return next_version
|
|
77
|
+
|
|
78
|
+
if artifact_input.build_number is None:
|
|
79
|
+
raise BuildNumberRequiredError
|
|
80
|
+
|
|
81
|
+
prerelease_type = artifact_input.prerelease_type.value
|
|
82
|
+
prerelease_number = artifact_input.prerelease_number
|
|
83
|
+
if prerelease_number is None:
|
|
84
|
+
raise PrereleaseNumberRequiredError
|
|
85
|
+
if artifact_input.scheme == ArtifactVersionScheme.semver:
|
|
86
|
+
return f'{next_version}-{prerelease_type}{prerelease_number}+{artifact_input.build_number}'
|
|
87
|
+
if artifact_input.scheme == ArtifactVersionScheme.docker:
|
|
88
|
+
return f'{next_version}-{prerelease_type}{prerelease_number}-{artifact_input.build_number}'
|
|
89
|
+
return _pep440_version(
|
|
90
|
+
next_version=next_version,
|
|
91
|
+
prerelease_type=artifact_input.prerelease_type,
|
|
92
|
+
prerelease_number=prerelease_number,
|
|
93
|
+
build_number=artifact_input.build_number,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _compute_next_version() -> str:
|
|
98
|
+
_, info = open_repo()
|
|
99
|
+
cliff = GitCliff(repo_root=info.root)
|
|
100
|
+
return cliff.compute_next_version(bump='auto')
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _pep440_version(
|
|
104
|
+
*,
|
|
105
|
+
next_version: str,
|
|
106
|
+
prerelease_type: PrereleaseType,
|
|
107
|
+
prerelease_number: int | None,
|
|
108
|
+
build_number: int,
|
|
109
|
+
) -> str:
|
|
110
|
+
marker = _PEP440_PRERELEASE_MARKERS[prerelease_type]
|
|
111
|
+
return f'{next_version}{marker}{prerelease_number}.dev{build_number}'
|