Skip to content

Commit

Permalink
Updated tag function
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSehr committed Sep 21, 2023
1 parent e82127b commit b8e79b1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @{
Expand All @@ -50,7 +43,7 @@ function Publish-ModuleFromTagToPBR {
$null = Convert-TokensInFileList @tokenConfiguration

###################
## 7. Publish ##
## 5. Publish ##
###################
$plainPublicRegistryServer = ConvertFrom-SecureString $PublicRegistryServer -AsPlainText

Expand All @@ -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)
```

0 comments on commit b8e79b1

Please sign in to comment.