From 3d704f5b3520367f8aed9b6f54af8d43e733aae3 Mon Sep 17 00:00:00 2001 From: Lilian Kasem Date: Wed, 29 May 2024 10:35:10 -0700 Subject: [PATCH] [1ES] Update extensions build template (#2475) --- .../jobs/build-extension-artifacts.yml | 97 +++---------------- .../steps/build-extension-project.yml | 91 +++++++++++++++++ .../ci/official-build.yml | 9 +- .../ci/public-build.yml | 2 + 4 files changed, 111 insertions(+), 88 deletions(-) create mode 100644 eng/ci/templates/steps/build-extension-project.yml diff --git a/eng/ci/templates/official/jobs/build-extension-artifacts.yml b/eng/ci/templates/official/jobs/build-extension-artifacts.yml index cde620fb..d3af937e 100644 --- a/eng/ci/templates/official/jobs/build-extension-artifacts.yml +++ b/eng/ci/templates/official/jobs/build-extension-artifacts.yml @@ -1,6 +1,10 @@ parameters: + - name: Projects + type: object + default: [] - name: ExtensionProjectName type: string + default: '' jobs: @@ -21,93 +25,20 @@ jobs: os: linux variables: - ${{ if and( not(contains(variables['Build.SourceBranch'], '/release/')), not(startsWith(variables['Build.SourceBranch'], 'refs/tags')) ) }}: + ${{ if and(not(contains(variables['Build.SourceBranch'], '/release/')), not(startsWith(variables['Build.SourceBranch'], 'refs/tags'))) }}: buildNumberTemp: $(Build.BuildNumber) buildNumber: $[variables.buildNumberTemp] steps: - template: /eng/ci/templates/steps/install-dotnet.yml@self - - task: DotNetCoreCLI@2 - displayName: Build project - inputs: - command: custom - custom: build - arguments: -p:BuildNumber=$(buildNumber) -c release - projects: | - extensions/${{ parameters.ExtensionProjectName }}/src/*.csproj + - ${{ if ne(parameters.ExtensionProjectName, '') }}: + - template: /eng/ci/templates/steps/build-extension-project.yml@self + parameters: + ExtensionProjectName: ${{ parameters.ExtensionProjectName }} - - task: EsrpCodeSigning@2 - displayName: Sign assemblies - inputs: - ConnectedServiceName: ESRP Service-internal - FolderPath: extensions - Pattern: Microsoft.Azure.Functions.Worker.Extensions*.dll - signConfigType: inlineSignParams - inlineOperation: | - [ - { - "KeyCode": "CP-230012", - "OperationCode": "SigntoolSign", - "Parameters": { - "OpusName": "Microsoft", - "OpusInfo": "http://www.microsoft.com", - "FileDigest": "/fd \"SHA256\"", - "PageHash": "/NPH", - "TimeStamp": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" - }, - "ToolName": "sign", - "ToolVersion": "1.0" - }, - { - "KeyCode": "CP-230012", - "OperationCode": "SigntoolVerify", - "Parameters": {}, - "ToolName": "sign", - "ToolVersion": "1.0" - } - ] - - - task: DeleteFiles@1 - displayName: Delete CodeSignSummary files - inputs: - contents: '**/CodeSignSummary-*.md' - - - task: DotNetCoreCLI@2 - displayName: Pack extension - inputs: - command: custom - custom: pack - arguments: '--no-build -c release -o $(Build.ArtifactStagingDirectory)/NugetPackages -p:BuildNumber=$(buildNumber)' - projects: | - extensions/${{ parameters.ExtensionProjectName }}/src/*.csproj - - - task: EsrpCodeSigning@2 - displayName: Sign nuget packages - inputs: - ConnectedServiceName: ESRP Service-internal - FolderPath: $(Build.ArtifactStagingDirectory)/NugetPackages - Pattern: Microsoft.Azure.Functions.Worker.Extensions*.nupkg - signConfigType: inlineSignParams - inlineOperation: | - [ - { - "KeyCode": "CP-401405", - "OperationCode": "NuGetSign", - "Parameters": {}, - "ToolName": "sign", - "ToolVersion": "1.0" - }, - { - "KeyCode": "CP-401405", - "OperationCode": "NuGetVerify", - "Parameters": {}, - "ToolName": "sign", - "ToolVersion": "1.0" - } - ] - - - task: DeleteFiles@1 - displayName: Delete CodeSignSummary files - inputs: - contents: '**/CodeSignSummary-*.md' + - ${{ if not(eq(length(parameters.Projects), 0)) }}: + - ${{ each Project in parameters.Projects }}: + - template: /eng/ci/templates/steps/build-extension-project.yml@self + parameters: + ExtensionProjectName: ${{ Project }} diff --git a/eng/ci/templates/steps/build-extension-project.yml b/eng/ci/templates/steps/build-extension-project.yml new file mode 100644 index 00000000..6803f49c --- /dev/null +++ b/eng/ci/templates/steps/build-extension-project.yml @@ -0,0 +1,91 @@ +parameters: + - name: ExtensionProjectName + type: string + +steps: + + - task: DotNetCoreCLI@2 + displayName: Build project + inputs: + command: custom + custom: build + arguments: -p:BuildNumber=$(buildNumber) -c release + projects: | + extensions/${{ parameters.ExtensionProjectName }}/**/*.csproj + + - task: EsrpCodeSigning@2 + displayName: Sign assemblies + inputs: + ConnectedServiceName: ESRP Service-internal + FolderPath: extensions + Pattern: Microsoft.Azure.Functions.Worker.Extensions*.dll + signConfigType: inlineSignParams + inlineOperation: | + [ + { + "KeyCode": "CP-230012", + "OperationCode": "SigntoolSign", + "Parameters": { + "OpusName": "Microsoft", + "OpusInfo": "http://www.microsoft.com", + "FileDigest": "/fd \"SHA256\"", + "PageHash": "/NPH", + "TimeStamp": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" + }, + "ToolName": "sign", + "ToolVersion": "1.0" + }, + { + "KeyCode": "CP-230012", + "OperationCode": "SigntoolVerify", + "Parameters": {}, + "ToolName": "sign", + "ToolVersion": "1.0" + } + ] + + - task: DeleteFiles@1 + displayName: Delete CodeSignSummary files + inputs: + sourceFolder: $(Build.ArtifactStagingDirectory)/NugetPackages + contents: '**/CodeSignSummary-*.md' + + - task: DotNetCoreCLI@2 + displayName: Pack extension + inputs: + command: custom + custom: pack + arguments: '--no-build -c release -o $(Build.ArtifactStagingDirectory)/NugetPackages -p:BuildNumber=$(buildNumber)' + projects: | + extensions/${{ parameters.ExtensionProjectName }}/**/*.csproj + + - task: EsrpCodeSigning@2 + displayName: Sign nuget packages + inputs: + ConnectedServiceName: ESRP Service-internal + FolderPath: $(Build.ArtifactStagingDirectory)/NugetPackages + Pattern: Microsoft.Azure.Functions.Worker.Extensions*.nupkg + signConfigType: inlineSignParams + inlineOperation: | + [ + { + "KeyCode": "CP-401405", + "OperationCode": "NuGetSign", + "Parameters": {}, + "ToolName": "sign", + "ToolVersion": "1.0" + }, + { + "KeyCode": "CP-401405", + "OperationCode": "NuGetVerify", + "Parameters": {}, + "ToolName": "sign", + "ToolVersion": "1.0" + } + ] + + - task: DeleteFiles@1 + displayName: Delete CodeSignSummary files + inputs: + sourceFolder: $(Build.ArtifactStagingDirectory)/NugetPackages + contents: '**/CodeSignSummary-*.md' diff --git a/extensions/Worker.Extensions.Http.AspNetCore/ci/official-build.yml b/extensions/Worker.Extensions.Http.AspNetCore/ci/official-build.yml index aa143301..38fc93a1 100644 --- a/extensions/Worker.Extensions.Http.AspNetCore/ci/official-build.yml +++ b/extensions/Worker.Extensions.Http.AspNetCore/ci/official-build.yml @@ -8,6 +8,7 @@ trigger: include: - eng/ - extensions/Worker.Extensions.Http.AspNetCore/ + - extensions/Worker.Extensions.Http.AspNetCore.Analyzers/ - test/extensions/Worker.Extensions.Http.AspNetCore.Tests/ # CI only, does not trigger on PRs. @@ -46,11 +47,9 @@ extends: jobs: - template: /eng/ci/templates/official/jobs/build-extension-artifacts.yml@self parameters: - ExtensionProjectName: $(ExtensionProjectName) - - - template: /eng/ci/templates/official/jobs/build-extension-artifacts.yml@self - parameters: - ExtensionProjectName: '$(ExtensionProjectName).Analyzers' + Projects: + - $(ExtensionProjectName) + - $(ExtensionProjectName).Analyzers - template: /eng/ci/templates/jobs/run-extension-tests.yml@self parameters: diff --git a/extensions/Worker.Extensions.Http.AspNetCore/ci/public-build.yml b/extensions/Worker.Extensions.Http.AspNetCore/ci/public-build.yml index 2f249657..97d31420 100644 --- a/extensions/Worker.Extensions.Http.AspNetCore/ci/public-build.yml +++ b/extensions/Worker.Extensions.Http.AspNetCore/ci/public-build.yml @@ -11,6 +11,7 @@ trigger: include: - eng/ - extensions/Worker.Extensions.Http.AspNetCore/ + - extensions/Worker.Extensions.Http.AspNetCore.Analyzers/ - test/extensions/Worker.Extensions.Http.AspNetCore.Tests/ pr: @@ -22,6 +23,7 @@ pr: include: - eng/ - extensions/Worker.Extensions.Http.AspNetCore/ + - extensions/Worker.Extensions.Http.AspNetCore.Analyzers/ - test/extensions/Worker.Extensions.Http.AspNetCore.Tests/ resources: