Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
cec89e1a
Unverified
Commit
cec89e1a
authored
Mar 09, 2022
by
Sylvain Gugger
Committed by
GitHub
Mar 09, 2022
Browse files
Simplify release utils (#15921)
* Simplify release utils * Quality
parent
e493a3a5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
40 deletions
+1
-40
utils/release.py
utils/release.py
+1
-40
No files found.
utils/release.py
View file @
cec89e1a
...
@@ -17,7 +17,6 @@ import argparse
...
@@ -17,7 +17,6 @@ import argparse
import
os
import
os
import
re
import
re
import
git
import
packaging.version
import
packaging.version
...
@@ -33,8 +32,6 @@ REPLACE_FILES = {
...
@@ -33,8 +32,6 @@ REPLACE_FILES = {
"setup"
:
"setup.py"
,
"setup"
:
"setup.py"
,
}
}
README_FILE
=
"README.md"
README_FILE
=
"README.md"
CUSTOM_JS_FILE
=
"docs/source/_static/js/custom.js"
DEPLOY_SH_FILE
=
".circleci/deploy.sh"
def
update_version_in_file
(
fname
,
version
,
pattern
):
def
update_version_in_file
(
fname
,
version
,
pattern
):
...
@@ -136,52 +133,16 @@ def post_release_work():
...
@@ -136,52 +133,16 @@ def post_release_work():
current_version
=
get_version
()
current_version
=
get_version
()
dev_version
=
f
"
{
current_version
.
major
}
.
{
current_version
.
minor
+
1
}
.0.dev0"
dev_version
=
f
"
{
current_version
.
major
}
.
{
current_version
.
minor
+
1
}
.0.dev0"
current_version
=
current_version
.
base_version
current_version
=
current_version
.
base_version
# Get the current commit hash
repo
=
git
.
Repo
(
"."
,
search_parent_directories
=
True
)
version_commit
=
repo
.
head
.
object
.
hexsha
[:
7
]
# Check with the user we got that right.
# Check with the user we got that right.
version
=
input
(
f
"Which version are we developing now? [
{
dev_version
}
]"
)
version
=
input
(
f
"Which version are we developing now? [
{
dev_version
}
]"
)
commit
=
input
(
f
"Commit hash to associate to v
{
current_version
}
? [
{
version_commit
}
]"
)
if
len
(
version
)
==
0
:
if
len
(
version
)
==
0
:
version
=
dev_version
version
=
dev_version
if
len
(
commit
)
==
0
:
commit
=
version_commit
print
(
f
"Updating version to
{
version
}
."
)
print
(
f
"Updating version to
{
version
}
."
)
global_version_update
(
version
)
global_version_update
(
version
)
def
post_patch_work
():
"""Do all the necesarry post-patch steps."""
# Try to guess the right info: last patch in the minor release before current version and its commit hash.
current_version
=
get_version
()
repo
=
git
.
Repo
(
"."
,
search_parent_directories
=
True
)
repo_tags
=
repo
.
tags
default_version
=
None
version_commit
=
None
for
tag
in
repo_tags
:
if
str
(
tag
).
startswith
(
f
"v
{
current_version
.
major
}
.
{
current_version
.
minor
-
1
}
"
):
if
default_version
is
None
:
default_version
=
packaging
.
version
.
parse
(
str
(
tag
)[
1
:])
version_commit
=
str
(
tag
.
commit
)[:
7
]
elif
packaging
.
version
.
parse
(
str
(
tag
)[
1
:])
>
default_version
:
default_version
=
packaging
.
version
.
parse
(
str
(
tag
)[
1
:])
version_commit
=
str
(
tag
.
commit
)[:
7
]
# Confirm with the user or ask for the info if not found.
if
default_version
is
None
:
version
=
input
(
"Which patch version was just released?"
)
commit
=
input
(
"Commit hash to associated to it?"
)
else
:
version
=
input
(
f
"Which patch version was just released? [
{
default_version
}
]"
)
commit
=
input
(
f
"Commit hash to associated to it? [
{
version_commit
}
]"
)
if
len
(
version
)
==
0
:
version
=
default_version
if
len
(
commit
)
==
0
:
commit
=
version_commit
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"--post_release"
,
action
=
"store_true"
,
help
=
"Whether this is pre or post release."
)
parser
.
add_argument
(
"--post_release"
,
action
=
"store_true"
,
help
=
"Whether this is pre or post release."
)
...
@@ -190,6 +151,6 @@ if __name__ == "__main__":
...
@@ -190,6 +151,6 @@ if __name__ == "__main__":
if
not
args
.
post_release
:
if
not
args
.
post_release
:
pre_release_work
(
patch
=
args
.
patch
)
pre_release_work
(
patch
=
args
.
patch
)
elif
args
.
patch
:
elif
args
.
patch
:
p
ost_patch_work
(
)
p
rint
(
"Nothing to do after a patch :-)"
)
else
:
else
:
post_release_work
()
post_release_work
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment