@@ -70,7 +70,7 @@ def pyproject_file_path() -> Path:
70
70
return project_root () / PYPROJECT_FILE_PATH
71
71
72
72
73
- def write_version_file (version : Text ) -> None :
73
+ def write_version_file (version : Version ) -> None :
74
74
"""Dump a new version into the python version file."""
75
75
76
76
with version_file_path ().open ("w" ) as f :
@@ -82,13 +82,13 @@ def write_version_file(version: Text) -> None:
82
82
check_call (["git" , "add" , str (version_file_path ().absolute ())])
83
83
84
84
85
- def write_version_to_pyproject (version : Text ) -> None :
85
+ def write_version_to_pyproject (version : Version ) -> None :
86
86
"""Dump a new version into the pyproject.toml."""
87
87
pyproject_file = pyproject_file_path ()
88
88
89
89
try :
90
90
data = toml .load (pyproject_file )
91
- data ["tool" ]["poetry" ]["version" ] = version
91
+ data ["tool" ]["poetry" ]["version" ] = str ( version )
92
92
with pyproject_file .open ("w" , encoding = "utf8" ) as f :
93
93
toml .dump (data , f )
94
94
except (FileNotFoundError , TypeError ):
@@ -119,10 +119,10 @@ def get_current_version() -> Text:
119
119
return _globals ["__version__" ]
120
120
121
121
122
- def confirm_version (version : Text ) -> bool :
122
+ def confirm_version (version : Version ) -> bool :
123
123
"""Allow the user to confirm the version number."""
124
124
125
- if version in git_existing_tags ():
125
+ if str ( version ) in git_existing_tags ():
126
126
confirmed = questionary .confirm (
127
127
f"Tag with version '{ version } ' already exists, overwrite?" , default = False
128
128
).ask ()
@@ -175,12 +175,12 @@ def get_rasa_sdk_version() -> Text:
175
175
raise Exception (f"Failed to find Rasa SDK version in { dependencies_filename } " )
176
176
177
177
178
- def validate_code_is_release_ready (version : Text ) -> None :
178
+ def validate_code_is_release_ready (version : Version ) -> None :
179
179
"""Make sure the code base is valid (e.g. Rasa SDK is up to date)."""
180
180
181
181
sdk = get_rasa_sdk_version ()
182
182
sdk_version = (Version .coerce (sdk ).major , Version .coerce (sdk ).minor )
183
- rasa_version = (Version . coerce ( version ) .major , Version . coerce ( version ) .minor )
183
+ rasa_version = (version .major , version .minor )
184
184
185
185
if sdk_version != rasa_version :
186
186
print ()
@@ -221,15 +221,15 @@ def git_current_branch_is_master_or_release() -> bool:
221
221
)
222
222
223
223
224
- def create_release_branch (version : Text ) -> Text :
224
+ def create_release_branch (version : Version ) -> Text :
225
225
"""Create a new branch for this release. Returns the branch name."""
226
226
227
227
branch = f"{ RELEASE_BRANCH_PREFIX } { version } "
228
228
check_call (["git" , "checkout" , "-b" , branch ])
229
229
return branch
230
230
231
231
232
- def create_commit (version : Text ) -> None :
232
+ def create_commit (version : Version ) -> None :
233
233
"""Creates a git commit with all stashed changes."""
234
234
check_call (["git" , "commit" , "-m" , f"prepared release of version { version } " ])
235
235
@@ -305,35 +305,37 @@ def next_prerelease(version: Version, flavor: Text) -> Version:
305
305
)
306
306
307
307
308
- def parse_next_version (version : Text ) -> Text :
308
+ def parse_next_version (version : Text ) -> Version :
309
309
"""Find the next version as a proper semantic version string."""
310
310
if version == "major" :
311
- return str ( Version .coerce (get_current_version ()).next_major () )
311
+ return Version .coerce (get_current_version ()).next_major ()
312
312
elif version == "minor" :
313
- return str ( Version .coerce (get_current_version ()).next_minor () )
313
+ return Version .coerce (get_current_version ()).next_minor ()
314
314
elif version == "patch" :
315
- return str ( Version .coerce (get_current_version ()).next_patch () )
315
+ return Version .coerce (get_current_version ()).next_patch ()
316
316
elif version == "alpha" :
317
- return str ( next_prerelease (Version .coerce (get_current_version ()), "a" ) )
317
+ return next_prerelease (Version .coerce (get_current_version ()), "a" )
318
318
elif version == "rc" :
319
- return str ( next_prerelease (Version .coerce (get_current_version ()), "rc" ) )
319
+ return next_prerelease (Version .coerce (get_current_version ()), "rc" )
320
320
elif validate_version (version ):
321
- return version
321
+ return Version . coerce ( version )
322
322
else :
323
323
raise Exception (f"Invalid version number '{ cmdline_args .next_version } '." )
324
324
325
325
326
- def next_version (args : argparse .Namespace ) -> Text :
326
+ def next_version (args : argparse .Namespace ) -> Version :
327
327
"""Take cmdline args or ask the user for the next version and return semver."""
328
328
return parse_next_version (args .next_version or ask_version ())
329
329
330
330
331
- def generate_changelog (version : Text ) -> None :
331
+ def generate_changelog (version : Version ) -> None :
332
332
"""Call tonwcrier and create a changelog from all available changelog entries."""
333
- check_call (["towncrier" , "--yes" , "--version" , version ], cwd = str (project_root ()))
333
+ check_call (
334
+ ["towncrier" , "--yes" , "--version" , str (version )], cwd = str (project_root ())
335
+ )
334
336
335
337
336
- def print_done_message (branch : Text , base : Text , version : Text ) -> None :
338
+ def print_done_message (branch : Text , base : Text , version : Version ) -> None :
337
339
"""Print final information for the user on what to do next."""
338
340
339
341
pull_request_url = f"{ REPO_BASE_URL } /compare/{ base } ...{ branch } ?expand=1"
@@ -344,7 +346,7 @@ def print_done_message(branch: Text, base: Text, version: Text) -> None:
344
346
print (f"Please open a PR on GitHub: { pull_request_url } " )
345
347
346
348
347
- def print_done_message_same_branch (version : Text ) -> None :
349
+ def print_done_message_same_branch (version : Version ) -> None :
348
350
"""
349
351
Print final information for the user in case changes
350
352
are directly committed on this branch.
0 commit comments