-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase major version on definition new Major version - #23
- Loading branch information
1 parent
e4dc343
commit 4721a8d
Showing
4 changed files
with
65 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import requests | ||
import xml.etree.ElementTree as ET | ||
|
||
url = 'https://raw.githubusercontent.com/angularsen/UnitsNet/master/UnitsNet/UnitsNet.csproj' | ||
|
||
try: | ||
response = requests.get(url) | ||
response.raise_for_status() # Raise an exception for HTTP errors | ||
|
||
xml = response.text | ||
root = ET.fromstring(xml) | ||
|
||
# Assuming the structure of the XML is consistent with the example | ||
version = root.find('.//PropertyGroup/Version').text | ||
print(version) | ||
|
||
except requests.exceptions.RequestException as e: | ||
print('Error fetching the URL:', e) | ||
except ET.ParseError as e: | ||
print('Error parsing XML:', e) | ||
except Exception as e: | ||
print('Error:', e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import sys | ||
|
||
# Function to parse version string to major, minor, patch | ||
def parse_version(version): | ||
major, minor, patch = map(int, version.split('.')) | ||
return {'major': major, 'minor': minor, 'patch': patch} | ||
|
||
# Function to increment the version | ||
def increment_version(current_version, definition_version, current_definition_version): | ||
current = parse_version(current_version) | ||
definition = parse_version(definition_version) | ||
current_definition = parse_version(current_definition_version) | ||
|
||
if current_definition['major'] > definition['major']: | ||
# Increment major version | ||
return f"{current['major'] + 1}.0.0" | ||
else: | ||
# Increment patch version | ||
return f"{current['major']}.{current['minor']}.{current['patch'] + 1}" | ||
|
||
# Get the current version from command line arguments | ||
if len(sys.argv) < 4: | ||
print('Please provide the current version, definition version, and current definition version as arguments.') | ||
sys.exit(1) | ||
|
||
current_version, definition_version, current_definition_version = sys.argv[1:4] | ||
|
||
new_version = increment_version(current_version, definition_version, current_definition_version) | ||
print(new_version) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters