Versioning¶バージョニング¶
Configuration¶設定¶
When the version is not statically set, configuration is defined in the tool.hatch.version table. The source option determines the source to use for retrieving and updating the version. The regex source is used by default.バージョンが静的に設定されていない場合、設定はtool.hatch.versionテーブルで定義されます。sourceオプションは、取得および更新に使用するソースを決定します。デフォルトでは、regexソースが使用されます。
The regex source requires an option path that represents a relative path to a file containing the project's version:regexソースは、プロジェクトのバージョンを含むファイルへの相対パスを表すオプションpathを必要とします:
[tool.hatch.version]
path = "src/hatch_demo/__about__.py"
[version]
path = "src/hatch_demo/__about__.py"
The default pattern looks for a variable named __version__ or VERSION that is set to a string containing the version, optionally prefixed with the lowercase letter v.デフォルトのパターンは、バージョンを含む文字列に設定された__version__またはVERSIONという名前の変数を探し、オプションで小文字のvで接頭辞を付けます。
If this doesn't reflect how you store the version, you can define a different regular expression using the pattern option:これがバージョンの保存方法を反映していない場合は、patternオプションを使用して異なる正規表現を定義できます:
[tool.hatch.version]
path = "pkg/__init__.py"
pattern = "BUILD = 'b(?P<version>[^']+)'"
[version]
path = "pkg/__init__.py"
pattern = "BUILD = 'b(?P<version>[^']+)'"
The pattern must have a named group called version that represents the version.パターンには、バージョンを表すversionという名前のグループが必要です。
Display¶表示¶
Invoking the version command without any arguments will display the current version of the project:version コマンドを引数なしで呼び出すと、プロジェクトの現在のバージョンが表示されます:
$ hatch version
0.0.1
Updating¶更新¶
You can update the version like so:バージョンを次のように更新できます:
$ hatch version "0.1.0"
Old: 0.0.1
New: 0.1.0
The scheme option determines the scheme to use for parsing both the existing and new versions. The standard scheme is used by default, which is based on PEP 440.scheme オプションは、既存のバージョンと新しいバージョンの両方を解析するために使用するスキームを決定します。デフォルトでは、標準スキームが使用され、これはPEP 440に基づいています。
Rather than setting the version explicitly, you can select the name of a segment used to increment the version:バージョンを明示的に設定する代わりに、バージョンを増加させるために使用されるセグメントの名前を選択できます:
$ hatch version minor
Old: 0.1.0
New: 0.2.0
You can chain multiple segment updates with a comma. For example, if you wanted to release a preview of your project's first major version, you could do:カンマで複数のセグメント更新を連鎖させることができます。たとえば、プロジェクトの最初のメジャーバージョンのプレビューをリリースしたい場合、次のようにできます:
$ hatch version major,rc
Old: 0.2.0
New: 1.0.0rc0
When you want to release the final version, you would do:最終バージョンをリリースしたい場合は、次のようにします:
$ hatch version release
Old: 1.0.0rc0
New: 1.0.0
Supported segments¶サポートされているセグメント¶
Here are the supported segments and how they would influence an existing version of 1.0.0:ここにサポートされているセグメントと、それらが既存の1.0.0バージョンにどのように影響するかを示します:
| Segmentsセグメント | New version新しいバージョン |
|---|---|
releaserelease | 1.0.0 |
majormajor | 2.0.0 |
minorminor | 1.1.0 |
micropatchfixmicropatchfix | 1.0.1 |
aalphaaalpha | 1.0.0a01.0.0a0 |
bbetabbeta | 1.0.0b01.0.0b0 |
crcprepreviewcrcprepreview | 1.0.0rc01.0.0rc0 |
rrevpostrrevpost | 1.0.0.post01.0.0.post0 |
devdev | 1.0.0.dev01.0.0.dev0 |