Skip to content

Commit

Permalink
GSAGH-538 - increase version number to 1.2.1 (#116)
Browse files Browse the repository at this point in the history
* GSAGH-538 - increase version number to 1.2.1

* feat: added script to update the version of the files

---------

Co-authored-by: spsarras <[email protected]>
  • Loading branch information
SandeepArup and psarras authored Sep 27, 2024
1 parent 9081f9a commit 625bdad
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 4 deletions.
82 changes: 82 additions & 0 deletions BumpVersion.ps1
Original file line number Diff line number Diff line change
@@ -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 <new-version>"
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>(.*?)<\/Version>'
ReplacementPattern = "<Version>$newVersion</Version>"
},
@{
FilePath = ".\GH_UnitNumber\GH_UnitNumber.csproj"
SearchPattern = '<Version>(.*?)<\/Version>'
ReplacementPattern = "<Version>$newVersion</Version>"
},
@{
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."

2 changes: 1 addition & 1 deletion GH_UnitNumber/GH_UnitNumber.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<RepositoryUrl>https://github.com/arup-group/OasysGH</RepositoryUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>UnitNumberLogo64.png</PackageIcon>
<Version>1.2.0</Version>
<Version>1.2.1</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<BaseOutputPath>bin\</BaseOutputPath>
<AutoGenerateBindingRedirects>True</AutoGenerateBindingRedirects>
Expand Down
4 changes: 2 additions & 2 deletions OasysGH/OasysGH.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<PackageProjectUrl>https://github.com/arup-group/OasysGH</PackageProjectUrl>
<RepositoryUrl>https://github.com/arup-group/OasysGH</RepositoryUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>1.2.0</Version>
<Version>1.2.1</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<LangVersion>8.0</LangVersion>
<Description>OasysGH is a library with shared content for Oasys Grasshopper plugins.</Description>
<PackageReleaseNotes>This is a release of OasysGH 1.2.0.</PackageReleaseNotes>
<PackageReleaseNotes>This is a release of OasysGH 1.2.1.</PackageReleaseNotes>
<PackageTags>oasys;grasshopper</PackageTags>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\OasysGH.snk</AssemblyOriginatorKeyFile>
Expand Down
2 changes: 1 addition & 1 deletion OasysGH/OasysPluginInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 625bdad

Please sign in to comment.