-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfetch_and_bump_version.py
More file actions
27 lines (20 loc) · 921 Bytes
/
fetch_and_bump_version.py
File metadata and controls
27 lines (20 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import requests
def get_incremented_version(package_name: str) -> str:
try:
url = f"https://pypi.org/pypi/{package_name}/json"
response = requests.get(url)
response.raise_for_status()
data = response.json()
latest_version = data['info']['version']
version_parts = latest_version.split('.')
# Convert last part to int and increment
version_parts[-1] = str(int(version_parts[-1]) + 1)
incremented_version = '.'.join(version_parts)
return incremented_version
except requests.exceptions.RequestException as e:
print(f"Failed to fetch version for package '{package_name}': {e}")
except Exception as e:
print(f"Error processing version: {e}")
return "0.0.1"
if __name__ == "__main__":
print(get_incremented_version("extliner")) # Example usage, replace with your package name