Skip to content
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

azure-pipelines: Allow template consumer to disable signing with parameter #1784

Merged
merged 23 commits into from
Aug 28, 2024
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
4 changes: 4 additions & 0 deletions azure-pipelines/1esmain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ parameters:
- name: additionalSetupSteps
type: stepList
default: []
- name: enableSigning
type: boolean
default: True

# `resources` specifies the location of templates to pick up, use it to get 1ES templates
resources:
Expand Down Expand Up @@ -36,3 +39,4 @@ extends:
parameters:
useAzureFederatedCredentials: ${{ parameters.useAzureFederatedCredentials }}
additionalSetupSteps: ${{ parameters.additionalSetupSteps }}
enableSigning: ${{ parameters.enableSigning }}
8 changes: 6 additions & 2 deletions azure-pipelines/1esstages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ parameters:
- name: additionalSetupSteps
type: stepList
default: []
- name: enableSigning
type: boolean
default: True

stages:
- stage: BuildStage
Expand All @@ -19,8 +22,7 @@ stages:
templateContext:
mb: # Enable the MicroBuild Signing toolset
signing:
# Enable the signing toolset when the build is not a PR and the branch is main or starts with rel/
enabled: $[and(ne(variables['Build.Reason'], 'PullRequest'), or(eq(variables['Build.SourceBranchName'], 'main'), startsWith(variables['Build.SourceBranchName'], 'rel/')))]
enabled: ${{ parameters.enableSigning }}
signType: real # options are 'real' & 'test'
zipSources: false
outputs:
Expand All @@ -34,6 +36,8 @@ stages:
- template: ./templates/build.yml
- template: ./templates/1espackage.yml
- template: ./templates/sign.yml
parameters:
enableSigning: ${{ parameters.enableSigning }}
- template: ./templates/stage-artifacts.yml
- template: ./templates/test.yml
parameters:
Expand Down
8 changes: 6 additions & 2 deletions azure-pipelines/templates/sign.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
parameters:
- name: enableSigning
type: boolean
default: True

steps:
# Check if the SignExtension.signproj file exists and set a variable using PowerShell
# All other steps in this template will only run if the file exists
Expand All @@ -11,8 +16,7 @@ steps:
Write-Output "SignExtension.signproj file not found. Skipping signing."
}
displayName: "\U0001F449 Check for SignExtension.signproj File"
# Run this step when the build is not a PR and the branch is main or starts with rel/
condition: and(ne(variables['Build.Reason'], 'PullRequest'), or(eq(variables['Build.SourceBranchName'], 'main'), startsWith(variables['Build.SourceBranchName'], 'rel/')))
condition: ${{ parameters.enableSigning }}

# put the extension name and version from the package.json into variables to use later. Variables can be used in later steps as $(package.name) and $(package.version)
- pwsh: |
Expand Down
Loading