diff --git a/docs/wiki/The CI environment - Publishing.md b/docs/wiki/The CI environment - Publishing.md index 6bc4253189..fae7969a37 100644 --- a/docs/wiki/The CI environment - Publishing.md +++ b/docs/wiki/The CI environment - Publishing.md @@ -29,7 +29,7 @@ The publishing works as follows: 1. The script [`utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1`](https://github.com/Azure/ResourceModules/blob/main/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 `version.json` file in the module folder. 1. 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/). - 1. The module is published with a `major.minor.patch` version (`x.y.z`). For Template Specs and Bicep Registry only, a `major` version (`x`) and a `major.minor` version (`x.y`) are also updated, allowing a consumer to: + 1. The module is published with a `major.minor.patch` version (`x.y.z`). For Template Specs and Bicep Registry only, a `major` version (`x`), a `major.minor` version (`x.y`) and a `latest` version are also updated, allowing a consumer to: - Reference the latest version of a major, i.e., the latest minor and patch of a major version. > Example: Using Template Specs, the reference to a `major` could look like: `ts/modules:microsoft.resources.resourcegroups:1` which means that the template will always consume whatever the potentially overwritten/updated version `1` contains. - Reference the latest version of a minor, i.e., the latest patch of a minor version. diff --git a/settings.yml b/settings.yml index fce227c994..37c759f5f5 100644 --- a/settings.yml +++ b/settings.yml @@ -42,6 +42,12 @@ variables: location: 'West Europe' # The default location to test deploy resources to + ###################################### + # Publish: Shared settings + ###################################### + + publishLatest: true # [Only for Template-Specs & Bicep Registry] Publish an absolute latest version. Note: This version may include breaking changes and is not recommended for production environments + ###################################### # Publish: Template-Spec settings ###################################### diff --git a/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 b/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 index ff468a5b3c..2d53d61ba9 100644 --- a/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 +++ b/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 @@ -346,10 +346,13 @@ Generates a hashtable with template file paths to publish with a new version. .PARAMETER TemplateFilePath Mandatory. Path to a deploy.bicep/json file. +.PARAMETER PublishLatest +Optional. Publish an absolute latest version. +Note: This version may include breaking changes and is not recommended for production environments + .EXAMPLE Get-ModulesToPublish -TemplateFilePath 'C:\Repos\Azure\ResourceModules\modules\Microsoft.Storage\storageAccounts\deploy.bicep' - Name Value ---- ----- TemplateFilePath C:\Repos\Azure\ResourceModules\modules\Microsoft.Storage\storageAccounts\fileServices\shares\deploy.bicep @@ -361,14 +364,17 @@ Version 0.3.848-prerelease Generates a hashtable with template file paths to publish and their new versions. - #># function Get-ModulesToPublish { [CmdletBinding()] param ( [Parameter(Mandatory)] - [string] $TemplateFilePath + [string] $TemplateFilePath, + + [Parameter(Mandatory = $false)] + [bool] $PublishLatest = $true + ) $ModuleFolderPath = Split-Path $TemplateFilePath -Parent @@ -396,6 +402,14 @@ function Get-ModulesToPublish { Version = ($ModuleVersion.Split('.')[0]) TemplateFilePath = $TemplateFileToPublish.FullName } + + if ($PublishLatest) { + # Absolute latest + $ModulesToPublish += @{ + Version = 'latest' + TemplateFilePath = $TemplateFileToPublish.FullName + } + } } $ParentTemplateFilesToPublish = Get-ParentModuleTemplateFile -TemplateFilePath $TemplateFileToPublish.FullName -Recurse @@ -420,6 +434,14 @@ function Get-ModulesToPublish { Version = ($ParentModuleVersion.Split('.')[0]) TemplateFilePath = $ParentTemplateFileToPublish.FullName } + + if ($PublishLatest) { + # Absolute latest + $ModulesToPublish += @{ + Version = 'latest' + TemplateFilePath = $ParentTemplateFileToPublish.FullName + } + } } } }