Created
April 17, 2019 07:04
-
-
Save rasmuseeg/f037fa631724530487f4497120a73d24 to your computer and use it in GitHub Desktop.
Increment clientdependency.config version during continues deployment
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
param( | |
[Parameter(Position=0, | |
HelpMessage="Path to your project.")] | |
[ValidateNotNullOrEmpty()] | |
[string] | |
$ProjectPath = "..\DanskBilglas.UmbracoCMS\Config\", | |
[Parameter(Position=1, | |
HelpMessage="Name of your client dependency config (default: ClientDependency.config)")] | |
[string] | |
$FileName = 'ClientDependency.config', | |
# Parameter help description | |
[Parameter(Mandatory=$true, Position=2)] | |
[bool] | |
$CommitAndPush = $false | |
) | |
$returnLocation = (Get-Location).Path; | |
Set-Location -Path $ProjectPath | |
$filePath = "$FileName"; | |
$xdoc = [System.Xml.XmlDocument](Get-Content "$filePath"); | |
$clientDependencyNode = $xdoc.SelectSingleNode('clientDependency'); | |
[string]$strVersion = $clientDependencyNode.GetAttribute('version'); | |
[int]$version = [convert]::ToInt32($strVersion); | |
$version = $version + 1; | |
$clientDependencyNode.SetAttribute('version', $version); | |
$savePath = (Get-Location).Path + "\$filePath"; | |
$xdoc.Save($savePath) | |
if($CommitAndPush -eq $true) | |
{ | |
git add $filePath | |
git commit -m "Incremented ClientDependency Version: $version"; | |
git push | |
} | |
Set-Location -Path $returnLocation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment