Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/scripts/update-version-patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash -e

sed -i "/\[stable\]/{n;s/version=.*/version=$1/}" eachdist.ini
sed -i "/\[prerelease\]/{n;s/version=.*/version=$2/}" eachdist.ini

./scripts/eachdist.py update_patch_versions --versions $1,$2,$3,$4
6 changes: 5 additions & 1 deletion .github/workflows/prepare-patch-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ jobs:
exit 1
fi

stable_version_prev="$stable_major_minor.$((stable_patch))"
unstable_version_prev="0.${unstable_minor}b$((unstable_patch))"
stable_version="$stable_major_minor.$((stable_patch + 1))"
unstable_version="0.${unstable_minor}b$((unstable_patch + 1))"

echo "STABLE_VERSION=$stable_version" >> $GITHUB_ENV
echo "UNSTABLE_VERSION=$unstable_version" >> $GITHUB_ENV
echo "STABLE_VERSION_PREV=$stable_version_prev" >> $GITHUB_ENV
echo "UNSTABLE_VERSION_PREV=$unstable_version_prev" >> $GITHUB_ENV

- name: Update version
run: .github/scripts/update-version.sh $STABLE_VERSION $UNSTABLE_VERSION
run: .github/scripts/update-version-patch.sh $STABLE_VERSION $UNSTABLE_VERSION $STABLE_VERSION_PREV $UNSTABLE_VERSION_PREV

- name: Update the change log with the approximate release date
run: |
Expand Down
47 changes: 47 additions & 0 deletions scripts/eachdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ def setup_instparser(instparser):
"releaseargs", nargs=argparse.REMAINDER, help=extraargs_help("pytest")
)

patchreleaseparser = subparsers.add_parser(
"update_patch_versions",
help="Updates version numbers during patch release, used by maintainers and CI",
)
patchreleaseparser.set_defaults(func=patch_release_args)
patchreleaseparser.add_argument("--versions", required=True)

fmtparser = subparsers.add_parser(
"format",
help="Formats all source code with black and isort.",
Expand Down Expand Up @@ -599,6 +606,23 @@ def update_dependencies(targets, version, packages):
)


def update_patch_dependencies(targets, version, prev_version, packages):
print("updating patch dependencies")
# PEP 508 allowed specifier operators
operators = ["==", "!=", "<=", ">=", "<", ">", "===", "~=", "="]
operators_pattern = "|".join(re.escape(op) for op in operators)

for pkg in packages:
search = rf"({basename(pkg)}[^,]*)(\s?({operators_pattern})\s?)(.*{prev_version})"
replace = r"\1\2 " + version
update_files(
targets,
"pyproject.toml",
search,
replace,
)


def update_files(targets, filename, search, replace):
errors = False
for target in targets:
Expand Down Expand Up @@ -640,6 +664,29 @@ def release_args(args):
update_version_files(targets, version, packages)


def patch_release_args(args):
print("preparing patch release")

rootpath = find_projectroot()
targets = list(find_targets_unordered(rootpath))
cfg = ConfigParser()
cfg.read(str(find_projectroot() / "eachdist.ini"))
versions = args.versions.split(",")
# stable
mcfg = cfg["stable"]
packages = mcfg["packages"].split()
print(f"update stable packages to {versions[0]}")
update_patch_dependencies(targets, versions[0], versions[2], packages)
update_version_files(targets, versions[0], packages)

# prerelease
mcfg = cfg["prerelease"]
packages = mcfg["packages"].split()
print(f"update prerelease packages to {versions[1]}")
update_patch_dependencies(targets, versions[1], versions[3], packages)
update_version_files(targets, versions[1], packages)


def test_args(args):
clean_remainder_args(args.pytestargs)
execute_args(
Expand Down
Loading