From 694edf6563554e03b91c936f2e092fe7316b058f Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Thu, 28 Mar 2024 11:40:07 +0100 Subject: [PATCH] - Trying to get real signing to work - Some reorg of file structure - Some other new piplines work --- .azure-devops/build-core-lib.yml | 4 +- .../common/{versioning.yml => version.yml} | 0 Microsoft.FluentUI.sln | 13 -- THIRD-PARTY-NOTICES.TXT | 34 ++++ CONTRIBUTING.md => docs/contributing.md | 0 unit-tests.md => docs/unit-tests.md | 0 eng/pipelines/azure-pipelines.yml | 191 ++++++++++++++++++ eng/pipelines/common-variables.yaml | 23 +++ eng/pipelines/update-assembly-version.ps1 | 157 ++++++++++++++ eng/pipelines/version.yml | 6 + 10 files changed, 413 insertions(+), 15 deletions(-) rename .azure-devops/common/{versioning.yml => version.yml} (100%) create mode 100644 THIRD-PARTY-NOTICES.TXT rename CONTRIBUTING.md => docs/contributing.md (100%) rename unit-tests.md => docs/unit-tests.md (100%) create mode 100644 eng/pipelines/azure-pipelines.yml create mode 100644 eng/pipelines/common-variables.yaml create mode 100644 eng/pipelines/update-assembly-version.ps1 create mode 100644 eng/pipelines/version.yml diff --git a/.azure-devops/build-core-lib.yml b/.azure-devops/build-core-lib.yml index 7decb46d7..be1a4dc46 100644 --- a/.azure-devops/build-core-lib.yml +++ b/.azure-devops/build-core-lib.yml @@ -18,10 +18,10 @@ parameters: default: '**/Microsoft.FluentUI.AspNetCore.Components.Tests.csproj' variables: - - template: common/versioning.yml@self # Versions + - template: common/version.yml@self - name: SignType - value: 'real' + value: real # The `resources` specify the location and version of the 1ES PT. resources: diff --git a/.azure-devops/common/versioning.yml b/.azure-devops/common/version.yml similarity index 100% rename from .azure-devops/common/versioning.yml rename to .azure-devops/common/version.yml diff --git a/Microsoft.FluentUI.sln b/Microsoft.FluentUI.sln index 3852ffa4b..149d47e63 100644 --- a/Microsoft.FluentUI.sln +++ b/Microsoft.FluentUI.sln @@ -3,19 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.7.33808.371 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{805140F8-CC9F-4C32-BB72-3D67D13BEBA7}" - ProjectSection(SolutionItems) = preProject - CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md - CONTRIBUTING.md = CONTRIBUTING.md - LICENSE = LICENSE - README.md = README.md - SECURITY.md = SECURITY.md - unit-tests.md = unit-tests.md - WHATSNEW.md = WHATSNEW.md - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "eng", "eng", "{558E0FEA-094D-4AA4-994A-8ED67ABEDED4}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{141FEF3E-C665-4D50-8E51-B9507C98040E}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{9468ADD1-3660-410D-8231-6F89384D135D}" diff --git a/THIRD-PARTY-NOTICES.TXT b/THIRD-PARTY-NOTICES.TXT new file mode 100644 index 000000000..c7ad816be --- /dev/null +++ b/THIRD-PARTY-NOTICES.TXT @@ -0,0 +1,34 @@ +We uses third-party libraries or other resources that may be +distributed under licenses different than the Fluent UI Blazor library software. + +In the event that we accidentally failed to list a required notice, please +bring it to our attention. Post an issue or email us: + + fluentui-blazor@microsoft.com + +The attached notices are provided for information only. + +License notice for Bootstrap +--------------------------- + +The MIT License (MIT) + +Copyright (c) 2011-2023 The Bootstrap Authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/CONTRIBUTING.md b/docs/contributing.md similarity index 100% rename from CONTRIBUTING.md rename to docs/contributing.md diff --git a/unit-tests.md b/docs/unit-tests.md similarity index 100% rename from unit-tests.md rename to docs/unit-tests.md diff --git a/eng/pipelines/azure-pipelines.yml b/eng/pipelines/azure-pipelines.yml new file mode 100644 index 000000000..657b93e3e --- /dev/null +++ b/eng/pipelines/azure-pipelines.yml @@ -0,0 +1,191 @@ +# Build and test Core project. +name: $(FileVersion).$(Year:yy)$(DayOfYear).$(Rev:r) + +trigger: + batch: true + branches: + include: + - main + - dev + + paths: + include: + - '*' + exclude: + - .github/* + - .devcontainer/* + - docs/* + - CODE_OF_CONDUCT.md + - README.md + - SECURITY.md + - LICENSE.TXT + - THIRD-PARTY-NOTICES.TXT + +pr: + branches: + include: + - main + - dev + + paths: + include: + - '*' + exclude: + - .github/* + - .devcontainer/* + - docs/* + - CODE_OF_CONDUCT.md + - README.md + - SECURITY.md + - LICENSE.TXT + - THIRD-PARTY-NOTICES.TXT + +variables: + - template: /eng/pipelines/common-variables.yml@self + - template: /eng/pipelines/common/version.yml@self + + - name: _BuildConfig + value: Release + - name: Build.Arcade.ArtifactsPath + value: $(Build.SourcesDirectory)/artifacts/ + - name: Build.Arcade.LogsPath + value: $(Build.Arcade.ArtifactsPath)log/$(_BuildConfig)/ + - name: Build.Arcade.TestResultsPath + value: $(Build.Arcade.ArtifactsPath)TestResults/$(_BuildConfig)/ + + # Produce test-signed build for PR and Public builds + - ${{ if or(eq(variables['_RunAsPublic'], 'true'), eq(variables['Build.Reason'], 'PullRequest')) }}: + # needed for darc (dependency flow) publishing + - name: _PublishArgs + value: '' + - name: _OfficialBuildIdArgs + value: '' + # needed for signing + - name: _SignType + value: test + - name: _SignArgs + value: '' + - name: _Sign + value: false + + # Set up non-PR build from internal project + - ${{ if and(ne(variables['_RunAsPublic'], 'true'), ne(variables['Build.Reason'], 'PullRequest')) }}: + # needed for darc (dependency flow) publishing + - name: _PublishArgs + value: >- + /p:DotNetPublishUsingPipelines=true + - name: _OfficialBuildIdArgs + value: /p:OfficialBuildId=$(BUILD.BUILDNUMBER) + # needed for signing + - name: _SignType + value: real + - name: _SignArgs + value: /p:DotNetSignType=$(_SignType) /p:TeamName=$(_TeamName) /p:Sign=$(_Sign) /p:DotNetPublishUsingPipelines=true + - name: _Sign + value: true + +resources: + repositories: + - repository: 1ESPipelineTemplates + type: git + name: 1ESPipelineTemplates/1ESPipelineTemplates + ref: refs/tags/release + +extends: + template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates + parameters: + sdl: + eslint: + enabled: false + justificationForDisabling: 'see https://portal.microsofticm.com/imp/v3/incidents/incident/482258316/summary' + sourceAnalysisPool: + name: NetCore1ESPool-Internal + image: windows.vs2022preview.amd64 + os: windows + + stages: + + # ---------------------------------------------------------------- + # This stage performs build, test, packaging + # ---------------------------------------------------------------- + - stage: build + displayName: Build + jobs: + - template: /eng/common/templates-official/jobs/jobs.yml@self + parameters: + enableMicrobuild: true + # Publish NuGet packages using v3 + # https://github.com/dotnet/arcade/blob/main/Documentation/CorePackages/Publishing.md#basic-onboarding-scenario-for-new-repositories-to-the-current-publishing-version-v3 + enablePublishUsingPipelines: true + enablePublishBuildAssets: true + enableTelemetry: true + enableSourceIndex: false + # Publish build logs + enablePublishBuildArtifacts: true + # Publish test logs + enablePublishTestResults: true + workspace: + clean: all + + jobs: + + - job: Windows + # timeout accounts for wait times for helix agents up to 30mins + timeoutInMinutes: 60 + + pool: + name: NetCore1ESPool-Internal + image: windows.vs2022preview.amd64 + os: windows + + variables: + - name: _buildScript + value: $(Build.SourcesDirectory)/build.cmd -ci + + preSteps: + - checkout: self + fetchDepth: 1 + clean: true + + steps: + - template: /eng/pipelines/templates/BuildAndTest.yml + parameters: + dotnetScript: $(Build.SourcesDirectory)/dotnet.cmd + buildScript: $(_buildScript) + buildConfig: $(_BuildConfig) + repoArtifactsPath: $(Build.Arcade.ArtifactsPath) + repoLogPath: $(Build.Arcade.LogsPath) + repoTestResultsPath: $(Build.Arcade.TestResultsPath) + isWindows: true + + - ${{ if and(notin(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/main')) }}: + - template: /eng/common/templates-official/job/onelocbuild.yml@self + parameters: + LclSource: lclFilesfromPackage + LclPackageId: 'LCL-JUNO-PROD-ASPIRE' + MirrorRepo: aspire + MirrorBranch: main + + - template: /eng/common/templates-official/post-build/post-build.yml@self + parameters: + validateDependsOn: + - build + publishingInfraVersion: 3 + enableSymbolValidation: false + enableSigningValidation: false + enableNugetValidation: false + enableSourceLinkValidation: false + # these param values come from the DotNet-Winforms-SDLValidation-Params azdo variable group + SDLValidationParameters: + enable: false + params: ' -SourceToolsList $(_TsaSourceToolsList) + -TsaInstanceURL $(_TsaInstanceURL) + -TsaProjectName $(_TsaProjectName) + -TsaNotificationEmail $(_TsaNotificationEmail) + -TsaCodebaseAdmin $(_TsaCodebaseAdmin) + -TsaBugAreaPath $(_TsaBugAreaPath) + -TsaIterationPath $(_TsaIterationPath) + -TsaRepositoryName $(_TsaRepositoryName) + -TsaCodebaseName $(_TsaCodebaseName) + -TsaOnboard $(_TsaOnboard) + -TsaPublish $(_TsaPublish)' diff --git a/eng/pipelines/common-variables.yaml b/eng/pipelines/common-variables.yaml new file mode 100644 index 000000000..bc468c400 --- /dev/null +++ b/eng/pipelines/common-variables.yaml @@ -0,0 +1,23 @@ +variables: + - name: _TeamName + value: fluentui-blazor + - name: _RunAsPublic + value: True + - name: _RunAsInternal + value: False + + - ${{ if notin(variables['Build.Reason'], 'PullRequest') }}: + - name: _RunAsPublic + value: False + - name: _RunAsInternal + value: True + - name: _SignType + value: real + - group: SDL_Settings + - name: _InternalBuildArgs + value: /p:DotNetSignType=$(_SignType) + /p:TeamName=$(_TeamName) + /p:DotNetPublishUsingPipelines=true + /p:OfficialBuildId=$(BUILD.BUILDNUMBER) + #- name: PostBuildSign + # value: true diff --git a/eng/pipelines/update-assembly-version.ps1 b/eng/pipelines/update-assembly-version.ps1 new file mode 100644 index 000000000..68a07d5f6 --- /dev/null +++ b/eng/pipelines/update-assembly-version.ps1 @@ -0,0 +1,157 @@ +<# +.DESCRIPTION + Update all .csproj files, adding these properties, excluding the files from $excludePatterns + - `AssemblyVersion = $assemblyVersion`, + - `FileVersion = $assemblyVersion`, + - `InformationalVersion = $assemblyVersion`, + - `Version = $packageVersion`, + +.PARAMETER sourcePath + Source path to list all .csproj files, by default the current path is used. + +.PARAMETER excludePatterns + List of files to exclude so as not to update the contents of the .csproj file. + +.PARAMETER assemblyVersion + Assembly version. + +.PARAMETER packageVersion + Package version. + +.EXAMPLE + $> .\update-assembly-version -sourcePath "./" -excludePatterns "**/src/Templates/content/**/*.csproj", "**/tests/TemplateValidation/**/*.csproj" -assemblyVersion "1.2.3" -packageVersion "1.2.3" + +.EXAMPLE + # Set version number (exclude some folders) + - task: PowerShell@2 + displayName: 'Versioning $(Build.BuildNumber)' + inputs: + targetType: 'filePath' + filePath: $(System.DefaultWorkingDirectory)/.azure-devops/common/update-assembly-version.ps1 + arguments: > # Use this to avoid newline characters in multiline string + -sourcePath "$(System.DefaultWorkingDirectory)/" + -excludePatterns "**/src/Templates/content/**/*.csproj", "**/tests/TemplateValidation/**/*.csproj" + -assemblyVersion "$(AssemblyVersion)" + -packageVersion "$(PackageVersion)" +#> + +param ( + [string]$sourcePath, + [string[]]$excludePatterns = @(), + [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string]$assemblyVersion, + [string]$packageVersion +) + + +# Define the patterns +$includePattern = "$sourcePath/**/*.csproj" + +if ($assemblyVersion -eq $null) { + $assemblyVersion = "0.0.1" +} + +if ($packageVersion -eq $null) { + $packageVersion = $assemblyVersion +} + +Write-Host "Add or update assemblies versions '$assemblyVersion' and package versions '$packageVersion'." +Write-Host " - include: $includePattern." +Write-Host " - exclude: $excludePatterns." + +# ------------------------------------------ +# Get all files matching the include pattern +# And matching the exclude patterns +# ------------------------------------------ +function Get-FilesFromDirectory { + param ( + [string]$includePattern, + [string[]]$excludePatterns + ) + + # Get all files matching the include pattern + $allFiles = Get-ChildItem -Path $includePattern -Recurse + + + # Get all files matching the exclude pattern => $filteredFiles + $excludedFiles = @() # Empty array + if ($excludePatterns.Length -gt 0) { + foreach ($pattern in $excludePatterns) { + # Create a RegEx: replacing "**" by ".*", "*" by "[^/]*" + $parts = $pattern -split '[\\/]' + foreach ($i in 0..($parts.Length - 1)) { + if ($parts[$i] -eq '**') { + $parts[$i] = '.*' + } + if ($parts[$i] -eq '*') { + $parts[$i] = '[^/]*' + } + } + $excludeRegEx = $parts -join "\/" + + # Check all files to detect the matching one + foreach ($file in $allFiles) { + $match1 = ($file.FullName -replace "\\", "/") -match $excludeRegEx + if ($match1) { + $excludedFiles += $file.FullName + } + } + } + + # Exclude found files + $filteredFiles = $allFiles | Where-Object { $_.FullName -notin $excludedFiles } + } + + return $filteredFiles; +} + +# ------------------------------------------------------------- +# Add or update the PropertyName tag, to set the PropertyValue. +# in the XML file name +# ------------------------------------------------------------- +function Update-PropertyGroup { + param ( + [string]$fileName, + [string]$propertyName, + [string]$propertyValue + ) + + # Load the XML file and find the first "default" PropertyGroup + $xmlDoc = New-Object System.Xml.XmlDocument + $xmlDoc.Load($fileName) + + $propertyGroup = $xmlDoc.SelectSingleNode("//Project//PropertyGroup") + + # Find the VersionNumber element + $propertyTag = $xmlDoc.SelectSingleNode("//Project//PropertyGroup//$propertyName") + + if ($null -eq $propertyTag) { + $propertyTag = $xmlDoc.CreateElement($propertyName) + $propertyGroup.AppendChild($propertyTag) > $null # Suppress the output + } + + # Update the text value of the VersionNumber element + $propertyTag.InnerText = $propertyValue + + # Save the updated XML back to the file + $xmlDoc.Save($fileName) +} + +# ------------------------------------------ +# Main calls +# ------------------------------------------ +$filteredFiles = Get-FilesFromDirectory -includePattern $includePattern -excludePatterns $excludePatterns + +# Update the PropertyGroup items... +# - VersionNumber: '$(assemblyVersion)' +# - FileVersionNumber: '$(assemblyVersion)' +# - InformationalVersion: '$(assemblyVersion)' +# - PackageVersion: '$(packageVersion)' +foreach ($file in $filteredFiles) { + $name = $file.Name + $fileName = $file.FullName + Write-Host " .. Updating $name" + Update-PropertyGroup -fileName $fileName -propertyName "AssemblyVersion" -propertyValue $assemblyVersion + Update-PropertyGroup -fileName $fileName -propertyName "FileVersion" -propertyValue $assemblyVersion + Update-PropertyGroup -fileName $fileName -propertyName "InformationalVersion" -propertyValue $assemblyVersion + Update-PropertyGroup -fileName $fileName -propertyName "Version" -propertyValue $packageVersion +} diff --git a/eng/pipelines/version.yml b/eng/pipelines/version.yml new file mode 100644 index 000000000..2958fd10a --- /dev/null +++ b/eng/pipelines/version.yml @@ -0,0 +1,6 @@ +variables: + # File and Package version + # dev branch: 1.2.4-Preview-23282-1' (PackageSuffix is always ignored in Dev branch) + # main branch: 1.2.4-RC.1' (PackageSuffix is ignored, if empty, in Main branch) + FileVersion: '4.6.0' # Set the next final version here. + PackageSuffix: ''