forked from Azure/bicep-registry-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
136 additions
and
60 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
97 changes: 52 additions & 45 deletions
97
avm/utilities/pipelines/resourcePublish/Publish-ModuleFromTagToPBR.ps1
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 |
---|---|---|
@@ -1,64 +1,71 @@ | ||
function Publish-ModuleFromTagToPBR { | ||
|
||
<<<<<<< HEAD | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory = $true)] | ||
[string] $ModuleReleaseTagName, | ||
======= | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory = $true)] | ||
[string] $TemplateFilePath, | ||
>>>>>>> 5c6008414f381dd3a5a500006621d277859abb04 | ||
|
||
[Parameter(Mandatory = $true)] | ||
[secureString] $PublicRegistryServer | ||
) | ||
[Parameter(Mandatory = $true)] | ||
[secureString] $PublicRegistryServer | ||
) | ||
|
||
# Load used functions | ||
. (Join-Path $PSScriptRoot 'helper' 'Test-ModuleQualifiesForPublish.ps1') | ||
. (Join-Path $PSScriptRoot 'helper' 'Get-ModuleTargetVersion.ps1') | ||
. (Join-Path $PSScriptRoot 'helper' 'Get-BRMRepositoryName.ps1') | ||
. (Join-Path $PSScriptRoot 'helper' 'Set-ModuleReleaseTag.ps1') | ||
. (Join-Path $PSScriptRoot 'helper' 'Get-ModuleReadmeLink.ps1') | ||
. (Join-Path $PSScriptRoot 'helper' 'Publish-ModuleToPrivateBicepRegistry.ps1') | ||
# Load used functions | ||
. (Join-Path $PSScriptRoot 'helper' 'Test-ModuleQualifiesForPublish.ps1') | ||
. (Join-Path $PSScriptRoot 'helper' 'Get-ModuleTargetVersion.ps1') | ||
. (Join-Path $PSScriptRoot 'helper' 'Get-BRMRepositoryName.ps1') | ||
. (Join-Path $PSScriptRoot 'helper' 'New-ModuleReleaseTag.ps1') | ||
. (Join-Path $PSScriptRoot 'helper' 'Get-ModuleReadmeLink.ps1') | ||
. (Join-Path $PSScriptRoot 'helper' 'Publish-ModuleToPrivateBicepRegistry.ps1') | ||
|
||
$moduleFolderPath = Split-Path $TemplateFilePath -Parent | ||
$moduleJsonFilePath = Join-Path $moduleFolderPath 'main.json' | ||
$moduleFolderPath = Split-Path $TemplateFilePath -Parent | ||
$moduleJsonFilePath = Join-Path $moduleFolderPath 'main.json' | ||
|
||
# 1. Test if module qualifies for publishing | ||
if (-not (Test-ModuleQualifiesForPublish -moduleFolderPath $moduleFolderPath)) { | ||
Write-Verbose "No changes detected. Skipping publishing" -Verbose | ||
return | ||
} | ||
# 1. Test if module qualifies for publishing | ||
if (-not (Test-ModuleQualifiesForPublish -moduleFolderPath $moduleFolderPath)) { | ||
Write-Verbose "No changes detected. Skipping publishing" -Verbose | ||
return | ||
} | ||
|
||
# 2. Calculate the version that we would publish with | ||
$targetVersion = Get-ModuleTargetVersion -moduleFolderPath $moduleFolderPath | ||
# 2. Calculate the version that we would publish with | ||
$targetVersion = Get-ModuleTargetVersion -moduleFolderPath $moduleFolderPath | ||
|
||
# 3. Get Target Published Module Name | ||
$publishedModuleName = Get-BRMRepositoryName -TemplateFilePath $TemplateFilePath | ||
# 3. Get Target Published Module Name | ||
$publishedModuleName = Get-BRMRepositoryName -TemplateFilePath $TemplateFilePath | ||
|
||
# 4.Create release tag | ||
Set-ModuleReleaseTag -moduleFolderPath $moduleFolderPath | ||
# 4.Create release tag | ||
New-ModuleReleaseTag -moduleFolderPath $moduleFolderPath | ||
|
||
# 5. Get the documentation link | ||
$documentationUri = Get-ModuleReadmeLink -moduleFolderPath $moduleFolderPath | ||
# 5. Get the documentation link | ||
$documentationUri = Get-ModuleReadmeLink -moduleFolderPath $moduleFolderPath | ||
|
||
# 6. Replace telemetry version value (in JSON) | ||
$tokenConfiguration = @{ | ||
FilePathList = @($moduleJsonFilePath) | ||
Tokens = @{ | ||
'moduleVersion' = $targetVersion | ||
} | ||
TokenPrefix = '[[' | ||
TokenSuffix = ']]' | ||
# 6. Replace telemetry version value (in JSON) | ||
$tokenConfiguration = @{ | ||
FilePathList = @($moduleJsonFilePath) | ||
Tokens = @{ | ||
'moduleVersion' = $targetVersion | ||
} | ||
$null = Convert-TokensInFileList @tokenConfiguration | ||
TokenPrefix = '[[' | ||
TokenSuffix = ']]' | ||
} | ||
$null = Convert-TokensInFileList @tokenConfiguration | ||
|
||
################### | ||
## 7. Publish ## | ||
################### | ||
$plainPublicRegistryServer = ConvertFrom-SecureString $PublicRegistryServer -AsPlainText | ||
################### | ||
## 7. Publish ## | ||
################### | ||
$plainPublicRegistryServer = ConvertFrom-SecureString $PublicRegistryServer -AsPlainText | ||
|
||
$publishInput = @( | ||
$moduleJsonFilePath | ||
'--target', ("br:{0}/public/bicep/{1}:{2}" -f $plainPublicRegistryServer, $publishedModuleName, $targetVersion) | ||
'--documentationUri', $documentationUri | ||
'--force' | ||
) | ||
# bicep publish @publishInput | ||
$publishInput = @( | ||
$moduleJsonFilePath | ||
'--target', ("br:{0}/public/bicep/{1}:{2}" -f $plainPublicRegistryServer, $publishedModuleName, $targetVersion) | ||
'--documentationUri', $documentationUri | ||
'--force' | ||
) | ||
# bicep publish @publishInput | ||
} |
24 changes: 24 additions & 0 deletions
24
avm/utilities/pipelines/resourcePublish/helper/New-ModuleReleaseTag.ps1
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,24 @@ | ||
<# | ||
.SYNOPSIS | ||
Creates a new release tag | ||
.DESCRIPTION | ||
TBD | ||
.EXAMPLE | ||
#> | ||
|
||
function New-ModuleReleaseTag { | ||
|
||
[CmdletBinding()] | ||
param ( | ||
[Parameter()] | ||
[string] $ModuleFolderPath | ||
) | ||
|
||
$oldPatch = 0 | ||
$newPatch = $oldPatch + 1 | ||
return $newPatch | ||
# Update logic, progressive number | ||
} |
Empty file.