potiuk commented on code in PR #36930:
URL: https://github.com/apache/airflow/pull/36930#discussion_r1462455778
##########
dev/breeze/src/airflow_breeze/commands/release_management_commands.py:
##########
@@ -2394,3 +2395,270 @@ def prepare_python_client(
finally:
if version_suffix_for_pypi:
VERSION_FILE.write_text(original_version)
+
+
+def _get_latest_airflow_version_from_pypi():
+ import requests
+
+ response = requests.get("https://pypi.org/pypi/apache-airflow/json")
+ response.raise_for_status()
+ return response.json()["info"]["version"]
+
+
+CHART_DIR = AIRFLOW_SOURCES_ROOT / "chart"
+CHART_YAML_FILE = CHART_DIR / "Chart.yaml"
+
+
+@release_management.command(name="prepare-helm-chart-tarball", help="Prepares
helm chart tarball.")
[email protected](
+ "--version",
+ help="Version used for helm chart. This version has to be set and has to
match the version in "
+ "Chart.yaml, unless the --ignore-version-check flag is used.",
+ envvar="VERSION",
+)
[email protected](
+ "--version-suffix",
+ help="Version suffix used to publish the package. Needs to be present as
we always build "
+ "archive using release candidate tag.",
+ required=True,
+ envvar="VERSION_SUFFIX",
+)
[email protected](
+ "--ignore-version-check",
+ is_flag=True,
+ help="Ignores result of version update check. Produce tarball regardless
of "
+ "whether version is correctly set in the Chart.yaml.",
+)
[email protected](
+ "--skip-tagging",
+ is_flag=True,
+ help="Skip tagging the chart. Useful if the tag is already created, or
when you verify the chart.",
+)
[email protected](
+ "--skip-tag-signing",
+ is_flag=True,
+ help="Skip signing the tag. Useful for CI where we just tag without
signing the tag.",
+)
[email protected](
+ "--override-tag",
+ is_flag=True,
+ help="Override tag if it already exists. Useful when you want to re-create
the tag, usually when you"
+ "test the breeze command locally.",
+)
+@option_dry_run
+@option_verbose
+def prepare_helm_chart_tarball(
+ version: str | None,
+ version_suffix: str,
+ ignore_version_check: bool,
+ override_tag: bool,
+ skip_tagging: bool,
+ skip_tag_signing: bool,
+) -> None:
+ import yaml
+
+ chart_yaml_file_content = CHART_YAML_FILE.read_text()
+ chart_yaml_dict = yaml.safe_load(chart_yaml_file_content)
+ version_in_chart = chart_yaml_dict["version"]
+ airflow_version_in_chart = chart_yaml_dict["appVersion"]
+ airflow_version_from_pypi = _get_latest_airflow_version_from_pypi()
+ if ignore_version_check:
+ if not version:
+ version = version_in_chart
+ else:
+ if not version or not version_suffix:
+ get_console().print(
+ "[error]You need to provide --version and --version-suffix
parameter unless you "
+ "use --ignore-version-check[/]"
+ )
+ sys.exit(1)
+ get_console().print(f"[info]Latest Airflow version from PyPI:
{airflow_version_from_pypi}[/]")
+ get_console().print(f"[info]Airflow version in chart:
{airflow_version_in_chart}[/]")
+ updating = False
+ if version_in_chart != version:
+ get_console().print(
+ f"[warning]Version in chart.yaml ({version_in_chart}) does not
match the version "
+ f"passed as parameter ({version}). Updating[/]"
+ )
+ updating = True
+ chart_yaml_file_content = chart_yaml_file_content.replace(
+ f"version: {version_in_chart}", f"version: {version}"
+ )
+ else:
+ get_console().print(f"[success]Version in chart.yaml is good:
{version}[/]")
+ if airflow_version_from_pypi != airflow_version_in_chart:
+ get_console().print(
+ f"[warning]Airflow version in chart.yaml
({airflow_version_in_chart}) does not match the "
Review Comment:
Resolving then. Rebase to apply just merged main fix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]