Skip to content

Commit

Permalink
test batch 0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
eriqua committed Feb 24, 2024
1 parent 232aeac commit 133971f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 69 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/avm.platform.publish-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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::'
Expand Down
2 changes: 1 addition & 1 deletion avm/res/batch/batch-account/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://aka.ms/bicep-registry-module-version-file-schema#",
"version": "0.6",
"version": "0.7",
"pathFilters": [
"./main.json"
]
Expand Down
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 133971f

Please sign in to comment.