Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added 'Publish from tag' pipeline for AVM #673

Merged
merged 81 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
20ac8b7
Added skeleton
AlexanderSehr Nov 7, 2023
4939b4d
Implemented first new tests
AlexanderSehr Nov 7, 2023
4e1d86f
Changed to warning
AlexanderSehr Nov 8, 2023
94fff0b
Expanded test verbosity & added additional tets
AlexanderSehr Nov 8, 2023
c18ce6b
Finalized further tests
AlexanderSehr Nov 8, 2023
a343694
Update to latest
AlexanderSehr Nov 8, 2023
3a6f0a2
Update to latest
AlexanderSehr Nov 8, 2023
4ab6a5b
Added module name + small fix
AlexanderSehr Nov 8, 2023
9bb64bd
Fixed kvlt
AlexanderSehr Nov 8, 2023
68e2bd2
Small caching fix
AlexanderSehr Nov 8, 2023
1a013c2
Small fix and enabled passthru of warnings to GH
AlexanderSehr Nov 8, 2023
1c2fc8a
More updates
AlexanderSehr Nov 8, 2023
d9c6dd5
Update to latest
AlexanderSehr Nov 8, 2023
dd0c343
Updated test names
AlexanderSehr Nov 8, 2023
2ebd458
JSON rollback
AlexanderSehr Nov 8, 2023
f6caf7e
Updated regex
AlexanderSehr Nov 8, 2023
f56f66a
Removed assertion
AlexanderSehr Nov 8, 2023
282b640
Update to latest
AlexanderSehr Nov 8, 2023
c025f52
Update avm/utilities/pipelines/staticValidation/compliance/module.tes…
AlexanderSehr Nov 9, 2023
405901a
Update avm/utilities/pipelines/staticValidation/compliance/module.tes…
AlexanderSehr Nov 9, 2023
904c82f
Merge branch 'main' into users/alsehr/testFileCompliance
AlexanderSehr Nov 9, 2023
ef24d1f
Rollback of unrelated changes
AlexanderSehr Nov 9, 2023
9393aa1
Merge branch 'Azure:main' into main
AlexanderSehr Nov 9, 2023
cb39086
Merge branch 'Azure:main' into main
AlexanderSehr Nov 9, 2023
89eac40
Merge branch 'Azure:main' into main
AlexanderSehr Nov 10, 2023
712a673
Merge branch 'Azure:main' into main
AlexanderSehr Nov 13, 2023
55e095f
Resolved conflict
AlexanderSehr Nov 14, 2023
3121335
Update to latest
AlexanderSehr Nov 14, 2023
e9d736c
Merge branch 'Azure:main' into main
AlexanderSehr Nov 15, 2023
abfa1b9
Merge branch 'Azure:main' into main
AlexanderSehr Nov 15, 2023
c6707f6
Merge branch 'Azure:main' into main
AlexanderSehr Nov 16, 2023
246f9ba
Merge branch 'Azure:main' into main
AlexanderSehr Nov 16, 2023
6e9729d
Merge branch 'Azure:main' into main
AlexanderSehr Nov 16, 2023
26ea9f6
Merge branch 'Azure:main' into main
AlexanderSehr Nov 17, 2023
c2d183b
Merge branch 'Azure:main' into main
AlexanderSehr Nov 18, 2023
0c6650e
Merge branch 'Azure:main' into main
AlexanderSehr Nov 19, 2023
65094a5
Merge branch 'Azure:main' into main
AlexanderSehr Nov 21, 2023
968cd9a
Merge branch 'Azure:main' into main
AlexanderSehr Nov 21, 2023
3c9589b
Merge branch 'Azure:main' into main
AlexanderSehr Nov 24, 2023
eb34ddf
Merge branch 'Azure:main' into main
AlexanderSehr Nov 25, 2023
d16099e
Added publish from tag pipeline
AlexanderSehr Nov 26, 2023
57dab9d
Update to latest
AlexanderSehr Nov 26, 2023
7f8ec0c
Temp disabled login for testing
AlexanderSehr Nov 26, 2023
3d4f5c6
Added pipeline to main for testing
AlexanderSehr Nov 26, 2023
283fd03
Update to latest
AlexanderSehr Nov 26, 2023
1130cc3
Renamed pipeline
AlexanderSehr Nov 26, 2023
f885851
Update to latest
AlexanderSehr Nov 26, 2023
b6121d7
Update to latest
AlexanderSehr Nov 26, 2023
776c4f9
Update to latest
AlexanderSehr Nov 26, 2023
b4d4694
Update to latest
AlexanderSehr Nov 26, 2023
5c5a0af
Update to latest
AlexanderSehr Nov 26, 2023
536ce01
Re-enabled commented test code
AlexanderSehr Nov 26, 2023
70154f3
Merge branch 'Azure:main' into main
AlexanderSehr Nov 27, 2023
18bd2ad
Merge branch 'Azure:main' into main
AlexanderSehr Nov 27, 2023
940b34f
Merge branch 'Azure:main' into main
AlexanderSehr Nov 28, 2023
fbb840f
Merge branch 'Azure:main' into main
AlexanderSehr Nov 29, 2023
381e366
Merge branch 'Azure:main' into main
AlexanderSehr Nov 29, 2023
1707367
Update .github/workflows/avm.platform.publish.tag.yml
AlexanderSehr Dec 1, 2023
817ca3f
Update .github/workflows/avm.platform.publish.tag.yml
AlexanderSehr Dec 1, 2023
06bcda3
Merge branch 'Azure:main' into main
AlexanderSehr Dec 1, 2023
0858beb
Merge branch 'Azure:main' into main
AlexanderSehr Dec 1, 2023
72b5fbb
Merge branch 'Azure:main' into main
AlexanderSehr Dec 1, 2023
917a761
TEst disable pipe
AlexanderSehr Dec 4, 2023
1b89452
Merge branch 'Azure:main' into main
AlexanderSehr Dec 4, 2023
feb981e
Update to latest
AlexanderSehr Dec 4, 2023
dda85a8
Merge branch 'Azure:main' into main
AlexanderSehr Dec 4, 2023
1543390
Resolved conflicts
AlexanderSehr Dec 6, 2023
e19a408
Merge branch 'users/alsehr/releaseFromTag' of https://github.com/Alex…
AlexanderSehr Dec 6, 2023
60007dd
Addressed feedback
AlexanderSehr Dec 6, 2023
dfe2a6f
Update to latest
AlexanderSehr Dec 6, 2023
0373f46
Merge branch 'Azure:main' into main
AlexanderSehr Dec 6, 2023
72dcc2c
Moved script
AlexanderSehr Dec 6, 2023
80247e4
Merge branch 'Azure:main' into main
AlexanderSehr Dec 9, 2023
2b5a791
Merge branch 'Azure:main' into main
AlexanderSehr Dec 10, 2023
39c5173
Merge branch 'main' into users/alsehr/releaseFromTag
AlexanderSehr Dec 10, 2023
1d3c70b
Merge branch 'main' into users/alsehr/releaseFromTag
eriqua Dec 10, 2023
a4eeb6a
Merge branch 'main' into users/alsehr/releaseFromTag
AlexanderSehr Dec 11, 2023
052c4e7
Update to latest
AlexanderSehr Dec 11, 2023
68afc1b
Merge branch 'main' into users/alsehr/releaseFromTag
AlexanderSehr Dec 11, 2023
f73a97f
Update to latest
AlexanderSehr Dec 11, 2023
3395117
Update to latest
AlexanderSehr Dec 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/actions/templates/avm-publishModule/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,16 @@ runs:
# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'avm' 'utilities' 'pipelines' 'publish' 'Publish-ModuleFromPathToPBR.ps1')
################################
## Get modules to publish ##
################################
$functionInput = @{
TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE "${{ inputs.templateFilePath }}"
PublicRegistryServer = ConvertTo-SecureString '${{ env.PUBLISH_REGISTRY_SERVER }}' -AsPlainText -Force
RepoRoot = $env:GITHUB_WORKSPACE
}
Write-Verbose "Invoke function with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose
# Get the modified child resources
if($publishOutputs = Publish-ModuleFromPathToPBR @functionInput -Verbose) {
Write-Output ('{0}={1}' -f 'version', $publishOutputs.version) >> $env:GITHUB_OUTPUT
Write-Output ('{0}={1}' -f 'publishedModuleName', $publishOutputs.publishedModuleName) >> $env:GITHUB_OUTPUT
}
Publish-ModuleFromPathToPBR @functionInput -Verbose
Write-Output '::endgroup::'
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/avm.platform.publish-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: "avm.platform.publish-tag"

on:
workflow_dispatch:
inputs:
tag:
description: "The git tag of the module to publish. For example: [avm/res/key-vault/vault/1.0.0]"
required: true
type: string

permissions:
id-token: write
contents: read

jobs:
job_publish_module_with_tag:
runs-on: ubuntu-latest
name: "Publish module with tag"
steps:
- name: Checkout tag
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag }}

- name: Log in to Azure
uses: azure/login@v1
with:
client-id: ${{ env.PUBLISH_CLIENT_ID }}
tenant-id: ${{ env.PUBLISH_TENANT_ID }}
subscription-id: ${{ env.PUBLISH_SUBSCRIPTION_ID }}

# Adding a step to explicitly install the latest Bicep CLI because there is
# always a delay in updating Bicep CLI in the job runner environments.
- name: Install the latest Bicep CLI
shell: bash
run: |
curl -Lo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64
chmod +x ./bicep
sudo mv ./bicep /usr/local/bin/bicep
bicep --version

- name: "Publish tagged module to public bicep registry"
uses: azure/powershell@v1
with:
azPSVersion: "latest"
inlineScript: |
# Grouping task logs
Write-Output '::group::Publish tagged module to public bicep registry'

# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'avm' 'utilities' 'pipelines' 'platform' 'Publish-ModuleFromTagToPBR.ps1')

$functionInput = @{
ModuleReleaseTagName = '${{ github.event.inputs.tag }}'
PublicRegistryServer = ConvertTo-SecureString '${{ secrets.PUBLISH_REGISTRY_SERVER }}' -AsPlainText -Force
RepoRoot = $env:GITHUB_WORKSPACE
}

Write-Verbose 'Invoke function with' -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

Publish-ModuleFromTagToPBR @functionInput -Verbose

Write-Output '::endgroup::'
67 changes: 67 additions & 0 deletions avm/utilities/pipelines/platform/Publish-ModuleFromTagToPBR.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<#
.SYNOPSIS
Publish a module based on the provided git tag

.DESCRIPTION
Publish a module based on the provided git tag

.PARAMETER ModuleReleaseTagName
Mandatory. The git tag to identify the module with & publish its code state of

.PARAMETER PublicRegistryServer
Mandatory. The public registry server.

.PARAMETER RepoRoot
Optional. Path to the root of the repository.

.EXAMPLE
Publish-ModuleFromTagToPBR -ModuleReleaseTagName 'avm/res/key-vault/vault/0.3.0' -PublicRegistryServer (ConvertTo-SecureString 'myServer' -AsPlainText -Force)

Publish the module 'avm/res/key-vault/vault' of git tag 'avm/res/key-vault/vault/0.3.0' to the public registry server 'myServer'
#>
function Publish-ModuleFromTagToPBR {

[CmdletBinding(SupportsShouldProcess)]
param (
[Parameter(Mandatory = $true)]
[string] $ModuleReleaseTagName,

[Parameter(Mandatory = $true)]
[secureString] $PublicRegistryServer,

[Parameter(Mandatory = $false)]
[string] $RepoRoot = (Get-Item -Path $PSScriptRoot).parent.parent.parent.parent.FullName
)

# Load used functions
. (Join-Path $RepoRoot 'avm' 'utilities' 'pipelines' 'publish' 'helper' 'Get-ModuleReadmeLink.ps1')

# 1. Extract information from the tag
$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]"

# 2. Get the documentation link
$documentationUri = Get-ModuleReadmeLink -TagName $ModuleReleaseTagName -ModuleFolderPath $moduleFolderPath
Write-Verbose "Determined documentation URI [$documentationUri]"

###################
## 3. Publish ##
###################
$plainPublicRegistryServer = ConvertFrom-SecureString $PublicRegistryServer -AsPlainText

$publishInput = @(
$moduleJsonFilePath
'--target', ("br:{0}/public/bicep/{1}:{2}" -f $plainPublicRegistryServer, $moduleRelativeFolderPath, $targetVersion)
'--documentationUri', $documentationUri
'--force'
)

Write-Verbose "Publish Input:`n $($publishInput | ConvertTo-Json -Depth 10)" -Verbose

if ($PSCmdlet.ShouldProcess("Module of tag [$ModuleReleaseTagName]", "Publish")) {
bicep publish @publishInput
}
}
23 changes: 15 additions & 8 deletions avm/utilities/pipelines/publish/Publish-ModuleFromPathToPBR.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ Mandatory. The path to the deployment file
.PARAMETER PublicRegistryServer
Mandatory. The public registry server.

.PARAMETER RepoRoot
Optional. Path to the root of the repository.

.EXAMPLE
Publish-ModuleFromPathToPBR -TemplateFilePath 'C:\avm\res\key-vault\vault\main.bicep -PublicRegistryServer '<secureString>'
Publish-ModuleFromPathToPBR -TemplateFilePath 'C:\avm\res\key-vault\vault\main.bicep -PublicRegistryServer (ConvertTo-SecureString 'myServer' -AsPlainText -Force)

Publish the module in path 'key-vault/vault' to the public registry server 'myServer'
#>
function Publish-ModuleFromPathToPBR {

Expand All @@ -27,16 +31,19 @@ function Publish-ModuleFromPathToPBR {
[string] $TemplateFilePath,

[Parameter(Mandatory = $true)]
[secureString] $PublicRegistryServer
[secureString] $PublicRegistryServer,

[Parameter(Mandatory = $false)]
[string] $RepoRoot = (Get-Item -Path $PSScriptRoot).parent.parent.parent.parent.FullName
)

# Load used functions
. (Join-Path $PSScriptRoot 'helper' 'Get-ModulesToPublish.ps1')
. (Join-Path $PSScriptRoot 'helper' 'Get-ModuleTargetVersion.ps1')
. (Join-Path (Split-Path $PSScriptRoot) 'sharedScripts' 'Get-BRMRepositoryName.ps1')
. (Join-Path $PSScriptRoot 'helper' 'New-ModuleReleaseTag.ps1')
. (Join-Path $PSScriptRoot 'helper' 'Get-ModuleReadmeLink.ps1')
. (Join-Path (Split-Path $PSScriptRoot -Parent) 'sharedScripts' 'tokenReplacement' 'Convert-TokensInFileList.ps1')
. (Join-Path $RepoRoot 'avm' 'utilities' 'pipelines' 'publish' 'helper' 'Get-ModulesToPublish.ps1')
. (Join-Path $RepoRoot 'avm' 'utilities' 'pipelines' 'publish' 'helper' 'Get-ModuleTargetVersion.ps1')
. (Join-Path $RepoRoot 'avm' 'utilities' 'pipelines' 'publish' 'helper' 'New-ModuleReleaseTag.ps1')
. (Join-Path $RepoRoot 'avm' 'utilities' 'pipelines' 'publish' 'helper' 'Get-ModuleReadmeLink.ps1')
. (Join-Path $RepoRoot 'avm' 'utilities' 'pipelines' 'sharedScripts' 'Get-BRMRepositoryName.ps1')
. (Join-Path $RepoRoot 'avm' 'utilities' 'pipelines' 'sharedScripts' 'tokenReplacement' 'Convert-TokensInFileList.ps1')

$moduleFolderPath = Split-Path $TemplateFilePath -Parent
$moduleJsonFilePath = Join-Path $moduleFolderPath 'main.json'
Expand Down
66 changes: 0 additions & 66 deletions avm/utilities/pipelines/publish/Publish-ModuleFromTagToPBR.ps1

This file was deleted.