mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-29 13:12:39 +08:00
Fix prepare patch release workflow (#3013)
This commit is contained in:
11
.github/scripts/update-version-patch.sh
vendored
Executable file
11
.github/scripts/update-version-patch.sh
vendored
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/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 \
|
||||||
|
--stable_version=$1 \
|
||||||
|
--unstable_version=$2 \
|
||||||
|
--stable_version_prev=$3 \
|
||||||
|
--unstable_version_prev=$4
|
||||||
|
|
6
.github/workflows/prepare-patch-release.yml
vendored
6
.github/workflows/prepare-patch-release.yml
vendored
@ -40,14 +40,18 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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))"
|
stable_version="$stable_major_minor.$((stable_patch + 1))"
|
||||||
unstable_version="0.${unstable_minor}b$((unstable_patch + 1))"
|
unstable_version="0.${unstable_minor}b$((unstable_patch + 1))"
|
||||||
|
|
||||||
echo "STABLE_VERSION=$stable_version" >> $GITHUB_ENV
|
echo "STABLE_VERSION=$stable_version" >> $GITHUB_ENV
|
||||||
echo "UNSTABLE_VERSION=$unstable_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
|
- 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: Set up Python 3.9
|
- name: Set up Python 3.9
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
|
@ -237,6 +237,16 @@ def parse_args(args=None):
|
|||||||
"releaseargs", nargs=argparse.REMAINDER, help=extraargs_help("pytest")
|
"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("--stable_version", required=True)
|
||||||
|
patchreleaseparser.add_argument("--unstable_version", required=True)
|
||||||
|
patchreleaseparser.add_argument("--stable_version_prev", required=True)
|
||||||
|
patchreleaseparser.add_argument("--unstable_version_prev", required=True)
|
||||||
|
|
||||||
fmtparser = subparsers.add_parser(
|
fmtparser = subparsers.add_parser(
|
||||||
"format",
|
"format",
|
||||||
help="Formats all source code with black and isort.",
|
help="Formats all source code with black and isort.",
|
||||||
@ -655,6 +665,24 @@ 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"\g<1>\g<2>" + version
|
||||||
|
print(f"{search=}\t{replace=}\t{pkg=}")
|
||||||
|
update_files(
|
||||||
|
targets,
|
||||||
|
"pyproject.toml",
|
||||||
|
search,
|
||||||
|
replace,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def update_files(targets, filename, search, replace):
|
def update_files(targets, filename, search, replace):
|
||||||
errors = False
|
errors = False
|
||||||
for target in targets:
|
for target in targets:
|
||||||
@ -707,6 +735,32 @@ def release_args(args):
|
|||||||
update_changelogs("-".join(updated_versions))
|
update_changelogs("-".join(updated_versions))
|
||||||
|
|
||||||
|
|
||||||
|
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"))
|
||||||
|
# stable
|
||||||
|
mcfg = cfg["stable"]
|
||||||
|
packages = mcfg["packages"].split()
|
||||||
|
print(f"update stable packages to {args.stable_version}")
|
||||||
|
update_patch_dependencies(
|
||||||
|
targets, args.stable_version, args.stable_version_prev, packages
|
||||||
|
)
|
||||||
|
update_version_files(targets, args.stable_version, packages)
|
||||||
|
|
||||||
|
# prerelease
|
||||||
|
mcfg = cfg["prerelease"]
|
||||||
|
packages = mcfg["packages"].split()
|
||||||
|
print(f"update prerelease packages to {args.unstable_version}")
|
||||||
|
update_patch_dependencies(
|
||||||
|
targets, args.unstable_version, args.unstable_version_prev, packages
|
||||||
|
)
|
||||||
|
update_version_files(targets, args.unstable_version, packages)
|
||||||
|
|
||||||
|
|
||||||
def test_args(args):
|
def test_args(args):
|
||||||
clean_remainder_args(args.pytestargs)
|
clean_remainder_args(args.pytestargs)
|
||||||
execute_args(
|
execute_args(
|
||||||
|
Reference in New Issue
Block a user