diff --git a/.github/workflows/avm.platform.publish-tag.yml b/.github/workflows/avm.platform.publish-tag.yml index 389a68b249..e18574d79a 100644 --- a/.github/workflows/avm.platform.publish-tag.yml +++ b/.github/workflows/avm.platform.publish-tag.yml @@ -63,12 +63,10 @@ jobs: Write-Verbose 'Invoke function with' -Verbose Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose - Publish-ModuleFromTagToPBR @functionInput -Verbose - - # if($publishOutputs = Publish-ModuleFromTagToPBR @functionInput -Verbose) { - # Write-Output ('{0}={1}' -f 'version', $publishOutputs.version) >> $env:GITHUB_OUTPUT - # Write-Output ('{0}={1}' -f 'publishedModuleName', $publishOutputs.publishedModuleName) >> $env:GITHUB_OUTPUT - # } + if($publishOutputs = Publish-ModuleFromTagToPBR @functionInput -Verbose) { + Write-Output ('{0}={1}' -f 'version', $publishOutputs.version) >> $env:GITHUB_OUTPUT + Write-Output ('{0}={1}' -f 'publishedModuleName', $publishOutputs.publishedModuleName) >> $env:GITHUB_OUTPUT + } Write-Output '::endgroup::' diff --git a/avm/res/batch/batch-account/version.json b/avm/res/batch/batch-account/version.json index e42c3d9e5f..7e1d3f4157 100644 --- a/avm/res/batch/batch-account/version.json +++ b/avm/res/batch/batch-account/version.json @@ -1,6 +1,6 @@ { "$schema": "https://aka.ms/bicep-registry-module-version-file-schema#", - "version": "0.6", + "version": "0.7", "pathFilters": [ "./main.json" ] diff --git a/avm/utilities/pipelines/platform/Publish-ModuleFromTagToPBR.ps1 b/avm/utilities/pipelines/platform/Publish-ModuleFromTagToPBR.ps1 index 7efa05629b..fe6e596ad6 100644 --- a/avm/utilities/pipelines/platform/Publish-ModuleFromTagToPBR.ps1 +++ b/avm/utilities/pipelines/platform/Publish-ModuleFromTagToPBR.ps1 @@ -35,66 +35,66 @@ function Publish-ModuleFromTagToPBR { ) Write-Verbose "1 [$ModuleReleaseTagName]" -Verbose - # # Load used functions - # . (Join-Path $RepoRoot 'avm' 'utilities' 'pipelines' 'publish' 'helper' 'Get-ModuleReadmeLink.ps1') - - # Write-Verbose "2 [$ModuleReleaseTagName]" -Verbose - # # 1. Extract information from the tag - # $targetVersion = Split-Path $ModuleReleaseTagName -Leaf - # Write-Verbose "1 [$targetVersion]" -Verbose - # $moduleRelativeFolderPath = $ModuleReleaseTagName -replace "\/$targetVersion$", '' - # Write-Verbose "1 [$moduleRelativeFolderPath]" -Verbose - # $moduleFolderPath = Join-Path $repositoryRoot $moduleRelativeFolderPath - # Write-Verbose "1 [$moduleFolderPath]" -Verbose - # $moduleBicepFilePath = Join-Path $moduleFolderPath 'main.bicep' - # Write-Verbose "Determined Bicep template path [$moduleBicepFilePath]" - - # # 2. Get the documentation link - # $documentationUri = Get-ModuleReadmeLink -TagName $ModuleReleaseTagName -ModuleFolderPath $moduleFolderPath - # Write-Verbose "Determined documentation URI [$documentationUri]" - - # # 3. Replace telemetry version value (in Bicep) - # $tokenConfiguration = @{ - # FilePathList = @($moduleBicepFilePath) - # AbsoluteTokens = @{ - # '-..--..-' = $targetVersion - # } - # } - # Write-Verbose "Convert Tokens Input:`n $($tokenConfiguration | ConvertTo-Json -Depth 10)" -Verbose - # $null = Convert-TokensInFileList @tokenConfiguration - - # # Double-check that tokens are correctly replaced - # $templateContent = Get-Content -Path $moduleBicepFilePath - # $incorrectLines = @() - # for ($index = 0; $index -lt $templateContent.Count; $index++) { - # if ($templateContent[$index] -match '-..--..-') { - # $incorrectLines += ('You have the token [{0}] in line [{1}] of file [{2}]. Please seek advice from the AVM team.' -f $matches[0], ($index + 1), $moduleBicepFilePath) - # } - # } - # if ($incorrectLines) { - # throw ($incorrectLines | ConvertTo-Json) - # } - # ################### - # ## 4. Publish ## - # ################### - # $plainPublicRegistryServer = ConvertFrom-SecureString $PublicRegistryServer -AsPlainText - - # $publishInput = @( - # $moduleBicepFilePath - # '--target', ("br:{0}/public/bicep/{1}:{2}" -f $plainPublicRegistryServer, $moduleRelativeFolderPath, $targetVersion) - # '--documentationUri', $documentationUri - # '--with-source' - # '--force' - # ) - - # Write-Verbose "Publish Input:`n $($publishInput | ConvertTo-Json -Depth 10)" -Verbose - - # if ($PSCmdlet.ShouldProcess("Module of tag [$ModuleReleaseTagName]", "Publish")) { - # bicep publish @publishInput - # } - - # return @{ - # version = $targetVersion - # publishedModuleName = $moduleRelativeFolderPath - # } + # Load used functions + . (Join-Path $RepoRoot 'avm' 'utilities' 'pipelines' 'publish' 'helper' 'Get-ModuleReadmeLink.ps1') + + Write-Verbose "2 [$ModuleReleaseTagName]" -Verbose + # 1. Extract information from the tag + $targetVersion = Split-Path $ModuleReleaseTagName -Leaf + Write-Verbose "1 [$targetVersion]" -Verbose + $moduleRelativeFolderPath = $ModuleReleaseTagName -replace "\/$targetVersion$", '' + Write-Verbose "1 [$moduleRelativeFolderPath]" -Verbose + $moduleFolderPath = Join-Path $repositoryRoot $moduleRelativeFolderPath + Write-Verbose "1 [$moduleFolderPath]" -Verbose + $moduleBicepFilePath = Join-Path $moduleFolderPath 'main.bicep' + Write-Verbose "Determined Bicep template path [$moduleBicepFilePath]" + + # 2. Get the documentation link + $documentationUri = Get-ModuleReadmeLink -TagName $ModuleReleaseTagName -ModuleFolderPath $moduleFolderPath + Write-Verbose "Determined documentation URI [$documentationUri]" + + # 3. Replace telemetry version value (in Bicep) + $tokenConfiguration = @{ + FilePathList = @($moduleBicepFilePath) + AbsoluteTokens = @{ + '-..--..-' = $targetVersion + } + } + Write-Verbose "Convert Tokens Input:`n $($tokenConfiguration | ConvertTo-Json -Depth 10)" -Verbose + $null = Convert-TokensInFileList @tokenConfiguration + + # Double-check that tokens are correctly replaced + $templateContent = Get-Content -Path $moduleBicepFilePath + $incorrectLines = @() + for ($index = 0; $index -lt $templateContent.Count; $index++) { + if ($templateContent[$index] -match '-..--..-') { + $incorrectLines += ('You have the token [{0}] in line [{1}] of file [{2}]. Please seek advice from the AVM team.' -f $matches[0], ($index + 1), $moduleBicepFilePath) + } + } + if ($incorrectLines) { + throw ($incorrectLines | ConvertTo-Json) + } + ################### + ## 4. Publish ## + ################### + $plainPublicRegistryServer = ConvertFrom-SecureString $PublicRegistryServer -AsPlainText + + $publishInput = @( + $moduleBicepFilePath + '--target', ("br:{0}/public/bicep/{1}:{2}" -f $plainPublicRegistryServer, $moduleRelativeFolderPath, $targetVersion) + '--documentationUri', $documentationUri + '--with-source' + '--force' + ) + + Write-Verbose "Publish Input:`n $($publishInput | ConvertTo-Json -Depth 10)" -Verbose + + if ($PSCmdlet.ShouldProcess("Module of tag [$ModuleReleaseTagName]", "Publish")) { + bicep publish @publishInput + } + + return @{ + version = $targetVersion + publishedModuleName = $moduleRelativeFolderPath + } }