poorvirohidekar commented on code in PR #38447:
URL: https://github.com/apache/airflow/pull/38447#discussion_r1537206701


##########
dev/breeze/src/airflow_breeze/commands/release_management_commands.py:
##########
@@ -949,6 +950,70 @@ def run_generate_constraints_in_parallel(
     )
 
 
+@release_management.command(
+    name="tag-providers",
+    help="Generates tags for providers.",

Review Comment:
   Ack



##########
dev/breeze/src/airflow_breeze/commands/release_management_commands.py:
##########
@@ -949,6 +950,70 @@ def run_generate_constraints_in_parallel(
     )
 
 
+@release_management.command(
+    name="tag-providers",
+    help="Generates tags for providers.",
+)
+@option_dry_run
+@option_verbose
+def tag_providers():
+    found_remote = None
+    remotes = ["origin", "apache"]
+    for remote in remotes:
+        try:
+            command = ["git", "remote", "get-url", "--push", 
shlex.quote(remote)]
+            result = subprocess.run(command, stdout=subprocess.PIPE, 
stderr=subprocess.DEVNULL, text=True)
+            if "apache/airflow.git" in result.stdout:
+                found_remote = remote
+                break
+        except subprocess.CalledProcessError:
+            pass
+
+    if found_remote is None:
+        raise ValueError("Could not find remote configured to push to 
apache/airflow")
+
+    tags = []
+    for file in os.listdir(os.path.join(SOURCE_DIR_PATH, "dist")):
+        if file.endswith(".whl"):
+            match = re.match(r".*airflow_providers_(.*)-(.*)-py3.*", file)
+            if match:
+                provider = f"providers-{match.group(1).replace('_', '-')}"
+                tag = f"{provider}/{match.group(2)}"
+                try:
+                    subprocess.run(
+                        ["git", "tag", shlex.quote(tag), "-m", f"Release 
{date.today()} of providers"],
+                        check=True,
+                    )
+                    tags.append(tag)
+                except subprocess.CalledProcessError:
+                    pass
+
+    if tags and len(tags) > 0:
+        try:
+            push_command = ["git", "push", remote] + [shlex.quote(tag) for tag 
in tags]
+            push_result = subprocess.Popen(
+                push_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, 
text=True
+            )
+            push_output, push_error = push_result.communicate()
+            if push_output:
+                print(push_output)
+            if push_error:
+                print(push_error)
+            print("Tags pushed successfully")

Review Comment:
   Ack.



-- 
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]

Reply via email to