Skip to content

Commit

Permalink
comment all
Browse files Browse the repository at this point in the history
  • Loading branch information
eriqua committed Feb 24, 2024
1 parent f5c5fe4 commit a902b1f
Showing 1 changed file with 62 additions and 62 deletions.
124 changes: 62 additions & 62 deletions avm/utilities/pipelines/platform/Publish-ModuleFromTagToPBR.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
# }
}

0 comments on commit a902b1f

Please sign in to comment.