diff --git a/.github/workflows/update_etcd_versions.yaml b/.github/workflows/update_etcd_versions.yaml index 41859f0..7b11e4a 100644 --- a/.github/workflows/update_etcd_versions.yaml +++ b/.github/workflows/update_etcd_versions.yaml @@ -22,7 +22,7 @@ jobs: - name: Update version file run: | cd assets - python -m pip install requests + python -m pip install requests packaging python get_all_etcd_versions.py - name: Push updated version file diff --git a/assets/etcd_versions_from_gtihub_api.json b/assets/etcd_versions_from_github_api.json similarity index 100% rename from assets/etcd_versions_from_gtihub_api.json rename to assets/etcd_versions_from_github_api.json diff --git a/assets/get_all_etcd_versions.py b/assets/get_all_etcd_versions.py index cc5f41b..990fe18 100644 --- a/assets/get_all_etcd_versions.py +++ b/assets/get_all_etcd_versions.py @@ -1,24 +1,33 @@ import json import requests +from packaging.version import parse, InvalidVersion # fetch version: -> https://api.github.com/repos/etcd-io/etcd/tags?per_page=300&sort=pushed # github api has rate limt # prefer use local version file def update_all_version_from_github_api(): - url = "https://api.github.com/repos/etcd-io/etcd/tags?per_page=500&sort=pushed" - response = requests.get(url) - data = response.json() - print(data) - if response.status_code != 200: - print("Failed to fetch data from github api") - return + all_version = [] + for page in range(1,10): + url = f"https://api.github.com/repos/etcd-io/etcd/tags?per_page=100&sort=pushed&page={page}" + response = requests.get(url) + if response.status_code != 200: + print("Failed to fetch data from github api") + return + data = response.json() + all_version = all_version + data - with open("etcd_versions_from_gtihub_api.json", 'w', encoding="utf-8") as file: - json.dump(data, file, indent=4) + with open("etcd_versions_from_github_api.json", 'w', encoding="utf-8") as file: + json.dump(all_version, file, indent=4) + +def safe_version_parse(v): + try: + return parse(v) + except InvalidVersion: + return None def get_all_version(): version_set = set() - with open("etcd_versions_from_gtihub_api.json", 'r', encoding="utf-8") as file: + with open("etcd_versions_from_github_api.json", 'r', encoding="utf-8") as file: data = json.load(file) for item in data: if "refs/tags/v" not in item["tarball_url"]: @@ -29,7 +38,9 @@ def get_all_version(): if __name__ == "__main__": update_all_version_from_github_api() - version_set = get_all_version() + versions = list(get_all_version()) + versions = sorted((v for v in versions if safe_version_parse(v) is not None), key=safe_version_parse, reverse=True) + print(versions) with open("versions.txt", 'w') as file: - for version in version_set: - file.write(version + '\n') + for v in versions: + file.write(v + '\n') diff --git a/assets/versions.txt b/assets/versions.txt index fcf1d8a..ce6c8dc 100644 --- a/assets/versions.txt +++ b/assets/versions.txt @@ -1,100 +1,99 @@ -3.4.16 -3.3.14-rc.0 -3.3.18 -3.4.1 -3.3.7 +3.6.0-alpha.0 +3.5.13 +3.5.12 +3.5.11 +3.5.10 3.5.9 -3.4.15 -3.4.32 +3.5.8 +3.5.7 3.5.6 -3.4.30 -3.3.9_plus_git -3.4.27 -3.3.4 -3.4.0-rc.1 -3.3.21 -3.4.31 -3.4.20 -3.3.22 -3.5.1 -3.4.9 -3.4.29 -3.5.0-beta.2 +3.5.5 +3.5.4 3.5.3 -3.3.27 -3.3.17 -3.4.10 -3.3.9 -3.3.14-beta.0 -3.4.12 -3.4.13 +3.5.2 +3.5.1 3.5.0 -3.3.19 -3.4.22 +3.5.0-rc.1 3.5.0-rc.0 -3.6.0-alpha.0 -3.4.18 -3.3.25 -3.4.21 -3.3.13 -3.3.3 -3.5.13 +3.5.0-beta.4 +3.5.0-beta.3 +3.5.0-beta.2 +3.5.0-beta.1 +3.5.0-beta.0 +3.5.0-alpha.0 +3.4.32 +3.4.31 +3.4.30 +3.4.29 +3.4.28 +3.4.27 +3.4.26 +3.4.25 3.4.24 -3.3.5 -3.5.4 -3.3.20 +3.4.23 +3.4.22 +3.4.21 +3.4.20 +3.4.19 +3.4.18 +3.4.17 +3.4.16 +3.4.15 +3.4.14 +3.4.13 +3.4.12 +3.4.11 +3.4.10 +3.4.9 3.4.8 -3.5.7 -3.3.26 3.4.7 -3.4.19 -3.4.26 -3.5.0-beta.0 -3.5.10 -3.4.3 -3.5.0-beta.3 -3.4.23 -3.4.5 -3.5.12 -3.3.23 -3.4.25 3.4.6 -3.3.24 -3.5.2 -3.5.0-rc.1 -3.5.5 -3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