Prepare `bump-my-version` for this project
Marco Ricci

Marco Ricci commited on 2025-02-08 19:58:45
Zeige 1 geänderte Dateien mit 116 Einfügungen und 1 Löschungen.


Prepare and configure the use of `bump-my-version` to automate keeping
version numbers synchronized everywhere.  From a cursory search, this
appears to be the most mature and actively developed tool of this kind
with support for `pyproject.toml` and multiple files with file-specific
replacements.  Some minor warts remain (non-recursive globbing,
duplication of the version number, incorrect calculation of the next
release due to missing true support for pre-release segments), but they
can be worked around, for now.
... ...
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6 6
 name = "derivepassphrase"
7 7
 description = "An almost faithful Python reimplementation of James Coglan's vault."
8 8
 readme = "README.md"
9
-version = "0.5a1.dev1"
9
+version = '0.5a1.dev1'
10 10
 requires-python = ">= 3.9"
11 11
 license = { text = "zlib/libpng" }
12 12
 keywords = []
... ...
@@ -78,6 +78,121 @@ Documentation = "https://the13thletter.info/derivepassphrase/"
78 78
 Issues = "https://github.com/the-13th-letter/derivepassphrase/issues"
79 79
 Source = "https://github.com/the-13th-letter/derivepassphrase"
80 80
 
81
+[tool.bumpversion]
82
+current_version = '0.5a1.dev1'
83
+# As of bump-my-version 0.32.0, version components are strictly
84
+# hierarchical in the order of occurrence, and there is no support for
85
+# pre-release markers.  The documentation suggests a fake "dev/rc/final"
86
+# marker, with "final" being suppressed on output; effectively, it's
87
+# major.minor.patch-n.m, where -n.m is suppressed if n is some maximum
88
+# value and m is zero.  This sort of scales to multiple levels of pre-
89
+# oder development releases (e.g. distinguished alpha versions and
90
+# development versions in between alpha versions) if you manually
91
+# increment the lower markers manually, in descending order, while no
92
+# committing the result... but at that point you're not really gaining
93
+# that much over calculating the new version number yourself and forcing
94
+# that.
95
+#
96
+# The primary reason to still fill out these templates is to ensure that
97
+# the version number correctly round-trips within bump-my-version.
98
+parse = '''(?x)
99
+    (?P<major>\d+)
100
+    \.(?P<minor>\d+)
101
+    (?:\.(?P<patch>\d+))?
102
+    (?:
103
+        (?P<pre_l>-dev|a|b|rc|)
104
+        (?P<pre_n>[1-9][0-9]*)
105
+    )?
106
+    (?:
107
+        [-.]
108
+        (?P<dev_t>dev|final)
109
+        (?P<dev_n>[1-9][0-9]*)
110
+    )?
111
+'''
112
+serialize = [
113
+    '{major}.{minor}.{patch}{pre_l}{pre_n}-{dev_t}{dev_n}',
114
+    '{major}.{minor}.{patch}{pre_l}{pre_n}',
115
+    '{major}.{minor}.{patch}',
116
+    '{major}.{minor}{pre_l}{pre_n}-{dev_t}{dev_n}',
117
+    '{major}.{minor}{pre_l}{pre_n}',
118
+    '{major}.{minor}',
119
+]
120
+search = '{current_version}'
121
+replace = '{new_version}'
122
+regex = false
123
+ignore_missing_version = false
124
+ignore_missing_files = false
125
+tag = true
126
+sign_tags = false
127
+tag_name = '{new_version}'
128
+tag_message = 'Release derivepassphrase v{new_version}'
129
+allow_dirty = true
130
+commit = true
131
+message = 'Release {new_version}'
132
+moveable_tags = []
133
+commit_args = ""
134
+setup_hooks = []
135
+pre_commit_hooks = []
136
+post_commit_hooks = []
137
+
138
+[tool.bumpversion.parts.dev_t]
139
+values = ['dev', '']
140
+optional_value = ''
141
+
142
+[tool.bumpversion.parts.dev_n]
143
+values = []
144
+first_value = '1'
145
+
146
+[tool.bumpversion.parts.pre_l]
147
+values = ['-dev', 'a', 'b', 'rc', '']
148
+optional_value = ''
149
+
150
+[tool.bumpversion.parts.pre_n]
151
+values = []
152
+first_value = '1'
153
+
154
+[[tool.bumpversion.files]]
155
+glob = 'src/derivepassphrase/*.py'
156
+search = '# SPDX-FileCopyrightText: \d\d\d\d'
157
+replace = '# SPDX-FileCopyrightText: {now:%Y}'
158
+regex = true
159
+
160
+[[tool.bumpversion.files]]
161
+glob = 'src/derivepassphrase/*/*.py'
162
+search = '# SPDX-FileCopyrightText: \d\d\d\d'
163
+replace = '# SPDX-FileCopyrightText: {now:%Y}'
164
+regex = true
165
+
166
+[[tool.bumpversion.files]]
167
+glob = 'tests/*.py'
168
+search = '# SPDX-FileCopyrightText: \d\d\d\d'
169
+replace = '# SPDX-FileCopyrightText: {now:%Y}'
170
+regex = true
171
+
172
+[[tool.bumpversion.files]]
173
+filename = 'pyproject.toml'
174
+search = "version = '{current_version}'"
175
+replace = "version = '{new_version}'"
176
+regex = true
177
+
178
+[[tool.bumpversion.files]]
179
+filename = 'pyproject.toml'
180
+search = "current_version = '{current_version}'"
181
+replace = "current_version = '{new_version}'"
182
+regex = true
183
+
184
+[[tool.bumpversion.files]]
185
+glob = 'man/derivepassphrase*.1'
186
+regex = true
187
+search = '^\.Dd \d\d\d\d-\d\d-\d\d'
188
+replace = '.Dd {now:%Y-%m-%d}'
189
+
190
+[[tool.bumpversion.files]]
191
+glob = 'man/derivepassphrase*.1'
192
+regex = true
193
+search = '^\.Os derivepassphrase {current_version}'
194
+replace = '\.Os derivepassphrase {new_version}'
195
+
81 196
 [tool.coverage.html]
82 197
 directory = "html/coverage"
83 198
 
84 199