From 625bdad3bc00fb9e21c85a9c4bf958e8e921781a Mon Sep 17 00:00:00 2001 From: SandeepArup <61278421+SandeepArup@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:09:21 +0530 Subject: [PATCH] GSAGH-538 - increase version number to 1.2.1 (#116) * GSAGH-538 - increase version number to 1.2.1 * feat: added script to update the version of the files --------- Co-authored-by: spsarras --- BumpVersion.ps1 | 82 ++++++++++++++++++++++++++++++ GH_UnitNumber/GH_UnitNumber.csproj | 2 +- OasysGH/OasysGH.csproj | 4 +- OasysGH/OasysPluginInfo.cs | 2 +- 4 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 BumpVersion.ps1 diff --git a/BumpVersion.ps1 b/BumpVersion.ps1 new file mode 100644 index 0000000..463b7be --- /dev/null +++ b/BumpVersion.ps1 @@ -0,0 +1,82 @@ + +function Has-Version { + param ($version) + + # Check if the version argument is provided + if ($version.Count -eq 0) { + Write-Host "Please provide the version number as an argument. Usage: .\bump-version.ps1 " + exit + } + + # Get the new version from the CLI argument + return $version[0] +} + +$newVersion = Has-Version($args) + +# Function to validate the version format (X.X.X where X is a number) +function Validate-VersionFormat { + param ( + [string]$version + ) + + # Regex pattern for validating version format (X.X.X) + $versionPattern = '^\d+\.\d+\.\d+$' + + # Check if version matches the pattern + return $version -match $versionPattern +} + +# Function to update version in a file +function Update-Version { + param ( + [string]$filePath, + [string]$searchPattern, + [string]$newVersion, + [string]$replacementPattern + ) + + # Read the content of the file + $content = Get-Content $filePath + + # Replace the version based on the provided pattern and replacement + $updatedContent = $content -replace $searchPattern, $replacementPattern + + # Write the updated content back to the file + Set-Content $filePath -Value $updatedContent + + Write-Host "Updated version in $filePath to $newVersion" +} + +# Check if the version format is valid +if (-not (Validate-VersionFormat $newVersion)) { + Write-Host "Invalid version format. Please use the format: X.X.X where X is a number." + exit +} + +# Define the paths and patterns for each file +$filesToUpdate = @( + @{ + FilePath = ".\OasysGH\OasysGH.csproj" + SearchPattern = '(.*?)<\/Version>' + ReplacementPattern = "$newVersion" + }, + @{ + FilePath = ".\GH_UnitNumber\GH_UnitNumber.csproj" + SearchPattern = '(.*?)<\/Version>' + ReplacementPattern = "$newVersion" + }, + @{ + FilePath = ".\OasysGH\OasysPluginInfo.cs" + SearchPattern = 'Version = "(.*?)"' + ReplacementPattern = 'Version = "' + $newVersion + '"' + } +) + +# Loop through each file and update the version +foreach ($file in $filesToUpdate) { + Update-Version -filePath $file.FilePath -searchPattern $file.SearchPattern -newVersion $newVersion -replacementPattern $file.ReplacementPattern +} + +Write-Host "Version update completed." + diff --git a/GH_UnitNumber/GH_UnitNumber.csproj b/GH_UnitNumber/GH_UnitNumber.csproj index 5b2585f..eba756c 100644 --- a/GH_UnitNumber/GH_UnitNumber.csproj +++ b/GH_UnitNumber/GH_UnitNumber.csproj @@ -10,7 +10,7 @@ https://github.com/arup-group/OasysGH README.md UnitNumberLogo64.png - 1.2.0 + 1.2.1 MIT bin\ True diff --git a/OasysGH/OasysGH.csproj b/OasysGH/OasysGH.csproj index 4d889f4..445c30b 100644 --- a/OasysGH/OasysGH.csproj +++ b/OasysGH/OasysGH.csproj @@ -9,12 +9,12 @@ https://github.com/arup-group/OasysGH https://github.com/arup-group/OasysGH README.md - 1.2.0 + 1.2.1 MIT false 8.0 OasysGH is a library with shared content for Oasys Grasshopper plugins. - This is a release of OasysGH 1.2.0. + This is a release of OasysGH 1.2.1. oasys;grasshopper True ..\OasysGH.snk diff --git a/OasysGH/OasysPluginInfo.cs b/OasysGH/OasysPluginInfo.cs index 72016aa..dfa2dfd 100644 --- a/OasysGH/OasysPluginInfo.cs +++ b/OasysGH/OasysPluginInfo.cs @@ -5,7 +5,7 @@ public static class OasysGHVersion { public const bool IsBeta = false; // this is the one place to set the version in VS: // also update the version manually in OasysGH.csproj - public const string Version = "1.2.0"; + public const string Version = "1.2.1"; } public class OasysPluginInfo {