Skip to content

Sync tools code from main branch to generation branch #23843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 29, 2023
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
27 changes: 25 additions & 2 deletions .azure-pipelines/code-sign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ parameters:
displayName: Branch for OOB pipeline
type: string
default: 'none'
- name: TargetModule
displayName: Build Module List(Split by ':')
type: string
default: 'none'
- name: BuildInstaller
displayName: Build Installer
type: boolean
default: true
jobs:
- job: Release
timeoutInMinutes: 180
Expand Down Expand Up @@ -31,10 +39,19 @@ jobs:

- task: DotNetCoreCLI@2
displayName: Build
condition: ne('${{ parameters.TargetModule }}', 'none')
inputs:
command: custom
custom: msbuild
arguments: 'build.proj /t:"Build;CopyAboutTopics;GenerateHelp" /p:"Configuration=Release;GenerateDocumentationFile=true;TargetModule=${{ parameters.TargetModule }}"'
- task: DotNetCoreCLI@2
displayName: Build
condition: eq('${{ parameters.TargetModule }}', 'none')
inputs:
command: custom
custom: msbuild
arguments: 'build.proj /t:"Build;CopyAboutTopics;GenerateHelp" /p:"Configuration=Release;GenerateDocumentationFile=true"'
arguments: 'build.proj /t:"Build;CopyAboutTopics;GenerateHelp" /p:"Configuration=Release;GenerateDocumentationFile=true;ModifiedModuleBuild=true"'


- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
displayName: 'Manifest Generator '
Expand Down Expand Up @@ -359,9 +376,11 @@ jobs:
./setup/generate.ps1 -repository MSIcreationrepository
Unregister-PSRepository -Name MSIcreationrepository
displayName: 'Build Installer'
condition: eq(${{ parameters.buildInstaller }}, true)

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@4
displayName: 'Installer Signing [Authenticode]'
condition: eq(${{ parameters.buildInstaller }}, true)
inputs:
ConnectedServiceName: 'ESRP Signing Service'
FolderPath: setup
Expand Down Expand Up @@ -404,9 +423,11 @@ jobs:
Get-ChildItem $Env:RepoArtifacts/$folderName
Copy-Item $Env:RepoArtifacts/$Env:Configuration/InstallModule.ps1 -Destination $Env:RepoArtifacts/$folderName
displayName: 'Gather nuget packages and install script'
condition: eq(${{ parameters.buildInstaller }}, true)

- task: ArchiveFiles@2
displayName: 'Pack nuget packages as Az-Cmdlets-latest.tar.gz'
condition: eq(${{ parameters.buildInstaller }}, true)
inputs:
rootFolderOrFile: 'artifacts/$(LocalRepoName)'
includeRootFolder: false
Expand All @@ -432,9 +453,11 @@ jobs:
" - "+$sha256.Hash+"`n"
New-Item -Path "setup" -Name "ReleaseNotes.txt" -ItemType File -Force -Value $value
displayName: 'Rename Az-Cmdlets-latest.tar.gz and Calculate SHA256'
condition: eq(${{ parameters.buildInstaller }}, true)

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: installer'
condition: eq(${{ parameters.buildInstaller }}, true)
inputs:
PathtoPublish: setup
ArtifactName: setup
Expand Down Expand Up @@ -468,4 +491,4 @@ jobs:
Get-ChildItem -Path $Env:RepoArtifacts -Filter Az.*.0.*.*.nupkg | Compress-Archive -DestinationPath "$buildName-preview.zip" -PassThru | Set-AzStorageBlobContent -Container $(ContainerName) -Context $context -Force
azurePowerShellVersion: LatestVersion
pwsh: true
condition: and(succeeded(), eq(variables['PushPackageToStorageAccount'], 'true'))
condition: and(succeeded(), eq(variables['PushPackageToStorageAccount'], 'true'), eq(${{ parameters.buildInstaller }}, true))
24 changes: 14 additions & 10 deletions tools/RunVersionController.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ Param(
[string]$GalleryName = "PSGallery",

[Parameter()]
[string]$ArtifactsOutputPath = "$PSScriptRoot/../artifacts/Release/",

[Parameter()]
[switch]$GenerateSyntaxChangelog
[string]$ArtifactsOutputPath = "$PSScriptRoot/../artifacts/Release/"
)

enum PSVersion
Expand Down Expand Up @@ -403,8 +400,16 @@ function Update-AzSyntaxChangelog
Write-Host "starting revise SyntaxChangeLog"
$rootPath = "$PSScriptRoot\.."
$NewVersion = (Import-PowerShellDataFile "$PSScriptRoot\Az\Az.psd1").ModuleVersion
Update-ChangeLog -Content "## $NewVersion - $Release" -FilePath "$rootPath\documentation\SyntaxChangeLog.md"
$changeLog = Get-Content "$rootPath\documentation\SyntaxChangeLog.md" -Raw
$majorVersion = $NewVersion.Split('.')[0]
$syntaxChangeLog = "$rootPath\documentation\SyntaxChangeLog\SyntaxChangeLog.md"
Update-ChangeLog -Content "## $NewVersion - $Release" -FilePath $syntaxChangeLog
$changeLog = Get-Content $syntaxChangeLog -Raw
$targetFile = "$rootPath\documentation\SyntaxChangeLog\SyntaxChangeLog-Az$majorVersion.md"
if (-not (Test-Path $targetFile)) {
New-Item -Path $targetFile -ItemType File
}
$currentContent = Get-Content -Path $targetFile -Raw
$newContent = $changeLog + "`r`n" + $currentContent
$regex = '####\s+(Az\.\w+)\s+(?![\d\.])'
$matches = Select-String -Pattern $regex -InputObject $changelog -AllMatches
foreach ($match in $matches.Matches) {
Expand All @@ -414,7 +419,8 @@ function Update-AzSyntaxChangelog
$replacement = "#### $moduleName $newVersion `r`n"
$changelog = $changelog -replace [regex]::Escape($match.Value), $replacement
}
Set-Content -Path "$rootPath\documentation\SyntaxChangeLog.md" -Value $changelog
Set-Content -Path $targetFile -Value $newContent
Remove-Item -Path $syntaxChangeLog
}

function New-CommandMappingFile
Expand Down Expand Up @@ -523,9 +529,7 @@ switch ($PSCmdlet.ParameterSetName)
# Refresh AzPreview.psd1
Update-AzPreview
Update-AzPreviewChangelog
if ($GenerateSyntaxChangelog){
Update-AzSyntaxChangelog
}
Update-AzSyntaxChangelog
# We need to generate the upcoming-breaking-changes.md after the process of bump version in minor release
if ([PSVersion]::MINOR -Eq $versionBump)
{
Expand Down
4 changes: 2 additions & 2 deletions tools/VersionController/Models/SyntaxChangelogGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@ public void Analyze(String rootDirectory)
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath);
Directory.SetCurrentDirectory(executingPath);
var newModuleMetadata = MetadataLoader.GetModuleMetadata(moduleName);
Console.WriteLine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", ".."));
var filePath = Path.Combine(executingPath, "SerializedCmdlets", $"{moduleName}.json");
if (!File.Exists(filePath)) continue;
var oldModuleMetadata = ModuleMetadata.DeserializeCmdlets(filePath);
CmdletLoader.ModuleMetadata = newModuleMetadata;
CompareModuleMetedata(oldModuleMetadata, newModuleMetadata, moduleName);
}
var markDownPath = Path.Combine(rootDirectory, "documentation/SyntaxChangeLog.md");
var markDownPath = Path.Combine(rootDirectory, "documentation/SyntaxChangeLog/SyntaxChangeLog.md");
GenerateMarkdown(markDownPath);
Console.WriteLine("Cmdlets Differences written to {0}", markDownPath);
}
Expand Down Expand Up @@ -445,6 +444,7 @@ public void GenerateMarkdown(string filePath)
}
}
}
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
File.AppendAllText(filePath, sb.ToString());
}
private string FormatListString(List<string> list, Func<string, string> formatter)
Expand Down
10 changes: 3 additions & 7 deletions tools/VersionController/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void Main(string[] args)
var executingAssemblyPath = Assembly.GetExecutingAssembly().Location;
var versionControllerDirectory = Directory.GetParent(executingAssemblyPath).FullName;
var artifactsDirectory = Directory.GetParent(versionControllerDirectory).FullName;
var syntaxChangelog = "false";
var syntaxChangelog = true;
_rootDirectory = Directory.GetParent(artifactsDirectory).FullName;
_projectDirectories = new List<string>{ Path.Combine(_rootDirectory, @"src\") }.Where((d) => Directory.Exists(d)).ToList();
_outputDirectories = new List<string>{ Path.Combine(_rootDirectory, @"artifacts\Release\") }.Where((d) => Directory.Exists(d)).ToList();
Expand All @@ -61,6 +61,7 @@ public static void Main(string[] args)
if (args != null && args.Length > 0)
{
exceptionsDirectory = args[0];
syntaxChangelog = false;
}

if (!Directory.Exists(exceptionsDirectory))
Expand All @@ -74,14 +75,9 @@ public static void Main(string[] args)
_moduleNameFilter = args[1] + Psd1NameExtension;
}

if (args != null && args.Length > 2)
{
syntaxChangelog = args[2];
}

ConsolidateExceptionFiles(exceptionsDirectory);
ValidateManifest();
if (syntaxChangelog.Equals("true", System.StringComparison.OrdinalIgnoreCase)) {
if (syntaxChangelog) {
GenerateSyntaxChangelog(_rootDirectory);
}
BumpVersions();
Expand Down