Correctly include Git commit in versioning; Lift pipeline build options to queue-time settable parameters; Fiddle with SBOM options (#244)

This commit is contained in:
Steve Molloy 2024-10-02 23:16:29 -07:00 коммит произвёл GitHub
Родитель ca2b3b74b0
Коммит 2c6b8cae3b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 59 добавлений и 29 удалений

Просмотреть файл

@ -21,27 +21,40 @@ resources:
name: 1ESPipelineTemplates/MicroBuildTemplate
ref: refs/tags/release
name: $(Date:yyyyMMdd).$(Rev:r)
variables:
- name: EnableNuGetPackageRestore
value: true
- name: Packaging.EnableSBOMSigning
value: true
parameters:
- name: SkipAzureAppConfigProj
value: false
type: boolean
default: false
- name: SkipAzureProj
value: false
type: boolean
default: false
- name: SkipEnvironmentProj
value: false
type: boolean
default: false
- name: SkipJsonProj
value: false
type: boolean
default: false
- name: SkipKeyPerFileProj
value: false
- name: SkipPackageRestore
value: true
type: boolean
default: false
- name: SkipUserSecretsProj
value: false
- name: TeamName
value: Asp.Net
type: boolean
default: false
variables:
TeamName: Asp.Net
EnableNuGetPackageRestore: true
SkipPackageRestore: false
SkipAzureAppConfigProj: ${{ parameters.SkipAzureAppConfigProj }}
SkipAzureProj: ${{ parameters.SkipAzureProj }}
SkipEnvironmentProj: ${{ parameters.SkipEnvironmentProj }}
SkipJsonProj: ${{ parameters.SkipJsonProj }}
SkipKeyPerFileProj: ${{ parameters.SkipKeyPerFileProj }}
SkipUserSecretsProj: ${{ parameters.SkipUserSecretsProj }}
# Define these at 'Queue Run...' time to enable full Azure-based tests
# Microsoft.Configuration.ConfigurationBuilders.Test.AKV.Common: ''
# Microsoft.Configuration.ConfigurationBuilders.Test.AKV.Custom: ''
# Microsoft.Configuration.ConfigurationBuilders.Test.AzConfig.Common: ''
# Microsoft.Configuration.ConfigurationBuilders.Test.AzConfig.Common: ''
extends:
template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate
parameters:
@ -62,7 +75,7 @@ extends:
timeoutInMinutes: 120
cancelTimeoutInMinutes: 1
pool:
name: VSEngSS-MicroBuild2019-1ES
name: VSEngSS-MicroBuild2022-1ES
templateContext:
mb:
signing:
@ -72,8 +85,14 @@ extends:
outputs:
- output: pipelineArtifact
displayName: 'Publish Artifact: Nuget packages'
targetPath: $(Build.SourcesDirectory)\.binaries\Packages\Release
artifactName: Nuget packages
targetPath: $(Build.SourcesDirectory)\.binaries\Packages\Release
sbomEnabled: true
sbomBuildDropPath: $(Build.SourcesDirectory)\.binaries\Packages\Release
sbomBuildComponentPath: $(Build.SourcesDirectory)\.binaries\Packages\Release
sbomPackageName: Microsoft.Configuration.ConfigurationBuilders
# sbomPackageVersion: $(NugetPackageVersion)
sbomValidate: true
steps:
- checkout: self
clean: true
@ -100,7 +119,7 @@ extends:
msbuildVersion: 17.0
msbuildArchitecture: x64
configuration: Release
msbuildArguments: /p:GitCommit=%BUILD_SOURCEVERSION% /p:GitCommitLink="https://github.com/aspnet/MicrosoftConfigurationBuilders/commit/%BUILD_SOURCEVERSION%" /p:SignType=real /p:SignAssembly=true /verbosity:n
msbuildArguments: /p:GitCommit=$(Build.SourceVersion) /p:GitCommitLink="https://github.com/aspnet/MicrosoftConfigurationBuilders/commit/$(Build.SourceVersion)" /p:SignType=real /p:SignAssembly=true /p:SkipAzureAppConfigProj=$(SkipAzureAppConfigProj) /p:SkipAzureProj=$(SkipAzureProj) /p:SkipEnvironmentProj=$(SkipEnvironmentProj) /p:SkipJsonProj=$(SkipJsonProj) /p:SkipKeyPerFileProj=$(SkipKeyPerFileProj) /p:SkipPackageRestore=$(SkipPackageRestore) /p:SkipUserSecretsProj=$(SkipUserSecretsProj) /verbosity:n
clean: true
createLogFile: true
logFileVerbosity: detailed

Просмотреть файл

@ -25,6 +25,7 @@
-->
<BuildQuality Condition="'$(BuildQuality)' == ''">rtm</BuildQuality>
<VersionStartYear>2022</VersionStartYear>
<!-- Update version in config.xdt's for major/minor changes. (Don't update for 'release' changes.) -->
<VersionMajor>3</VersionMajor>
<VersionMinor>0</VersionMinor>
<VersionRevision>0</VersionRevision>

Просмотреть файл

@ -9,7 +9,7 @@ Project global versioning targets.
<!-- NOTE: The VersionFileAttribute ItemGroup can be used to add assembly-level attributes to the generated version file, ex:
<VersionFileAttribute Include="[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(&quot;Microsoft.Usage&quot;, &quot;CA2243:AttributeStringLiteralsShouldParseCorrectly&quot;, Justification = &quot;Justification here&quot;)]" />
-->
<PropertyGroup>
<VersionFileGenerationEnabled Condition="'$(VersionFileGenerationEnabled)' == '' AND '$(MSBuildProjectExtension)' == '.csproj'">true</VersionFileGenerationEnabled>
<VersionFileGenerationEnabled Condition="'$(VersionFileGenerationEnabled)' == ''">false</VersionFileGenerationEnabled>
@ -19,27 +19,22 @@ Project global versioning targets.
<VersionStartYear Condition="'$(VersionStartYear)' == ''">INVALID_VersionStartYear</VersionStartYear>
<VersionMajor Condition="'$(VersionMajor)' == ''">INVALID_VersionMajor</VersionMajor>
<VersionMinor Condition="'$(VersionMinor)' == ''">INVALID_VersionMinor</VersionMinor>
<VersionBuild Condition="'$(VersionBuild)' == '' OR '$(VersionBuild)' == '0'">$([MSBuild]::Add(1, $([MSBuild]::Subtract($([System.DateTime]::Now.Year), $(VersionStartYear)))))$([System.DateTime]::Now.ToString("MMdd"))</VersionBuild>
<VersionRevision Condition="'$(VersionRevision)' == ''">0</VersionRevision>
<VersionRelease Condition="'$(VersionRelease)' == ''">0</VersionRelease>
<VersionRevision Condition="'$(VersionRevision)' == ''">0</VersionRevision>
<VersionBuild Condition="'$(VersionBuild)' == '' OR '$(VersionBuild)' == '0'">$([MSBuild]::Add(1, $([MSBuild]::Subtract($([System.DateTime]::Now.Year), $(VersionStartYear)))))$([System.DateTime]::Now.ToString("MMdd"))</VersionBuild>
</PropertyGroup>
<!-- Comptued parameters -->
<PropertyGroup>
<AssemblyVersion>$(VersionMajor).$(VersionMinor).0.$(VersionRevision)</AssemblyVersion>
<AssemblyFileVersion>$(VersionMajor).$(VersionMinor).$(VersionBuild).$(VersionRevision)</AssemblyFileVersion>
<AssemblyInfoVersion Condition="'$(VersionRelease)' != ''">$(VersionMajor).$(VersionMinor).$(VersionRelease)-$(VersionBuild)</AssemblyInfoVersion>
<AssemblyInfoVersion Condition="'$(AssemblyInfoVersion)' == ''">$(AssemblyFileVersion)</AssemblyInfoVersion>
<AssemblyFileVersion>$(VersionMajor).$(VersionMinor).$(VersionRelease).$(VersionBuild)</AssemblyFileVersion>
<AssemblyVersionFile>$(IntermediateOutputPath)$(MSBuildProjectName).version.cs</AssemblyVersionFile>
</PropertyGroup>
<PropertyGroup>
<NuGetPackageVersion Condition="'$(NuGetPackageVersion)' == ''">$(VersionMajor).$(VersionMinor).$(VersionRelease)</NuGetPackageVersion>
</PropertyGroup>
<PropertyGroup>
<SatelliteContractVersion Condition="'$(SatelliteContractVersion)' == ''">$(AssemblyVersion)</SatelliteContractVersion>
<NuGetPackageVersion Condition="'$(BuildQuality)' != 'rtm'">$(NuGetPackageVersion)-$(BuildQuality)</NuGetPackageVersion>
</PropertyGroup>
<ItemGroup Condition="'$(VersionFileGenerationEnabled)' == 'true'">
@ -71,7 +66,22 @@ Project global versioning targets.
</PropertyGroup>
<Target Name="GenerateVersionFile" DependsOnTargets="$(GenerateVersionFileDependsOn)" />
<Target Name="GenerateVersionFileCore" Condition="'$(ShouldGenerateVersionFile)' == 'true'">
<Target Name="EnsureGitInfo" Condition="'$(GitCommit)' == ''">
<Exec Command="git describe --match= --always --dirty --abbrev=40" ConsoleToMSBuild="true" IgnoreExitCode="false" ContinueOnError="true" >
<Output PropertyName="GitDescribeOutput" TaskParameter="ConsoleOutput" />
<Output PropertyName="GitDescribeExit" TaskParameter="ExitCode" />
</Exec>
<PropertyGroup Condition="'$(GitDescribeExit)' == '0'">
<GitCommit>$(GitDescribeOutput)</GitCommit>
</PropertyGroup>
</Target>
<Target Name="GenerateVersionFileCore" Condition="'$(ShouldGenerateVersionFile)' == 'true'" DependsOnTargets="EnsureGitInfo">
<PropertyGroup>
<AssemblyInfoVersion Condition="'$(GitCommit)' != ''">$(VersionMajor).$(VersionMinor).$(VersionRelease)+$(GitCommit)</AssemblyInfoVersion>
<AssemblyInfoVersion Condition="'$(AssemblyInfoVersion)' == '' AND '$(VersionBuild)' != ''">$(VersionMajor).$(VersionMinor).$(VersionRelease)-$(VersionBuild)</AssemblyInfoVersion>
<AssemblyInfoVersion Condition="'$(AssemblyInfoVersion)' == ''">$(AssemblyFileVersion)</AssemblyInfoVersion>
</PropertyGroup>
<ItemGroup>
<LinesToWrite Include="// $(SourceFileCopyright)" Condition="'$(SourceFileCopyright)' != ''"/>
<LinesToWrite Include="// &lt;auto-generated&gt;" />