mirror of
https://github.com/saymrwulf/cryptography.git
synced 2026-05-14 20:37:55 +00:00
parent
581b928a86
commit
36368cc056
2 changed files with 24 additions and 9 deletions
|
|
@ -70,6 +70,7 @@ ssh = ["bcrypt >=3.1.5"]
|
|||
# All the following are used for our own testing.
|
||||
nox = ["nox"]
|
||||
test = [
|
||||
"cryptography_vectors",
|
||||
"pytest >=6.2.0",
|
||||
"pytest-benchmark",
|
||||
"pytest-cov",
|
||||
|
|
|
|||
32
release.py
32
release.py
|
|
@ -38,23 +38,24 @@ def release() -> None:
|
|||
run("git", "push", "--tags", "git@github.com:pyca/cryptography.git")
|
||||
|
||||
|
||||
def replace_version(
|
||||
p: pathlib.Path, variable_name: str, new_version: str
|
||||
) -> None:
|
||||
def replace_pattern(p: pathlib.Path, pattern: str, replacement: str) -> None:
|
||||
content = p.read_text()
|
||||
|
||||
pattern = rf"^{variable_name}\s*=\s*.*$"
|
||||
match = re.search(pattern, content, re.MULTILINE)
|
||||
assert match is not None
|
||||
|
||||
start, end = match.span()
|
||||
new_content = (
|
||||
content[:start] + f'{variable_name} = "{new_version}"' + content[end:]
|
||||
)
|
||||
|
||||
new_content = content[:start] + replacement + content[end:]
|
||||
p.write_text(new_content)
|
||||
|
||||
|
||||
def replace_version(
|
||||
p: pathlib.Path, variable_name: str, new_version: str
|
||||
) -> None:
|
||||
replace_pattern(
|
||||
p, rf"^{variable_name}\s*=\s*.*$", f'{variable_name} = "{new_version}"'
|
||||
)
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.argument("new_version")
|
||||
def bump_version(new_version: str) -> None:
|
||||
|
|
@ -75,6 +76,19 @@ def bump_version(new_version: str) -> None:
|
|||
new_version,
|
||||
)
|
||||
|
||||
if Version(new_version).is_prerelease:
|
||||
replace_pattern(
|
||||
base_dir / "pyproject.toml",
|
||||
r'"cryptography_vectors(==.*?)?"',
|
||||
'"cryptography_vectors"',
|
||||
)
|
||||
else:
|
||||
replace_pattern(
|
||||
base_dir / "pyproject.toml",
|
||||
r'"cryptography_vectors(==.*?)?"',
|
||||
f'"cryptography_vectors=={new_version}"',
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
|
|
|
|||
Loading…
Reference in a new issue