From d5f5f6d0b784d25cbcbed3e9ed7846077388c5b7 Mon Sep 17 00:00:00 2001 From: Ahmad Abdalla <28486158+ahmadabdalla@users.noreply.github.com> Date: Fri, 1 Sep 2023 18:22:27 +1000 Subject: [PATCH 1/4] test --- .github/actions/templates/publishModule/action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/actions/templates/publishModule/action.yml b/.github/actions/templates/publishModule/action.yml index 49d8241f57..c561279723 100644 --- a/.github/actions/templates/publishModule/action.yml +++ b/.github/actions/templates/publishModule/action.yml @@ -136,6 +136,13 @@ runs: } } + # Filter modules to publish 'prerelease' only if branch is not main/master + $BranchName = Get-GitBranchName + if ('$BranchName' -ne 'refs/heads/main' -or $BranchName -ne 'refs/heads/master') { + Write-Verbose "Filtering modules to only publish [prerelease] as current branch [$BranchName] is not [main/master]." -Verbose + $modulesToPublish = $modulesToPublish | Where-Object -Property version -like '*-prerelease' + } + ################# ## Publish ## ################# From c027873d7cd3d33ce5383d8273acf988f7e13b96 Mon Sep 17 00:00:00 2001 From: Ahmad Abdalla <28486158+ahmadabdalla@users.noreply.github.com> Date: Fri, 1 Sep 2023 18:37:46 +1000 Subject: [PATCH 2/4] branch test --- .github/actions/templates/publishModule/action.yml | 5 ++--- modules/managed-identity/user-assigned-identity/version.json | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/actions/templates/publishModule/action.yml b/.github/actions/templates/publishModule/action.yml index c561279723..0ec830a4d0 100644 --- a/.github/actions/templates/publishModule/action.yml +++ b/.github/actions/templates/publishModule/action.yml @@ -137,9 +137,8 @@ runs: } # Filter modules to publish 'prerelease' only if branch is not main/master - $BranchName = Get-GitBranchName - if ('$BranchName' -ne 'refs/heads/main' -or $BranchName -ne 'refs/heads/master') { - Write-Verbose "Filtering modules to only publish [prerelease] as current branch [$BranchName] is not [main/master]." -Verbose + if ('$env:GITHUB_REF_NAME' -ne 'refs/heads/main' -or '$env:GITHUB_REF_NAME' -ne 'refs/heads/master') { + Write-Verbose "Filtering modules to only publish [prerelease] as current branch [$env:GITHUB_REF_NAME] is not [main/master]." -Verbose $modulesToPublish = $modulesToPublish | Where-Object -Property version -like '*-prerelease' } diff --git a/modules/managed-identity/user-assigned-identity/version.json b/modules/managed-identity/user-assigned-identity/version.json index 96236a61ba..04a0dd1a80 100644 --- a/modules/managed-identity/user-assigned-identity/version.json +++ b/modules/managed-identity/user-assigned-identity/version.json @@ -1,6 +1,6 @@ { "$schema": "https://aka.ms/bicep-registry-module-version-file-schema#", - "version": "0.4", + "version": "0.5", "pathFilters": [ "./main.json" ] From f06a44468f188f347a58e583af9d9e2575de7b9a Mon Sep 17 00:00:00 2001 From: Ahmad Abdalla <28486158+ahmadabdalla@users.noreply.github.com> Date: Mon, 4 Sep 2023 10:10:13 +1000 Subject: [PATCH 3/4] hotfixes --- .../pipelineTemplates/jobs.publishModule.yml | 36 ++++++++++++++++++- .../templates/publishModule/action.yml | 12 +++++-- utilities/tools/Set-ModuleReadMe.ps1 | 2 +- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/.azuredevops/pipelineTemplates/jobs.publishModule.yml b/.azuredevops/pipelineTemplates/jobs.publishModule.yml index 5087e1244f..801409be31 100644 --- a/.azuredevops/pipelineTemplates/jobs.publishModule.yml +++ b/.azuredevops/pipelineTemplates/jobs.publishModule.yml @@ -184,6 +184,13 @@ jobs: } } + # Filter modules to publish 'prerelease' only if branch is not main/master + $BranchName = '$(Build.SourceBranch)' + if ($BranchName -ne 'refs/heads/main' -and $BranchName -ne 'refs/heads/master') { + Write-Verbose "Filtering modules to only publish a [prerelease] version as the current branch [$BranchName] is not [main/master]." -Verbose + $modulesToPublish = $modulesToPublish | Where-Object -Property version -like '*-prerelease' + } + ################# ## Publish ## ################# @@ -225,6 +232,13 @@ jobs: pwsh: true ScriptType: InlineScript inline: | + # Load PS-Profile configuration + if (Test-Path $profile) { + . $profile + } else { + Write-Warning "No profile loaded from location [$profile]" + } + # Set context to chosen subscription Write-Verbose ('Setting context to subscription [{0}]' -f '${{ parameters.subscriptionId }}') -Verbose $null = Set-AzContext -Subscription '${{ parameters.subscriptionId }}' @@ -279,6 +293,13 @@ jobs: } } + # Filter modules to publish 'prerelease' only if branch is not main/master + $BranchName = '$(Build.SourceBranch)' + if ($BranchName -ne 'refs/heads/main' -and $BranchName -ne 'refs/heads/master') { + Write-Verbose "Filtering modules to only publish a [prerelease] version as the current branch [$BranchName] is not [main/master]." -Verbose + $modulesToPublish = $modulesToPublish | Where-Object -Property version -like '*-prerelease' + } + ################# ## Publish ## ################# @@ -316,8 +337,14 @@ jobs: scriptType: pscore scriptLocation: inlineScript inlineScript: | + # Load PS-Profile configuration + if (Test-Path $profile) { + . $profile + } else { + Write-Warning "No profile loaded from location [$profile]" + } + # Log into Az-PowerShell context - . $profile # Load PS-Profile configuration $SecuredPassword = ConvertTo-SecureString -AsPlainText -String $env:servicePrincipalKey $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $env:servicePrincipalId, $SecuredPassword $null = Connect-AzAccount -ServicePrincipal -TenantId $env:tenantId -Credential $Credential @@ -370,6 +397,13 @@ jobs: $missingModules = Get-ModulesMissingFromPrivateBicepRegistry @missingInputObject + # Filter modules to publish 'prerelease' only if branch is not main/master + $BranchName = '$(Build.SourceBranch)' + if ($BranchName -ne 'refs/heads/main' -and $BranchName -ne 'refs/heads/master') { + Write-Verbose "Filtering modules to only publish a [prerelease] version as the current branch [$BranchName] is not [main/master]." -Verbose + $modulesToPublish = $modulesToPublish | Where-Object -Property version -like '*-prerelease' + } + foreach($missingModule in $missingModules) { if($modulsToPublish.TemplateFilePath -notcontains $missingModule.TemplateFilePath) { $modulesToPublish += $missingModule diff --git a/.github/actions/templates/publishModule/action.yml b/.github/actions/templates/publishModule/action.yml index 003d732bc1..7645e7eb21 100644 --- a/.github/actions/templates/publishModule/action.yml +++ b/.github/actions/templates/publishModule/action.yml @@ -142,8 +142,9 @@ runs: } # Filter modules to publish 'prerelease' only if branch is not main/master - if ('$env:GITHUB_REF_NAME' -ne 'refs/heads/main' -or '$env:GITHUB_REF_NAME' -ne 'refs/heads/master') { - Write-Verbose "Filtering modules to only publish [prerelease] as current branch [$env:GITHUB_REF_NAME] is not [main/master]." -Verbose + $BranchName = "$env:GITHUB_REF_NAME" + if ($BranchName -ne 'main' -and $BranchName -ne 'master') { + Write-Verbose "Filtering modules to only publish a [prerelease] version as the current branch [$BranchName] is not [main/master]." -Verbose $modulesToPublish = $modulesToPublish | Where-Object -Property version -like '*-prerelease' } @@ -228,6 +229,13 @@ runs: } } + # Filter modules to publish 'prerelease' only if branch is not main/master + $BranchName = "$env:GITHUB_REF_NAME" + if ($BranchName -ne 'main' -and $BranchName -ne 'master') { + Write-Verbose "Filtering modules to only publish a [prerelease] version as the current branch [$BranchName] is not [main/master]." -Verbose + $modulesToPublish = $modulesToPublish | Where-Object -Property version -like '*-prerelease' + } + ################# ## Publish ## ################# diff --git a/utilities/tools/Set-ModuleReadMe.ps1 b/utilities/tools/Set-ModuleReadMe.ps1 index ca0f04a51b..ee525697f3 100644 --- a/utilities/tools/Set-ModuleReadMe.ps1 +++ b/utilities/tools/Set-ModuleReadMe.ps1 @@ -1575,7 +1575,7 @@ function Set-ModuleReadMe { } $moduleRoot = Split-Path $TemplateFilePath -Parent - $fullModuleIdentifier = $moduleRoot.Replace('\', '/').split('modules/')[1] + $fullModuleIdentifier = $moduleRoot.Replace('\', '/').split('modules/')[-1] # Custom modules are modules having the same resource type but different properties based on the name # E.g., web/site/config--appsetting vs web/site/config--authsettingv2 $customModuleSeparator = '--' From 1e150446e3d6757d0b30f277513dc435d614a03c Mon Sep 17 00:00:00 2001 From: Ahmad Abdalla <28486158+ahmadabdalla@users.noreply.github.com> Date: Tue, 5 Sep 2023 08:52:17 +1000 Subject: [PATCH 4/4] reverted managed identity version --- modules/managed-identity/user-assigned-identity/version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/managed-identity/user-assigned-identity/version.json b/modules/managed-identity/user-assigned-identity/version.json index 04a0dd1a80..96236a61ba 100644 --- a/modules/managed-identity/user-assigned-identity/version.json +++ b/modules/managed-identity/user-assigned-identity/version.json @@ -1,6 +1,6 @@ { "$schema": "https://aka.ms/bicep-registry-module-version-file-schema#", - "version": "0.5", + "version": "0.4", "pathFilters": [ "./main.json" ]