Skip to content

Commit

Permalink
chore: sort vfox search version
Browse files Browse the repository at this point in the history
  • Loading branch information
yeshan333 committed May 8, 2024
1 parent 497e893 commit a957a65
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/update_etcd_versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
37 changes: 24 additions & 13 deletions assets/get_all_etcd_versions.py
Original file line number Diff line number Diff line change
@@ -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"]:
Expand All @@ -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')
167 changes: 83 additions & 84 deletions assets/versions.txt
Original file line number Diff line number Diff line change
@@ -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.4.0-rc.2
3.3.15
3.3.0
3.3.16
3.3.0-rc.4
3.3.1
3.4.0-rc.3
3.2.32
3.4.0
3.3.0-rc.1
3.4.5
3.4.4
3.4.14
3.4.3
3.4.2
3.4.1
3.4.0
3.4.0-rc.4
3.3.6
3.5.8
3.4.0-rc.3
3.4.0-rc.2
3.4.0-rc.1
3.4.0-rc.0
3.3.27
3.3.26
3.3.25
3.3.24
3.3.23
3.3.22
3.3.21
3.3.20
3.3.19
3.3.18
3.3.17
3.3.16
3.3.15
3.3.14
3.3.0-rc.2
3.4.11
3.3.10
3.3.14-rc.0
3.3.14-beta.0
3.3.13
3.3.12
3.3.11
3.5.0-beta.4
3.3.10
3.3.9
3.3.8
3.3.7
3.3.6
3.3.5
3.3.4
3.3.3
3.3.2
3.3.1
3.3.0
3.3.0-rc.4
3.3.0-rc.3
3.2.30
3.2.31
3.4.17
3.4.2
3.3.0-rc.2
3.3.0-rc.1
3.3.0-rc.0
3.5.0-beta.1
3.5.11
3.4.0-rc.0
3.4.28
3.3.2
3.5.0-alpha.0
3.3.8
3.2.32
3.2.31
3.2.30

0 comments on commit a957a65

Please sign in to comment.