Skip to content

Commit

Permalink
[CI Platform] Enabled module publishing from feature branch prereleas…
Browse files Browse the repository at this point in the history
…e publishing without publishing stable version (#3906)
  • Loading branch information
ahmadabdalla authored Sep 5, 2023
1 parent d41292f commit 096f450
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
36 changes: 35 additions & 1 deletion .azuredevops/pipelineTemplates/jobs.publishModule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##
#################
Expand Down Expand Up @@ -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 }}'
Expand Down Expand Up @@ -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 ##
#################
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions .github/actions/templates/publishModule/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,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 ##
#################
Expand Down Expand Up @@ -222,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 ##
#################
Expand Down
2 changes: 1 addition & 1 deletion utilities/tools/Set-ModuleReadMe.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,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 = '--'
Expand Down

0 comments on commit 096f450

Please sign in to comment.