Skip to content

Commit

Permalink
fix: calling publish --with-source with bicep template (#1040)
Browse files Browse the repository at this point in the history
## Description

Calling publish --with-source with bicep template instead of compiled
ARM/JSON

---------

Co-authored-by: ChrisSidebotham-MSFT <[email protected]>
  • Loading branch information
eriqua and ChrisSidebotham authored Feb 19, 2024
1 parent 31f4c9f commit dfaa8e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ function Publish-ModuleFromTagToPBR {
$targetVersion = Split-Path $ModuleReleaseTagName -Leaf
$moduleRelativeFolderPath = $ModuleReleaseTagName -replace "\/$targetVersion$", ''
$moduleFolderPath = Join-Path $repositoryRoot $moduleRelativeFolderPath
$moduleJsonFilePath = Join-Path $moduleFolderPath 'main.json'
Write-Verbose "Determined JSON template Path [$moduleJsonFilePath]"
$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
Expand All @@ -53,7 +53,7 @@ function Publish-ModuleFromTagToPBR {
$plainPublicRegistryServer = ConvertFrom-SecureString $PublicRegistryServer -AsPlainText

$publishInput = @(
$moduleJsonFilePath
$moduleBicepFilePath
'--target', ("br:{0}/public/bicep/{1}:{2}" -f $plainPublicRegistryServer, $moduleRelativeFolderPath, $targetVersion)
'--documentationUri', $documentationUri
'--with-source'
Expand Down
12 changes: 6 additions & 6 deletions avm/utilities/pipelines/publish/Publish-ModuleFromPathToPBR.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function Publish-ModuleFromPathToPBR {
. (Join-Path $RepoRoot 'avm' 'utilities' 'pipelines' 'sharedScripts' 'tokenReplacement' 'Convert-TokensInFileList.ps1')

$moduleFolderPath = Split-Path $TemplateFilePath -Parent
$moduleJsonFilePath = Join-Path $moduleFolderPath 'main.json'
$moduleBicepFilePath = Join-Path $moduleFolderPath 'main.bicep'

# 1. Test if module qualifies for publishing
if (-not (Get-ModulesToPublish -ModuleFolderPath $moduleFolderPath)) {
Expand All @@ -66,9 +66,9 @@ function Publish-ModuleFromPathToPBR {
# 5. Get the documentation link
$documentationUri = Get-ModuleReadmeLink -TagName $tagName -ModuleFolderPath $moduleFolderPath

# 6. Replace telemetry version value (in JSON)
# 6. Replace telemetry version value (in Bicep)
$tokenConfiguration = @{
FilePathList = @($moduleJsonFilePath)
FilePathList = @($moduleBicepFilePath)
AbsoluteTokens = @{
'-..--..-' = $targetVersion
}
Expand All @@ -77,11 +77,11 @@ function Publish-ModuleFromPathToPBR {
$null = Convert-TokensInFileList @tokenConfiguration

# Double-check that tokens are correctly replaced
$templateContent = Get-Content -Path $moduleJsonFilePath
$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), $moduleJsonFilePath)
$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) {
Expand All @@ -94,7 +94,7 @@ function Publish-ModuleFromPathToPBR {
$plainPublicRegistryServer = ConvertFrom-SecureString $PublicRegistryServer -AsPlainText

$publishInput = @(
$moduleJsonFilePath
$moduleBicepFilePath
'--target', ("br:{0}/public/bicep/{1}:{2}" -f $plainPublicRegistryServer, $publishedModuleName, $targetVersion)
'--documentationUri', $documentationUri
'--with-source'
Expand Down

0 comments on commit dfaa8e9

Please sign in to comment.