FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
robust-python-demo/scripts/setup-release.py at main · robust-python/robust-python-demo · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
robust-python
/
robust-python-demo
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
10
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
robust-python-demo
/
scripts
/
setup-release.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
88 lines (68 loc) · 2.87 KB
Breadcrumbs
robust-python-demo
/
scripts
/
setup-release.py
Copy path
File metadata and controls
88 lines (68 loc) · 2.87 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"""Script responsible for preparing a release of the robust-python-demo package."""
import
argparse
import
subprocess
from
typing
import
Optional
from
util
import
REPO_FOLDER
from
util
import
bump_version
from
util
import
check_dependencies
from
util
import
create_release_branch
from
util
import
get_bumped_package_version
from
util
import
get_package_version
from
util
import
require_clean_and_up_to_date_repo
def
main
()
->
None
:
"""Parses args and passes through to setup_release."""
parser
:
argparse
.
ArgumentParser
=
get_parser
()
args
:
argparse
.
Namespace
=
parser
.
parse_args
()
setup_release
(
increment
=
args
.
increment
)
def
get_parser
()
->
argparse
.
ArgumentParser
:
"""Creates the argument parser for setup-release."""
parser
:
argparse
.
ArgumentParser
=
argparse
.
ArgumentParser
(
prog
=
"setup-release"
,
usage
=
"python ./scripts/setup-release.py patch"
)
parser
.
add_argument
(
"increment"
,
nargs
=
"?"
,
default
=
None
,
type
=
str
,
help
=
"Increment type to use when preparing the release."
,
choices
=
[
"MAJOR"
,
"MINOR"
,
"PATCH"
,
"PRERELEASE"
],
)
return
parser
def
setup_release
(
increment
:
Optional
[
str
]
=
None
)
->
None
:
"""Prepares a release of the robust-python-demo package.
Will try to create the release and push, however will return to pre-existing state on error.
"""
check_dependencies
(
path
=
REPO_FOLDER
,
dependencies
=
[
"git"
])
require_clean_and_up_to_date_repo
()
current_version
:
str
=
get_package_version
()
new_version
:
str
=
get_bumped_package_version
(
increment
=
increment
)
try
:
_setup_release
(
increment
=
increment
,
current_version
=
current_version
,
new_version
=
new_version
)
except
Exception
as
error
:
_rollback_release
(
version
=
new_version
)
raise
error
def
_setup_release
(
increment
:
str
,
current_version
:
str
,
new_version
:
str
)
->
None
:
"""Prepares a release of the robust-python-demo package.
Sets up a release branch from the branch develop, bumps the version, and creates a release commit. Does not tag the
release or push any changes.
"""
create_release_branch
(
new_version
=
new_version
)
bump_version
(
increment
=
increment
)
commands
:
list
[
list
[
str
]]
=
[
[
"uv"
,
"sync"
,
"--all-groups"
],
[
"git"
,
"add"
,
"."
],
[
"git"
,
"commit"
,
"-m"
,
f"bump: version
{
current_version
}
→
{
new_version
}
"
,
"--no-verify"
],
]
for
command
in
commands
:
subprocess
.
run
(
command
,
cwd
=
REPO_FOLDER
,
capture_output
=
True
,
check
=
True
)
def
_rollback_release
(
version
:
str
)
->
None
:
"""Rolls back to the pre-existing state on error."""
commands
:
list
[
list
[
str
]]
=
[
[
"git"
,
"checkout"
,
"develop"
],
[
"git"
,
"checkout"
,
"."
],
[
"git"
,
"branch"
,
"-D"
,
f"release/
{
version
}
"
],
]
for
command
in
commands
:
subprocess
.
run
(
command
,
cwd
=
REPO_FOLDER
,
check
=
False
)
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL