-
Notifications
You must be signed in to change notification settings - Fork 9
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 - #45
- Loading branch information
1 parent
cf5defc
commit c7618e3
Showing
5 changed files
with
147 additions
and
8 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
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,28 @@ | ||
const axios = require('axios'); | ||
const xml2js = require('xml2js'); | ||
|
||
const url = 'https://raw.githubusercontent.com/angularsen/UnitsNet/master/UnitsNet/UnitsNet.csproj'; | ||
|
||
axios.get(url) | ||
.then(response => { | ||
const xml = response.data; | ||
xml2js.parseString(xml, (err, result) => { | ||
if (err) { | ||
exit(1); | ||
console.error('Error parsing XML:', err); | ||
process.exit(1); | ||
} | ||
|
||
try { | ||
const version = result.Project.PropertyGroup[0].Version[0]; | ||
console.log(version); | ||
} catch (e) { | ||
console.error('Error extracting version:', e); | ||
process.exit(1); | ||
} | ||
}); | ||
}) | ||
.catch(error => { | ||
console.error('Error fetching the URL:', error); | ||
process.exit(1); | ||
}); |
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,31 @@ | ||
// Function to parse version string to major, minor, patch | ||
const parseVersion = (version) => { | ||
const [major, minor, patch] = version.split('.').map(Number); | ||
return { major, minor, patch }; | ||
}; | ||
|
||
// Function to increment the version | ||
const incrementVersion = (currentVersion, definitionVersion, currentDefinitionVersion) => { | ||
const current = parseVersion(currentVersion); | ||
const definition = parseVersion(definitionVersion); | ||
const currentDefinition = parseVersion(currentDefinitionVersion); | ||
|
||
if (currentDefinition.major > definition.major) { | ||
// Increment major version | ||
return `${current.major + 1}.0.0`; | ||
} else { | ||
// Increment patch version | ||
return `${current.major}.${current.minor}.${current.patch + 1}`; | ||
} | ||
}; | ||
|
||
// Get the current version from command line arguments | ||
const [currentVersion, definitionVersion, currentDefinitionVersion] = process.argv.slice(2); | ||
|
||
if (!currentVersion || !definitionVersion || !currentDefinitionVersion) { | ||
console.error('Please provide the current version & definition version & current definition version as an argument.'); | ||
process.exit(1); | ||
} | ||
|
||
const newVersion = incrementVersion(currentVersion, definitionVersion, currentDefinitionVersion); | ||
console.log(newVersion); |
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