@@ -7,10 +7,16 @@ parameters:
77 SigningCertificate : ' '
88 ExportCommand : ' '
99 ContinueOnError : false
10+ AzureServiceConnectionName : ' Python Signing'
1011
1112steps :
1213- ${{ if parameters.SigningCertificate }} :
1314 - powershell : |
15+ # Install test root, so that signing tool can do test signing
16+ # See https://github.com/dotnet/sign/issues/908 for underlying issue
17+ Import-Certificate -FilePath .\TestCertRoot.cer -CertStoreLocation Cert:\LocalMachine\Root
18+
19+ # Install sign tool
1420 dotnet tool install --global --prerelease sign
1521 $signtool = (gcm sign -EA SilentlyContinue).Source
1622 if (-not $signtool) {
@@ -32,6 +38,29 @@ steps:
3238 env:
3339 EXPORT_COMMAND: ${{ parameters.ExportCommand }}
3440
41+ # We sign in once with the AzureCLI task, as it uses OIDC to obtain a
42+ # temporary token. But the task also logs out, and so we save the token and
43+ # use it to log in persistently (for the rest of the build).
44+ - task : AzureCLI@2
45+ displayName : ' Authenticate signing tools (1/2)'
46+ inputs :
47+ azureSubscription : ${{ parameters.AzureServiceConnectionName }}
48+ scriptType : ' ps'
49+ scriptLocation : ' inlineScript'
50+ inlineScript : |
51+ "##vso[task.setvariable variable=AZURE_CLIENT_ID;issecret=true]${env:servicePrincipalId}"
52+ "##vso[task.setvariable variable=AZURE_ID_TOKEN;issecret=true]${env:idToken}"
53+ "##vso[task.setvariable variable=AZURE_TENANT_ID;issecret=true]${env:tenantId}"
54+ addSpnToEnvironment : true
55+
56+ - powershell : >
57+ az login --service-principal
58+ -u $(AZURE_CLIENT_ID)
59+ --tenant $(AZURE_TENANT_ID)
60+ --allow-no-subscriptions
61+ --federated-token $(AZURE_ID_TOKEN)
62+ displayName: 'Authenticate signing tools (2/2)'
63+
3564 - ${{ if parameters.Include }} :
3665 - powershell : |
3766 if ("${{ parameters.Exclude }}") {
5887 env:
5988 TRUSTED_SIGNING_CMD: $(__TrustedSigningCmd)
6089 TRUSTED_SIGNING_ARGS: $(__TrustedSigningArgs)
61- AZURE_TENANT_ID: $(TrustedSigningTenantId)
62- AZURE_CLIENT_ID: $(TrustedSigningClientId)
63- AZURE_CLIENT_SECRET: $(TrustedSigningSecret)
6490 ${{ if parameters.Filter }}:
6591 FILTER: ${{ parameters.Filter }}
6692
0 commit comments