From 0550d0e8d27c47ef66b47e0ffc04831ca66e14ba Mon Sep 17 00:00:00 2001 From: Beisi Zhou Date: Tue, 18 May 2021 19:01:01 +0800 Subject: [PATCH] Create AzPreview module (#15034) * create AzPreview module * Update AzPreview.psd1.template * Update AzPreview.psd1 Co-authored-by: Dingmeng Xue --- tools/AzPreview/AzPreview.psd1 | 252 ++++++++++++++++++++++++ tools/AzPreview/AzPreview.psd1.template | 133 +++++++++++++ tools/PublishModules.psm1 | 1 + tools/RunVersionController.ps1 | 197 +++++++++++------- tools/UpdateModules.psm1 | 5 + 5 files changed, 513 insertions(+), 75 deletions(-) create mode 100644 tools/AzPreview/AzPreview.psd1 create mode 100644 tools/AzPreview/AzPreview.psd1.template diff --git a/tools/AzPreview/AzPreview.psd1 b/tools/AzPreview/AzPreview.psd1 new file mode 100644 index 000000000000..345df8eda575 --- /dev/null +++ b/tools/AzPreview/AzPreview.psd1 @@ -0,0 +1,252 @@ +# +# Module manifest for module 'AzPreview' +# +# Generated by: Microsoft Corporation +# +# Generated on: 5/17/2021 +# + +@{ + +# Script module or binary module file associated with this manifest. +# RootModule = '' + +# Version number of this module. +ModuleVersion = '5.10.0' + +# Supported PSEditions +CompatiblePSEditions = 'Core', 'Desktop' + +# ID used to uniquely identify this module +GUID = '5052d1e8-69f1-4f91-8433-5400429b2db9' + +# Author of this module +Author = 'Microsoft Corporation' + +# Company or vendor of this module +CompanyName = 'Microsoft Corporation' + +# Copyright statement for this module +Copyright = 'Microsoft Corporation. All rights reserved.' + +# Description of the functionality provided by this module +Description = 'Microsoft Azure PowerShell - Cmdlets to manage resources in Azure. This module is compatible with WindowsPowerShell and PowerShell Core. +For more information about the Az module, please visit the following: https://docs.microsoft.com/en-us/powershell/azure/' + +# Minimum version of the PowerShell engine required by this module +PowerShellVersion = '5.1' + +# Name of the PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +DotNetFrameworkVersion = '4.7.2' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# CLRVersion = '' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +RequiredModules = @(@{ModuleName = 'Az.Accounts'; RequiredVersion = '2.3.0'; }, + @{ModuleName = 'Az.ADDomainServices'; RequiredVersion = '0.1.0'; }, + @{ModuleName = 'Az.Advisor'; RequiredVersion = '1.1.1'; }, + @{ModuleName = 'Az.Aks'; RequiredVersion = '2.1.0'; }, + @{ModuleName = 'Az.AlertsManagement'; RequiredVersion = '0.2.0'; }, + @{ModuleName = 'Az.AnalysisServices'; RequiredVersion = '1.1.4'; }, + @{ModuleName = 'Az.ApiManagement'; RequiredVersion = '2.2.0'; }, + @{ModuleName = 'Az.AppConfiguration'; RequiredVersion = '1.0.0'; }, + @{ModuleName = 'Az.ApplicationInsights'; RequiredVersion = '1.1.0'; }, + @{ModuleName = 'Az.Attestation'; RequiredVersion = '0.1.8'; }, + @{ModuleName = 'Az.Automation'; RequiredVersion = '1.7.0'; }, + @{ModuleName = 'Az.Batch'; RequiredVersion = '3.1.0'; }, + @{ModuleName = 'Az.Billing'; RequiredVersion = '2.0.0'; }, + @{ModuleName = 'Az.Blockchain'; RequiredVersion = '0.2.0'; }, + @{ModuleName = 'Az.Blueprint'; RequiredVersion = '0.3.0'; }, + @{ModuleName = 'Az.BotService'; RequiredVersion = '0.3.0'; }, + @{ModuleName = 'Az.Cdn'; RequiredVersion = '1.7.0'; }, + @{ModuleName = 'Az.CloudService'; RequiredVersion = '0.3.0'; }, + @{ModuleName = 'Az.CognitiveServices'; RequiredVersion = '1.8.0'; }, + @{ModuleName = 'Az.Communication'; RequiredVersion = '0.1.0'; }, + @{ModuleName = 'Az.Compute'; RequiredVersion = '4.13.0'; }, + @{ModuleName = 'Az.Confluent'; RequiredVersion = '0.1.0'; }, + @{ModuleName = 'Az.ConnectedKubernetes'; RequiredVersion = '0.2.0'; }, + @{ModuleName = 'Az.ConnectedMachine'; RequiredVersion = '0.2.0'; }, + @{ModuleName = 'Az.ContainerInstance'; RequiredVersion = '1.0.3'; }, + @{ModuleName = 'Az.ContainerRegistry'; RequiredVersion = '2.2.3'; }, + @{ModuleName = 'Az.CosmosDB'; RequiredVersion = '1.2.0'; }, + @{ModuleName = 'Az.CostManagement'; RequiredVersion = '0.2.0'; }, + @{ModuleName = 'Az.CustomProviders'; RequiredVersion = '0.1.0'; }, + @{ModuleName = 'Az.DataBox'; RequiredVersion = '0.1.1'; }, + @{ModuleName = 'Az.DataBoxEdge'; RequiredVersion = '1.1.0'; }, + @{ModuleName = 'Az.Databricks'; RequiredVersion = '1.1.0'; }, + @{ModuleName = 'Az.DataFactory'; RequiredVersion = '1.12.0'; }, + @{ModuleName = 'Az.DataLakeAnalytics'; RequiredVersion = '1.0.2'; }, + @{ModuleName = 'Az.DataLakeStore'; RequiredVersion = '1.3.0'; }, + @{ModuleName = 'Az.DataMigration'; RequiredVersion = '0.7.4'; }, + @{ModuleName = 'Az.DataProtection'; RequiredVersion = '0.2.0'; }, + @{ModuleName = 'Az.DataShare'; RequiredVersion = '1.0.0'; }, + @{ModuleName = 'Az.DedicatedHsm'; RequiredVersion = '0.2.0'; }, + @{ModuleName = 'Az.DeploymentManager'; RequiredVersion = '1.1.0'; }, + @{ModuleName = 'Az.DesktopVirtualization'; RequiredVersion = '2.2.0'; }, + @{ModuleName = 'Az.DeviceProvisioningServices'; RequiredVersion = '0.10.0'; }, + @{ModuleName = 'Az.DevSpaces'; RequiredVersion = '0.7.3'; }, + @{ModuleName = 'Az.DevTestLabs'; RequiredVersion = '1.0.2'; }, + @{ModuleName = 'Az.DigitalTwins'; RequiredVersion = '0.1.0'; }, + @{ModuleName = 'Az.Dns'; RequiredVersion = '1.1.2'; }, + @{ModuleName = 'Az.EventGrid'; RequiredVersion = '1.3.0'; }, + @{ModuleName = 'Az.EventHub'; RequiredVersion = '1.7.2'; }, + @{ModuleName = 'Az.FrontDoor'; RequiredVersion = '1.8.0'; }, + @{ModuleName = 'Az.Functions'; RequiredVersion = '2.0.0'; }, + @{ModuleName = 'Az.GuestConfiguration'; RequiredVersion = '0.10.8'; }, + @{ModuleName = 'Az.HanaOnAzure'; RequiredVersion = '0.3.0'; }, + @{ModuleName = 'Az.HDInsight'; RequiredVersion = '4.2.1'; }, + @{ModuleName = 'Az.HealthBot'; RequiredVersion = '0.1.0'; }, + @{ModuleName = 'Az.HealthcareApis'; RequiredVersion = '1.3.1'; }, + @{ModuleName = 'Az.HPCCache'; RequiredVersion = '0.1.1'; }, + @{ModuleName = 'Az.ImageBuilder'; RequiredVersion = '0.2.0'; }, + @{ModuleName = 'Az.ImportExport'; RequiredVersion = '0.1.0'; }, + @{ModuleName = 'Az.IotCentral'; RequiredVersion = '0.9.0'; }, + @{ModuleName = 'Az.IotHub'; RequiredVersion = '2.7.3'; }, + @{ModuleName = 'Az.KeyVault'; RequiredVersion = '3.4.3'; }, + @{ModuleName = 'Az.KubernetesConfiguration'; RequiredVersion = '0.3.0'; }, + @{ModuleName = 'Az.Kusto'; RequiredVersion = '1.0.1'; }, + @{ModuleName = 'Az.LogicApp'; RequiredVersion = '1.5.0'; }, + @{ModuleName = 'Az.MachineLearning'; RequiredVersion = '1.1.3'; }, + @{ModuleName = 'Az.Maintenance'; RequiredVersion = '1.1.1'; }, + @{ModuleName = 'Az.ManagedServiceIdentity'; RequiredVersion = '0.7.3'; }, + @{ModuleName = 'Az.ManagedServices'; RequiredVersion = '2.0.0'; }, + @{ModuleName = 'Az.ManagementPartner'; RequiredVersion = '0.7.2'; }, + @{ModuleName = 'Az.Maps'; RequiredVersion = '0.7.3'; }, + @{ModuleName = 'Az.MariaDb'; RequiredVersion = '0.2.0'; }, + @{ModuleName = 'Az.Marketplace'; RequiredVersion = '0.2.0'; }, + @{ModuleName = 'Az.MarketplaceOrdering'; RequiredVersion = '1.0.2'; }, + @{ModuleName = 'Az.Media'; RequiredVersion = '1.1.1'; }, + @{ModuleName = 'Az.Migrate'; RequiredVersion = '1.0.1'; }, + @{ModuleName = 'Az.MixedReality'; RequiredVersion = '0.1.4'; }, + @{ModuleName = 'Az.Monitor'; RequiredVersion = '2.5.0'; }, + @{ModuleName = 'Az.MonitoringSolutions'; RequiredVersion = '0.1.0'; }, + @{ModuleName = 'Az.MySql'; RequiredVersion = '0.6.0'; }, + @{ModuleName = 'Az.NetAppFiles'; RequiredVersion = '0.5.0'; }, + @{ModuleName = 'Az.Network'; RequiredVersion = '4.8.0'; }, + @{ModuleName = 'Az.NotificationHubs'; RequiredVersion = '1.1.1'; }, + @{ModuleName = 'Az.OperationalInsights'; RequiredVersion = '2.3.0'; }, + @{ModuleName = 'Az.Peering'; RequiredVersion = '0.3.0'; }, + @{ModuleName = 'Az.PolicyInsights'; RequiredVersion = '1.4.1'; }, + @{ModuleName = 'Az.Portal'; RequiredVersion = '0.1.0'; }, + @{ModuleName = 'Az.PostgreSql'; RequiredVersion = '0.5.0'; }, + @{ModuleName = 'Az.PowerBIEmbedded'; RequiredVersion = '1.1.2'; }, + @{ModuleName = 'Az.PrivateDns'; RequiredVersion = '1.0.3'; }, + @{ModuleName = 'Az.ProviderHub'; RequiredVersion = '0.1.0'; }, + @{ModuleName = 'Az.RecoveryServices'; RequiredVersion = '3.7.0'; }, + @{ModuleName = 'Az.RedisCache'; RequiredVersion = '1.4.0'; }, + @{ModuleName = 'Az.RedisEnterpriseCache'; RequiredVersion = '1.0.0'; }, + @{ModuleName = 'Az.Relay'; RequiredVersion = '1.0.3'; }, + @{ModuleName = 'Az.Reservations'; RequiredVersion = '0.9.0'; }, + @{ModuleName = 'Az.ResourceGraph'; RequiredVersion = '0.10.0'; }, + @{ModuleName = 'Az.ResourceMover'; RequiredVersion = '1.0.0'; }, + @{ModuleName = 'Az.Resources'; RequiredVersion = '3.6.0'; }, + @{ModuleName = 'Az.Search'; RequiredVersion = '0.8.0'; }, + @{ModuleName = 'Az.Security'; RequiredVersion = '0.11.0'; }, + @{ModuleName = 'Az.SecurityInsights'; RequiredVersion = '1.0.0'; }, + @{ModuleName = 'Az.ServiceBus'; RequiredVersion = '1.5.0'; }, + @{ModuleName = 'Az.ServiceFabric'; RequiredVersion = '2.5.0'; }, + @{ModuleName = 'Az.SignalR'; RequiredVersion = '1.2.0'; }, + @{ModuleName = 'Az.SpringCloud'; RequiredVersion = '0.2.0'; }, + @{ModuleName = 'Az.Sql'; RequiredVersion = '2.18.0'; }, + @{ModuleName = 'Az.SqlVirtualMachine'; RequiredVersion = '1.1.0'; }, + @{ModuleName = 'Az.StackEdge'; RequiredVersion = '0.1.0'; }, + @{ModuleName = 'Az.StackHCI'; RequiredVersion = '0.5.0'; }, + @{ModuleName = 'Az.Storage'; RequiredVersion = '3.6.0'; }, + @{ModuleName = 'Az.StorageSync'; RequiredVersion = '1.5.0'; }, + @{ModuleName = 'Az.StreamAnalytics'; RequiredVersion = '2.2.0'; }, + @{ModuleName = 'Az.Subscription'; RequiredVersion = '0.8.0'; }, + @{ModuleName = 'Az.Support'; RequiredVersion = '1.0.0'; }, + @{ModuleName = 'Az.Synapse'; RequiredVersion = '0.11.0'; }, + @{ModuleName = 'Az.TimeSeriesInsights'; RequiredVersion = '0.2.0'; }, + @{ModuleName = 'Az.TrafficManager'; RequiredVersion = '1.0.4'; }, + @{ModuleName = 'Az.VMware'; RequiredVersion = '0.2.0'; }, + @{ModuleName = 'Az.Websites'; RequiredVersion = '2.5.0'; }, + @{ModuleName = 'Az.WindowsIotServices'; RequiredVersion = '0.1.0'; }) + +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = @() + +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = @() + +# Variables to export from this module +# VariablesToExport = @() + +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = @() + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +# FileList = @() + +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = 'Azure','ARM','ResourceManager','Linux','AzureAutomationNotSupported' + + # A URL to the license for this module. + LicenseUri = 'https://aka.ms/azps-license' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/Azure/azure-powershell' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + ReleaseNotes = '' + + # Prerelease string of this module + # Prerelease = '' + + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false + + # External dependent modules of this module + # ExternalModuleDependencies = @() + + } # End of PSData hashtable + + } # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} + diff --git a/tools/AzPreview/AzPreview.psd1.template b/tools/AzPreview/AzPreview.psd1.template new file mode 100644 index 000000000000..650f3be959c8 --- /dev/null +++ b/tools/AzPreview/AzPreview.psd1.template @@ -0,0 +1,133 @@ +# +# Module manifest for module 'AzPreview' +# +# Generated by: Microsoft Corporation +# +# Generated on: 5/17/2021 +# + +@{ + +# Script module or binary module file associated with this manifest. +# RootModule = '' + +# Version number of this module. +ModuleVersion = 'x.x.x' + +# Supported PSEditions +CompatiblePSEditions = 'Core', 'Desktop' + +# ID used to uniquely identify this module +GUID = '5052d1e8-69f1-4f91-8433-5400429b2db9' + +# Author of this module +Author = 'Microsoft Corporation' + +# Company or vendor of this module +CompanyName = 'Microsoft Corporation' + +# Copyright statement for this module +Copyright = 'Microsoft Corporation. All rights reserved.' + +# Description of the functionality provided by this module +Description = 'Microsoft Azure PowerShell - Including stable version and preview version of Azure PowerShell modules. This module is compatible with WindowsPowerShell and PowerShell Core. +For more information about the AzPreview module, please visit the following: https://docs.microsoft.com/en-us/powershell/azure/' + +# Minimum version of the PowerShell engine required by this module +PowerShellVersion = '5.1' + +# Name of the PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +DotNetFrameworkVersion = '4.7.2' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# CLRVersion = '' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = @() + +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = @() + +# Variables to export from this module +# VariablesToExport = @() + +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = @() + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +# FileList = @() + +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = 'Azure','ARM','ResourceManager','Linux','AzureAutomationNotSupported' + + # A URL to the license for this module. + LicenseUri = 'https://aka.ms/azps-license' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/Azure/azure-powershell' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + ReleaseNotes = '' + + # Prerelease string of this module + # Prerelease = '' + + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false + + # External dependent modules of this module + # ExternalModuleDependencies = @() + + } # End of PSData hashtable + + } # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} + diff --git a/tools/PublishModules.psm1 b/tools/PublishModules.psm1 index f790c2994c74..27ae097cc760 100644 --- a/tools/PublishModules.psm1 +++ b/tools/PublishModules.psm1 @@ -107,6 +107,7 @@ function Get-RollupModules { if ($IsNetCore) { # For .NetCore publish AzureRM.Netcore $targets += "$PSScriptRoot\Az" + $targets += "$PSScriptRoot\AzPreview" } else { $targets += "$PSScriptRoot\AzureRM" } diff --git a/tools/RunVersionController.ps1 b/tools/RunVersionController.ps1 index 0c458536cefb..043096d5cfad 100644 --- a/tools/RunVersionController.ps1 +++ b/tools/RunVersionController.ps1 @@ -183,6 +183,126 @@ function Get-ExistSerializedCmdletJsonFile return $(ls "$PSScriptRoot\Tools.Common\SerializedCmdlets").Name } +function Bump-AzVersion +{ + Write-Host "Getting local Az information..." -ForegroundColor Yellow + $localAz = Test-ModuleManifest -Path "$PSScriptRoot\Az\Az.psd1" + + Write-Host "Getting gallery Az information..." -ForegroundColor Yellow + $galleryAz = Find-Module -Name Az -Repository $GalleryName + + $versionBump = [PSVersion]::NONE + $updatedModules = @() + foreach ($galleryDependency in $galleryAz.Dependencies) + { + $localDependency = $localAz.RequiredModules | where { $_.Name -eq $galleryDependency.Name } + if ($localDependency -eq $null) + { + Write-Error "Could not find matching dependency for $($galleryDependency.Name)" + } + + $galleryVersion = $galleryDependency.RequiredVersion + if ([string]::IsNullOrEmpty($galleryVersion)) + { + $galleryVersion = $galleryDependency.MinimumVersion + } + $localVersion = $localDependency.Version.ToString() + if ($galleryVersion.ToString() -ne $localVersion) + { + $updatedModules += $galleryDependency.Name + $currBump = Get-VersionBump -GalleryVersion $galleryVersion.ToString() -LocalVersion $localVersion + Write-Host "Found $currBump version bump for $($localDependency.NAME)" + if ($currBump -eq [PSVersion]::MAJOR) + { + $versionBump = [PSVersion]::MAJOR + } + elseif ($currBump -eq [PSVersion]::MINOR -and $versionBump -ne [PSVersion]::MAJOR) + { + $versionBump = [PSVersion]::MINOR + } + elseif ($currBump -eq [PSVersion]::PATCH -and $versionBump -eq [PSVersion]::NONE) + { + $versionBump = [PSVersion]::PATCH + } + } + } + + if ($versionBump -eq [PSVersion]::NONE) + { + Write-Host "No changes found in Az." -ForegroundColor Green + return + } + + $newVersion = Get-BumpedVersion -Version $localAz.Version -VersionBump $versionBump + + Write-Host "New version of Az: $newVersion" -ForegroundColor Green + + $rootPath = "$PSScriptRoot\.." + $oldVersion = $galleryAz.Version + + Update-AzurecmdFile -OldVersion $oldVersion -NewVersion $newVersion -Release $Release -RootPath $rootPath + + # This was moved to the common repo + # Update-AzurePowerShellFile -OldVersion $oldVersion -NewVersion $newVersion -RootPath $rootPath + + $releaseNotes = @() + $releaseNotes += "$newVersion - $Release" + + $changeLog = @() + $changeLog += "## $newVersion - $Release" + foreach ($updatedModule in $updatedModules) + { + $releaseNotes += $updatedModule + $releaseNotes += $(Get-ReleaseNotes -Module $updatedModule -RootPath $rootPath) + "`n" + + $changeLog += "#### $updatedModule" + $changeLog += $(Get-ReleaseNotes -Module $updatedModule -RootPath $rootPath) + "`n" + } + + Update-ModuleManifest -Path "$PSScriptRoot\Az\Az.psd1" -ModuleVersion $newVersion -ReleaseNotes $releaseNotes + Update-ChangeLog -Content $changeLog -RootPath $rootPath +} + +function Generate-AzPreview +{ + # The version of AzPrview aligns with Az + $AzPrviewVersion = (Import-PowerShellDataFile "$PSScriptRoot\Az\Az.psd1").ModuleVersion + $SrcPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src" + $requiredModulesString = "RequiredModules = @(" + $rawRequiredModulesString = "RequiredModules = @\(" + foreach ($ModuleName in $(Get-ChildItem $SrcPath -Directory).Name) + { + $ModulePath = $(Join-Path -Path $SrcPath -ChildPath $ModuleName) + $Psd1FileName = "Az.{0}.psd1" -f $ModuleName + $Psd1FilePath = $(Get-ChildItem $ModulePath -Depth 2 -Recurse -Filter $Psd1FileName) + if ($null -ne $Psd1FilePath) + { + if($Psd1FilePath.Count -gt 1) + { + $Psd1FilePath = $Psd1FilePath[0] + } + $Psd1Object = Import-PowerShellDataFile $Psd1FilePath + $moduleName = "Az.${ModuleName}" + $moduleVersion = $Psd1Object.ModuleVersion.ToString() + $requiredModulesString += "@{ModuleName = '$moduleName'; RequiredVersion = '$moduleVersion'; }, + " + } + } + $requiredModulesString = $requiredModulesString.Trim() + $requiredModulesString = $requiredModulesString.TrimEnd(",") + + $AzPrviewTemplate = Get-Item -Path "$PSScriptRoot\AzPreview\AzPreview.psd1.template" + $AzPrviewTemplateContent = Get-Content -Path $AzPrviewTemplate.FullName + $AzPreviewPsd1Content = $AzPrviewTemplateContent | % { + $_ -replace "ModuleVersion = 'x.x.x'", "ModuleVersion = '$AzPrviewVersion'" + } | % { + $_ -replace "$rawRequiredModulesString", "$requiredModulesString" + } + + $AzPrviewPsd1 = New-Item -Path "$PSScriptRoot\AzPreview\" -Name "AzPreview.psd1" -ItemType "file" -Force + Set-Content -Path $AzPrviewPsd1.FullName -Value $AzPreviewPsd1Content -Encoding UTF8 +} + switch ($PSCmdlet.ParameterSetName) { "ReleaseSingleModule" @@ -239,81 +359,8 @@ switch ($PSCmdlet.ParameterSetName) Write-Host executing dotnet $PSScriptRoot/../artifacts/VersionController/VersionController.Netcore.dll dotnet $PSScriptRoot/../artifacts/VersionController/VersionController.Netcore.dll - Write-Host "Getting local Az information..." -ForegroundColor Yellow - $localAz = Test-ModuleManifest -Path "$PSScriptRoot\Az\Az.psd1" - - Write-Host "Getting gallery Az information..." -ForegroundColor Yellow - $galleryAz = Find-Module -Name Az -Repository $GalleryName - - $versionBump = [PSVersion]::NONE - $updatedModules = @() - foreach ($galleryDependency in $galleryAz.Dependencies) - { - $localDependency = $localAz.RequiredModules | where { $_.Name -eq $galleryDependency.Name } - if ($localDependency -eq $null) - { - Write-Error "Could not find matching dependency for $($galleryDependency.Name)" - } - - $galleryVersion = $galleryDependency.RequiredVersion - if ([string]::IsNullOrEmpty($galleryVersion)) - { - $galleryVersion = $galleryDependency.MinimumVersion - } - $localVersion = $localDependency.Version.ToString() - if ($galleryVersion.ToString() -ne $localVersion) - { - $updatedModules += $galleryDependency.Name - $currBump = Get-VersionBump -GalleryVersion $galleryVersion.ToString() -LocalVersion $localVersion - Write-Host "Found $currBump version bump for $($localDependency.NAME)" - if ($currBump -eq [PSVersion]::MAJOR) - { - $versionBump = [PSVersion]::MAJOR - } - elseif ($currBump -eq [PSVersion]::MINOR -and $versionBump -ne [PSVersion]::MAJOR) - { - $versionBump = [PSVersion]::MINOR - } - elseif ($currBump -eq [PSVersion]::PATCH -and $versionBump -eq [PSVersion]::NONE) - { - $versionBump = [PSVersion]::PATCH - } - } - } - - if ($versionBump -eq [PSVersion]::NONE) - { - Write-Host "No changes found in Az." -ForegroundColor Green - return - } - - $newVersion = Get-BumpedVersion -Version $localAz.Version -VersionBump $versionBump - - Write-Host "New version of Az: $newVersion" -ForegroundColor Green - - $rootPath = "$PSScriptRoot\.." - $oldVersion = $galleryAz.Version - - Update-AzurecmdFile -OldVersion $oldVersion -NewVersion $newVersion -Release $Release -RootPath $rootPath - - # This was moved to the common repo - # Update-AzurePowerShellFile -OldVersion $oldVersion -NewVersion $newVersion -RootPath $rootPath - - $releaseNotes = @() - $releaseNotes += "$newVersion - $Release" - - $changeLog = @() - $changeLog += "## $newVersion - $Release" - foreach ($updatedModule in $updatedModules) - { - $releaseNotes += $updatedModule - $releaseNotes += $(Get-ReleaseNotes -Module $updatedModule -RootPath $rootPath) + "`n" - - $changeLog += "#### $updatedModule" - $changeLog += $(Get-ReleaseNotes -Module $updatedModule -RootPath $rootPath) + "`n" - } + Bump-AzVersion - Update-ModuleManifest -Path "$PSScriptRoot\Az\Az.psd1" -ModuleVersion $newVersion -ReleaseNotes $releaseNotes - Update-ChangeLog -Content $changeLog -RootPath $rootPath + Generate-AzPreview } } \ No newline at end of file diff --git a/tools/UpdateModules.psm1 b/tools/UpdateModules.psm1 index 4c8483cf11e2..662301842ba6 100644 --- a/tools/UpdateModules.psm1 +++ b/tools/UpdateModules.psm1 @@ -454,4 +454,9 @@ function Update-Netcore { Write-Host "Updating Netcore module from $modulePath" New-ModulePsm1 -ModulePath $modulePath -TemplatePath $script:TemplateLocation -IsNetcore Write-Host "Updated Netcore module" + + $modulePath = "$PSScriptRoot\AzPreview" + Write-Host "Updating Netcore module from $modulePath" + New-ModulePsm1 -ModulePath $modulePath -TemplatePath $script:TemplateLocation -IsNetcore + Write-Host "Updated Netcore module" }