Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
48 changes: 30 additions & 18 deletions .azuredevops/pipelineTemplates/jobs.publishModule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
pwsh: true
script: |
# Load used functions
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Get-ModulesToUpdate.ps1')
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Get-ModulesToPublish.ps1')
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Publish-ModuleToUniversalArtifactFeed.ps1')

#Prioritizing the bicep file
Expand All @@ -168,27 +168,31 @@ jobs:
TemplateFilePath = $TemplateFilePath
}

Write-Verbose "Invoke Get-ModulesToUpdate with" -Verbose
Write-Verbose "Invoke Get-ModulesToPublish with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

# Get the modified child resources
$ModulesToUpdate = Get-ModulesToUpdate @functionInput -Verbose
$ModulesToPublish = Get-ModulesToPublish @functionInput -Verbose

# Publish the modified child resources
foreach ($ModuleToUpdate in $ModulesToUpdate) {
foreach ($ModuleToPublish in $ModulesToPublish) {
$RelPath = (($ModuleToPublish.TemplateFilePath).Split('/arm/')[-1]).Split('/deploy.')[0]
Write-Host "##[group]$(' - [{0}] [{1}]' -f $RelPath, $ModuleToPublish.Version)"

$functionInput = @{
TemplateFilePath = $ModuleToUpdate.TemplateFilePath
TemplateFilePath = $ModuleToPublish.TemplateFilePath
VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}'
VstsFeedProject = '${{ parameters.vstsFeedProject }}'
VstsFeedName = '${{ parameters.vstsFeedName }}'
ModuleVersion = $ModuleToUpdate.Version
ModuleVersion = $ModuleToPublish.Version
BearerToken = $env:TOKEN
}

Write-Verbose "Invoke Publish-ModuleToUniversalArtifactFeed with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

Publish-ModuleToUniversalArtifactFeed @functionInput -Verbose
Write-Host "##[endgroup]"
}
env:
TOKEN: $(vstsFeedToken)
Expand All @@ -210,7 +214,7 @@ jobs:
ScriptType: InlineScript
inline: |
# Load used functions
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Get-ModulesToUpdate.ps1')
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Get-ModulesToPublish.ps1')
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Publish-ModuleToTemplateSpec.ps1')

#Prioritizing the bicep file
Expand All @@ -223,26 +227,30 @@ jobs:
TemplateFilePath = $TemplateFilePath
}

Write-Verbose "Invoke Get-ModulesToUpdate with" -Verbose
Write-Verbose "Invoke Get-ModulesToPublish with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

# Get the modified child resources
$ModulesToUpdate = Get-ModulesToUpdate @functionInput -Verbose
$ModulesToPublish = Get-ModulesToPublish @functionInput -Verbose

# Publish the modified child resources
foreach ($ModuleToUpdate in $ModulesToUpdate) {
foreach ($ModuleToPublish in $ModulesToPublish) {
$RelPath = (($ModuleToPublish.TemplateFilePath).Split('/arm/')[-1]).Split('/deploy.')[0]
Write-Host "##[group]$(' - [{0}] [{1}]' -f $RelPath, $ModuleToPublish.Version)"

$functionInput = @{
TemplateFilePath = $ModuleToUpdate.TemplateFilePath
TemplateFilePath = $ModuleToPublish.TemplateFilePath
TemplateSpecsRgName = '${{ parameters.templateSpecsRgName }}'
TemplateSpecsRgLocation = '${{ parameters.templateSpecsRgLocation }}'
TemplateSpecsDescription = '${{ parameters.templateSpecsDescription }}'
ModuleVersion = $ModuleToUpdate.Version
ModuleVersion = $ModuleToPublish.Version
}

Write-Verbose "Invoke Publish-ModuleToTemplateSpec with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

Publish-ModuleToTemplateSpec @functionInput -Verbose
Write-Host "##[endgroup]"
}

# [private bicep registry publish] task(s)
Expand All @@ -262,7 +270,7 @@ jobs:
ScriptType: InlineScript
inline: |
# Load used functions
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Get-ModulesToUpdate.ps1')
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Get-ModulesToPublish.ps1')
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Publish-ModuleToPrivateBicepRegistry.ps1')

#Prioritizing the bicep file
Expand All @@ -275,24 +283,28 @@ jobs:
TemplateFilePath = $TemplateFilePath
}

Write-Verbose "Invoke Get-ModulesToUpdate with" -Verbose
Write-Verbose "Invoke Get-ModulesToPublish with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

# Get the modified child resources
$ModulesToUpdate = Get-ModulesToUpdate @functionInput -Verbose
$ModulesToPublish = Get-ModulesToPublish @functionInput -Verbose

# Publish the modified child resources
foreach ($ModuleToUpdate in $ModulesToUpdate) {
foreach ($ModuleToPublish in $ModulesToPublish) {
$RelPath = (($ModuleToPublish.TemplateFilePath).Split('/arm/')[-1]).Split('/deploy.')[0]
Write-Host "##[group]$(' - [{0}] [{1}]' -f $RelPath, $ModuleToPublish.Version)"

$functionInput = @{
TemplateFilePath = $ModuleToUpdate.TemplateFilePath
TemplateFilePath = $ModuleToPublish.TemplateFilePath
BicepRegistryName = '${{ parameters.bicepRegistryName }}'
BicepRegistryRgName = '${{ parameters.bicepRegistryRgName }}'
BicepRegistryRgLocation = '${{ parameters.bicepRegistryRgLocation }}'
ModuleVersion = $ModuleToUpdate.Version
ModuleVersion = $ModuleToPublish.Version
}

Write-Verbose "Invoke Publish-ModuleToPrivateBicepRegistry with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

Publish-ModuleToPrivateBicepRegistry @functionInput -Verbose
Write-Host "##[endgroup]"
}
26 changes: 16 additions & 10 deletions .github/actions/templates/publishModule/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ runs:
Write-Output "::group::Publish module to template specs"

# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'resourcePublish' 'Get-ModulesToUpdate.ps1')
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'resourcePublish' 'Get-ModulesToPublish.ps1')
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'resourcePublish' 'Publish-ModuleToTemplateSpec.ps1')

$functionInput = @{
Expand All @@ -81,16 +81,19 @@ runs:
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

# Get the modified child resources
$ModulesToUpdate = Get-ModulesToUpdate @functionInput -Verbose
$ModulesToPublish = Get-ModulesToPublish @functionInput -Verbose

# Publish the modified child resources
foreach ($ModuleToUpdate in $ModulesToUpdate) {
foreach ($ModuleToPublish in $ModulesToPublish) {
$RelPath = (($ModuleToPublish.TemplateFilePath).Split('/arm/')[-1]).Split('/deploy.')[0]
Write-Output "::group::$(' - [{0}] [{1}]' -f $RelPath, $ModuleToPublish.Version)"

$functionInput = @{
TemplateFilePath = $ModuleToUpdate.TemplateFilePath
TemplateFilePath = $ModuleToPublish.TemplateFilePath
TemplateSpecsRgName = '${{ inputs.templateSpecsRgName }}'
TemplateSpecsRgLocation = '${{ inputs.templateSpecsRgLocation }}'
TemplateSpecsDescription = '${{ inputs.templateSpecsDescription }}'
ModuleVersion = $ModuleToUpdate.Version
ModuleVersion = $ModuleToPublish.Version
}

Write-Verbose "Invoke task with" -Verbose
Expand All @@ -109,7 +112,7 @@ runs:
Write-Output "::group::Publish module to private bicep registry"

# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'resourcePublish' 'Get-ModulesToUpdate.ps1')
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'resourcePublish' 'Get-ModulesToPublish.ps1')
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'resourcePublish' 'Publish-ModuleToPrivateBicepRegistry.ps1')

$functionInput = @{
Expand All @@ -120,16 +123,19 @@ runs:
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

# Get the modified child resources
$ModulesToUpdate = Get-ModulesToUpdate @functionInput -Verbose
$ModulesToPublish = Get-ModulesToPublish @functionInput -Verbose

# Publish the modified child resources
foreach ($ModuleToUpdate in $ModulesToUpdate) {
foreach ($ModuleToPublish in $ModulesToPublish) {
$RelPath = (($ModuleToPublish.TemplateFilePath).Split('/arm/')[-1]).Split('/deploy.')[0]
Write-Output "::group::$(' - [{0}] [{1}]' -f $RelPath, $ModuleToPublish.Version)"

$functionInput = @{
TemplateFilePath = $ModuleToUpdate.TemplateFilePath
TemplateFilePath = $ModuleToPublish.TemplateFilePath
BicepRegistryName = '${{ inputs.bicepRegistryName }}'
BicepRegistryRgName = '${{ inputs.bicepRegistryRgName }}'
BicepRegistryRgLocation = '${{ inputs.bicepRegistryRgLocation }}'
ModuleVersion = $ModuleToUpdate.Version
ModuleVersion = $ModuleToPublish.Version
}

Write-Verbose "Invoke task with" -Verbose
Expand Down
12 changes: 9 additions & 3 deletions docs/wiki/PipelinesDesign.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,13 @@ Besides the execution of a publish, there is also the possibility to set the swi

The publishing works as follows:

1. The script `utilities/pipelines/resourcePublish/Get-ModulesToUpdate.ps1` gets all changed module files including child modules and handles the logic of propagating the appropriate module version to be used:
1. The script `utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1` gets all changed module files including child modules and handles the logic of propagating the appropriate module version to be used:
1. The major (`x.0`) and minor (`0.x`) version are set based on the file `version.json` in the module folder.
1. The patch (`0.0.x`) version is calculated based on the number of commits on the `HEAD` ref. This will cause the patch version to never reset to 0 with major and/or minor increment, as specified for [semver](https://semver.org/).
2. The patch (`0.0.x`) version is calculated based on the number of commits on the `HEAD` ref (aka. git height). This will cause the patch version to never reset to 0 with major and/or minor increment, as specified for [semver](https://semver.org/).
3. The module is published with a patch specific version (`x.y.z`). For Template Specs and Bicep Registry a major (`x`) and minor (`x.x`) version is also updated, allowing a consumer to use the latest version of any major or minor version.
1. For a changed child module, the direct parent hierarchy is also registered for an update, following the same procedure as above.
1. The list of module files paths and their versions are passed on as a array list.
2. The different publishing scripts run (Artifact, Template Spec or Bicep Registry) and publish the module to the respective target location for each item on the list.

**Example scenario**

Expand All @@ -139,7 +143,9 @@ Lets look at an example run where we would do a patch change on the `fileShares`
- Assuming the development branch started from commit 500 on the default branch, and the author added 6 commits on the development branch, the prerelease versions will reach `0.3.506-prerelease`.
- Meanwhile, there can be changes (let's say 2 squashed PR merges) on the default branch that is pushing its number of commits in history further.
- If the PR for the changes to `fileShare` is squash merged as commit number 503, the patch version on the child and parent module is then `503`, resulting in a version `0.3.503` being published.

7. The merge triggers cascading updates in the following way:
- The module is published with a `major.minor.patch` version as well as a `major.minor` and `major` version updates, allowing consumers to target the latest major or minor version with ease.
- All parent module are published following the steps mentioned above.
```
\ \
C499 -> C500 ---> C501 ---> C502 ---> C503 (503)
Expand Down
Loading