Skip to content

Commit

Permalink
Update module versioning CI process (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
BernieWhite authored Jun 2, 2019
1 parent 81691fe commit 18ee54c
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions pipeline.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,32 @@ if ($Env:coverage -eq 'true') {
$CodeCoverage = $True;
}

if ($Env:BUILD_SOURCEBRANCH -contains '/tags/' -and $Env:BUILD_SOURCEBRANCHNAME -like "v0.*") {
if ($Env:BUILD_SOURCEBRANCH -like '*/tags/*' -and $Env:BUILD_SOURCEBRANCHNAME -like 'v0.*') {
$ModuleVersion = $Env:BUILD_SOURCEBRANCHNAME.Substring(1);
}

if (![String]::IsNullOrEmpty($ReleaseVersion)) {
Write-Host -Object "[Pipeline] -- ReleaseVersion: $ReleaseVersion" -ForegroundColor Green;
$ModuleVersion = $ReleaseVersion;
}

Write-Host -Object "[Pipeline] -- ModuleVersion: $ModuleVersion" -ForegroundColor Green;

$version = $ModuleVersion;
$versionSuffix = [String]::Empty;

if ($version -like '*-*') {
[String[]]$versionParts = $version.Split('-', [System.StringSplitOptions]::RemoveEmptyEntries);
$version = $versionParts[0];

if ($versionParts.Length -eq 2) {
$versionSuffix = $versionParts[1];
}
}

Write-Host -Object "[Pipeline] -- Using version: $version" -ForegroundColor Green;
Write-Host -Object "[Pipeline] -- Using versionSuffix: $versionSuffix" -ForegroundColor Green;

# Copy the PowerShell modules files to the destination path
function CopyModuleFiles {

Expand Down Expand Up @@ -123,39 +143,19 @@ task Clean {
}

task VersionModule {
if (![String]::IsNullOrEmpty($ReleaseVersion)) {
Write-Verbose -Message "[VersionModule] -- ReleaseVersion: $ReleaseVersion";
$ModuleVersion = $ReleaseVersion;
}

if (![String]::IsNullOrEmpty($ModuleVersion)) {
Write-Verbose -Message "[VersionModule] -- ModuleVersion: $ModuleVersion";

$version = $ModuleVersion;
$revision = [String]::Empty;

Write-Verbose -Message "[VersionModule] -- Using Version: $version";
Write-Verbose -Message "[VersionModule] -- Using Revision: $revision";

if ($version -like '*-*') {
[String[]]$versionParts = $version.Split('-', [System.StringSplitOptions]::RemoveEmptyEntries);
$version = $versionParts[0];

if ($versionParts.Length -eq 2) {
$revision = $versionParts[1];
}
}

# Update module version
if (![String]::IsNullOrEmpty($version)) {
Write-Verbose -Message "[VersionModule] -- Updating module manifest ModuleVersion";
Update-ModuleManifest -Path (Join-Path -Path $ArtifactPath -ChildPath PSRule/PSRule.psd1) -ModuleVersion $version;
}

# Update pre-release version
if (![String]::IsNullOrEmpty($revision)) {
if (![String]::IsNullOrEmpty($versionSuffix)) {
Write-Verbose -Message "[VersionModule] -- Updating module manifest Prerelease";
Update-ModuleManifest -Path (Join-Path -Path $ArtifactPath -ChildPath PSRule/PSRule.psd1) -Prerelease $revision;
Update-ModuleManifest -Path (Join-Path -Path $ArtifactPath -ChildPath PSRule/PSRule.psd1) -Prerelease $versionSuffix;
}
}
}
Expand Down

0 comments on commit 18ee54c

Please sign in to comment.