You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/09/17 20:34:47 UTC

[GitHub] [airflow] kaxil commented on a change in pull request #18335: Added more automation on latest version

kaxil commented on a change in pull request #18335:
URL: https://github.com/apache/airflow/pull/18335#discussion_r711335628



##########
File path: scripts/ci/pre_commit/pre_commit_update_versions.py
##########
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import glob
+import json
+import os
+import re
+from os.path import abspath, dirname, join
+from re import Pattern
+
+import httpx
+
+AIRFLOW_SOURCES_DIR = abspath(join(dirname(__file__), os.pardir, os.pardir, os.pardir))
+
+
+def update_version(pattern: Pattern, version: str, file_path: str):
+    print(f"Replacing {pattern} to {version} in {file_path}")
+    with open(file_path, "r+") as f:
+        file_contents = f.read()
+        lines = file_contents.splitlines(keepends=True)
+        for i in range(0, len(lines)):
+            lines[i] = re.sub(pattern, fr'\g<1>{version}\g<2>', lines[i])
+        file_contents = "".join(lines)
+        f.seek(0)
+        f.truncate()
+        f.write(file_contents)
+
+
+REPLACEMENTS = {
+    r'(FROM apache/airflow:).*($)': "docs/docker-stack/docker-examples/extending/*/Dockerfile",
+    r'(apache/airflow:)[^-]*(\-)': "docs/docker-stack/entrypoint.rst",
+    r'(/constraints-)[^-]*(/constraints)': "docs/docker-stack/docker-examples/"
+    "restricted/restricted_environments.sh",
+    r'(AIRFLOW_VERSION=")[^"]*(" \\)': "docs/docker-stack/docker-examples/"
+    "restricted/restricted_environments.sh",
+}
+
+if __name__ == '__main__':
+    airflow_pypi_info = json.loads(httpx.get("https://pypi.org/pypi/apache-airflow/json").text)

Review comment:
       This will fail even before we release as for example when releasing `2.1.4`, this will use `2.1.3` instead as 2.1.4 won't be available until I push it.
   
   I think this should match version in `setup.py` and just maintain a list of all the files that needs to be updated when the version is updated in setup.py. And if it contains "dev" in the version, it can then use `https://pypi.org/pypi/apache-airflow/json`




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org