Skip to content

Commit 37b1b4b

Browse files
authored
Merge pull request #906 from SteveL-MSFT/cfs-store-sign
Fix auth to CFS for release build
2 parents 06f2b94 + 9ea21dc commit 37b1b4b

File tree

3 files changed

+57
-10
lines changed

3 files changed

+57
-10
lines changed

.pipelines/DSC-Official.yml

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ pr:
77
- onebranch
88
- release/v*
99

10-
schedules:
11-
- cron: '0 3 * * 1'
12-
displayName: Weekly Build
13-
branches:
14-
include:
15-
- main
16-
always: true
17-
1810
variables:
1911
BuildConfiguration: 'release'
2012
PackageRoot: '$(System.ArtifactsDirectory)/Packages'
@@ -83,13 +75,25 @@ extends:
8375
Write-Host ("sending " + $vstsCommandString)
8476
Write-Host "##$vstsCommandString"
8577
name: Package
78+
- task: AzureCLI@2
79+
displayName: Get Az Token
80+
inputs:
81+
azureSubscription: az-blob-cicd-infra
82+
scriptType: pscore
83+
scriptLocation: inlineScript
84+
inlineScript: |
85+
$token = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
86+
$vstsCommandString = "vso[task.setvariable variable=AzToken;isoutput=true]$token"
87+
Write-Host "Setting token"
88+
Write-Host "##$vstsCommandString"
8689
8790
- job: BuildWin_x64
8891
dependsOn: SetPackageVersion
8992
variables:
9093
ob_sdl_tsa_configFile: '$(Build.SourcesDirectory)\DSC\.config\tsaoptions.json'
9194
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
9295
signSrcPath: '$(Build.SourcesDirectory)\out'
96+
AzToken: $[ dependencies.SetPackageVersion.outputs['AzToken'] ]
9397
ob_sdl_sbom_enabled: true
9498
ob_signing_setup_enabled: true
9599
ob_sdl_codeql_compiled_enabled: true
@@ -101,6 +105,7 @@ extends:
101105
buildName: x86_64-pc-windows-msvc
102106
signSrcPath: '$(signSrcPath)'
103107
PackageRoot: '$(PackageRoot)'
108+
token: '$(AzToken)'
104109

105110
- job: BuildWin_arm64
106111
dependsOn: SetPackageVersion
@@ -119,6 +124,7 @@ extends:
119124
buildName: aarch64-pc-windows-msvc
120125
signSrcPath: '$(signSrcPath)'
121126
PackageRoot: '$(PackageRoot)'
127+
token: '$(AzToken)'
122128

123129
- job: CreateMsixBundle
124130
dependsOn:
@@ -149,12 +155,21 @@ extends:
149155
Copy-Item ./bin/*.msixbundle "$(ob_outputDirectory)"
150156
displayName: 'Create msixbundle'
151157
condition: succeeded()
158+
- task: onebranch.pipeline.signing@1
159+
displayName: Sign MsixBundle
160+
condition: succeeded()
161+
inputs:
162+
command: 'sign'
163+
signing_profile: $(MSIXProfile)
164+
files_to_sign: '*.msixbundle'
165+
search_root: '$(ob_outputDirectory)'
152166

153167
- job: BuildLinuxMusl
154168
dependsOn: SetPackageVersion
155169
variables:
156170
LinuxContainerImage: 'onebranch.azurecr.io/linux/ubuntu-2204:latest'
157171
PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
172+
AzToken: $[ dependencies.SetPackageVersion.outputs['AzToken'] ]
158173
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
159174
displayName: Linux-x64-musl
160175
pool:
@@ -171,6 +186,9 @@ extends:
171186
- pwsh: |
172187
apt update
173188
apt -y install musl-tools
189+
$header = "Bearer $accessToken"
190+
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
191+
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
174192
./build.ps1 -Release -Architecture x86_64-unknown-linux-musl
175193
./build.ps1 -PackageType tgz -Architecture x86_64-unknown-linux-musl -Release
176194
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
@@ -182,6 +200,7 @@ extends:
182200
variables:
183201
LinuxContainerImage: 'onebranch.azurecr.io/linux/ubuntu-2004-arm64:latest'
184202
PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
203+
AzToken: $[ dependencies.SetPackageVersion.outputs['AzToken'] ]
185204
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
186205
displayName: Linux-ARM64-musl
187206
pool:
@@ -196,6 +215,14 @@ extends:
196215
displayName: Install Rust
197216
env:
198217
ob_restore_phase: true
218+
- task: AzureCLI@2
219+
displayName: Azure CLI
220+
inputs:
221+
azureSubscription: az-blob-cicd-infra
222+
scriptType: pscore
223+
scriptLocation: inlineScript
224+
inlineScript: |
225+
az account show
199226
- pwsh: |
200227
$env:CC_aarch64_unknown_linux_musl='clang'
201228
$env:AR_aarch64_unknown_linux_musl='llvm-ar'
@@ -211,6 +238,9 @@ extends:
211238
if ((openssl version -d) -match 'OPENSSLDIR: "(?<dir>.*?)"') {
212239
$env:OPENSSL_LIB_DIR = $matches['dir']
213240
}
241+
$header = "Bearer $accessToken"
242+
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
243+
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
214244
./build.ps1 -Release -Architecture aarch64-unknown-linux-musl
215245
./build.ps1 -PackageType tgz -Architecture aarch64-unknown-linux-musl -Release
216246
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"
@@ -221,6 +251,7 @@ extends:
221251
dependsOn: SetPackageVersion
222252
variables:
223253
PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
254+
AzToken: $[ dependencies.SetPackageVersion.outputs['AzToken'] ]
224255
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
225256
displayName: BuildMac
226257
pool:
@@ -243,7 +274,18 @@ extends:
243274
displayName: Install Rust
244275
env:
245276
ob_restore_phase: true
277+
- task: AzureCLI@2
278+
displayName: Azure CLI
279+
inputs:
280+
azureSubscription: az-blob-cicd-infra
281+
scriptType: pscore
282+
scriptLocation: inlineScript
283+
inlineScript: |
284+
az account show
246285
- pwsh: |
286+
$header = "Bearer $accessToken"
287+
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
288+
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
247289
./build.ps1 -Release -Architecture $(buildName)
248290
./build.ps1 -PackageType tgz -Architecture $(buildName) -Release
249291
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"

.pipelines/DSC-Windows.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ parameters:
88
- name: BuildConfiguration
99
type: string
1010
default: Release
11+
- name: token
12+
type: string
1113

1214
steps:
1315
- checkout: self
@@ -35,6 +37,9 @@ steps:
3537
env:
3638
ob_restore_phase: true
3739
- pwsh: |
40+
$header = "Bearer ${ parameters.token }"
41+
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
42+
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
3843
Set-Location "$(Build.SourcesDirectory)/DSC"
3944
$LLVMBIN = "$($env:PROGRAMFILES)\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\bin"
4045
if (!(Test-Path $LLVMBIN)) {

build.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ if (!$SkipBuild) {
238238
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = $null
239239
$env:CARGO_REGISTRIES_CRATESIO_INDEX = $null
240240

241-
if ($UseCFSAuth -or $null -ne $env:TF_BUILD) {
241+
if ($UseCFSAuth) {
242242
if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
243243
throw "Azure CLI not found"
244244
}
@@ -250,9 +250,9 @@ if (!$SkipBuild) {
250250
Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access."
251251
} else {
252252
$header = "Bearer $accessToken"
253-
$env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/"
254253
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
255254
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
255+
$env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/"
256256
}
257257
}
258258
else {

0 commit comments

Comments
 (0)