Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow path pattern to be specified in package_release_tasks.py. #20650

Merged
Merged
Changes from all 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
20 changes: 14 additions & 6 deletions tools/ci_build/github/apple/package_release_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import annotations

import argparse
import glob
import os
import shlex
import subprocess
Expand Down Expand Up @@ -50,6 +51,15 @@ def update_podspec(pod_archive_path: Path, podspec_path: Path):
podspec_path.write_text(podspec_content)


def _resolve_single_path_from_pattern(path_pattern: str) -> Path:
matches = glob.glob(path_pattern)
if len(matches) != 1:
raise argparse.ArgumentTypeError(
f"Expected exactly 1 match for pattern '{path_pattern}' but got {len(matches)} matches."
)
return Path(matches[0]).resolve(strict=True)


def _parse_args():
parser = argparse.ArgumentParser(
description="Helper script to perform release tasks. "
Expand All @@ -58,14 +68,14 @@ def _parse_args():

parser.add_argument(
"--pod-archive-path",
type=Path,
help="Pod archive path.",
type=_resolve_single_path_from_pattern,
help="Pod archive path. It may be a pattern, in which case it must match exactly one path.",
)

parser.add_argument(
"--podspec-path",
type=Path,
help="Podspec path.",
type=_resolve_single_path_from_pattern,
help="Podspec path. It may be a pattern, in which case it must match exactly one path.",
)

parser.add_argument(
Expand All @@ -82,11 +92,9 @@ def _validate_args(
):
if require_pod_archive_path:
assert args.pod_archive_path is not None, "--pod-archive-path must be specified."
args.pod_archive_path = args.pod_archive_path.resolve(strict=True)

if require_podspec_path:
assert args.podspec_path is not None, "--podspec-path must be specified."
args.podspec_path = args.podspec_path.resolve(strict=True)


def main():
Expand Down
Loading