From b8e79b1e2a8682246df75897751cfc4d203f5862 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Thu, 21 Sep 2023 10:54:33 +0100 Subject: [PATCH] Updated tag function --- .../Publish-ModuleFromPathToPBR.ps1 | 3 +- .../Publish-ModuleFromTagToPBR.ps1 | 40 +++++++++---------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/avm/utilities/pipelines/resourcePublish/Publish-ModuleFromPathToPBR.ps1 b/avm/utilities/pipelines/resourcePublish/Publish-ModuleFromPathToPBR.ps1 index d981579f7a..cbf38e6937 100644 --- a/avm/utilities/pipelines/resourcePublish/Publish-ModuleFromPathToPBR.ps1 +++ b/avm/utilities/pipelines/resourcePublish/Publish-ModuleFromPathToPBR.ps1 @@ -10,11 +10,12 @@ function Publish-ModuleFromPathToPBR { ) # Load used functions - . (Join-Path $PSScriptRoot 'helper' 'Test-ModuleQualifiesForPublish.ps1') + . (Join-Path $PSScriptRoot 'helper' 'Get-ModulesToPublish.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 '..' 'tokensReplacement' 'Convert-TokensInFileList.ps1') $moduleFolderPath = Split-Path $TemplateFilePath -Parent $moduleJsonFilePath = Join-Path $moduleFolderPath 'main.json' diff --git a/avm/utilities/pipelines/resourcePublish/Publish-ModuleFromTagToPBR.ps1 b/avm/utilities/pipelines/resourcePublish/Publish-ModuleFromTagToPBR.ps1 index d80cbabe59..169231c0fe 100644 --- a/avm/utilities/pipelines/resourcePublish/Publish-ModuleFromTagToPBR.ps1 +++ b/avm/utilities/pipelines/resourcePublish/Publish-ModuleFromTagToPBR.ps1 @@ -10,35 +10,28 @@ function Publish-ModuleFromTagToPBR { ) # 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') + . (Join-Path $PSScriptRoot '..' 'tokensReplacement' 'Convert-TokensInFileList.ps1') - $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 - } + # TODO: Diff in between tag & tag^-1 to find modules to publish? - # 2. Calculate the version that we would publish with - $targetVersion = Get-ModuleTargetVersion -moduleFolderPath $moduleFolderPath + # ModuleReleaseTagName = 'avm/res/key-vault/vault/0.6.10' + # 1. Find tag as per function input + $repositoryRoot = (Get-Item $PSScriptRoot).Parent.Parent.Parent.Parent + $targetVersion = Split-Path $ModuleReleaseTagName -Leaf + $moduleRelativeFolderPath = $ModuleReleaseTagName -replace "\/$targetVersion$", '' + $moduleFolderPath = Join-Path $repositoryRoot $moduleRelativeFolderPath + $moduleJsonFilePath = Join-Path $moduleFolderPath 'main.json' - # 3. Get Target Published Module Name - $publishedModuleName = Get-BRMRepositoryName -TemplateFilePath $TemplateFilePath - # 4.Create release tag - New-ModuleReleaseTag -moduleFolderPath $moduleFolderPath + # 2. Get Target Published Module Name + $publishedModuleName = Get-BRMRepositoryName -TemplateFilePath $moduleJsonFilePath - # 5. Get the documentation link - $documentationUri = Get-ModuleReadmeLink -moduleFolderPath $moduleFolderPath + # 3. Get the documentation link + $documentationUri = Get-ModuleReadmeLink -TagName $ModuleReleaseTagName -ModuleRelativeFolderPath $moduleRelativeFolderPath - # 6. Replace telemetry version value (in JSON) + # 4. Replace telemetry version value (in JSON) $tokenConfiguration = @{ FilePathList = @($moduleJsonFilePath) Tokens = @{ @@ -50,7 +43,7 @@ function Publish-ModuleFromTagToPBR { $null = Convert-TokensInFileList @tokenConfiguration ################### - ## 7. Publish ## + ## 5. Publish ## ################### $plainPublicRegistryServer = ConvertFrom-SecureString $PublicRegistryServer -AsPlainText @@ -62,3 +55,6 @@ function Publish-ModuleFromTagToPBR { ) # bicep publish @publishInput } + +Publish-ModuleFromTagToPBR -ModuleReleaseTagName 'avm/res/key-vault/vault/0.6.10' -PublicRegistryServer (ConvertTo-SecureString 'myserver' -AsPlainText -Force) +``` \ No newline at end of file