Skip to content

Commit 82cae10

Browse files
gavinbarronCopilot
andcommitted
fix(hidi): hand off Docker context through pipeline artifacts
Replace forbidden release-job checkout with a build-produced context containing only required source and public signing inputs. Keep stable and preview publishing disabled. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c631d217-9378-4cee-8c7e-761043ff3ae5
1 parent bfcaa50 commit 82cae10

2 files changed

Lines changed: 64 additions & 2 deletions

File tree

‎.azure-pipelines/hidi-release.yml‎

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ extends:
4444
- output: pipelineArtifact
4545
artifactName: Hidi
4646
targetPath: '$(Build.ArtifactStagingDirectory)\hidi'
47+
- output: pipelineArtifact
48+
artifactName: HidiDockerContext
49+
targetPath: '$(Build.ArtifactStagingDirectory)\hidi-docker-context'
4750
steps:
4851
- task: UseDotNet@2
4952
displayName: Use .NET 6 for ESRP
@@ -74,6 +77,49 @@ extends:
7477
</configuration>
7578
"@ | Set-Content -Path "$(Build.SourcesDirectory)/nuget.config" -Encoding UTF8
7679
displayName: Create nuget.config (central feed)
80+
- pwsh: |
81+
$ErrorActionPreference = 'Stop'
82+
$sourceRoot = '$(Build.SourcesDirectory)'
83+
$context = Join-Path '$(Build.ArtifactStagingDirectory)' 'hidi-docker-context'
84+
New-Item -ItemType Directory -Path $context | Out-Null
85+
$rootFiles = @('Dockerfile', '.dockerignore', 'Directory.Build.props', 'Build.props', 'build.root', 'global.json', 'README.md', 'src/Build.props')
86+
foreach ($relativePath in $rootFiles) {
87+
$destination = Join-Path $context $relativePath
88+
New-Item -ItemType Directory -Force (Split-Path $destination -Parent) | Out-Null
89+
Copy-Item -LiteralPath (Join-Path $sourceRoot $relativePath) -Destination $destination
90+
}
91+
foreach ($sourceDirectory in @('src/Microsoft.OpenApi.Hidi', 'src/Microsoft.OpenApi.OData.Reader')) {
92+
$directory = Join-Path $sourceRoot $sourceDirectory
93+
foreach ($file in Get-ChildItem -LiteralPath $directory -File -Recurse -Force) {
94+
$relativePath = [IO.Path]::GetRelativePath($sourceRoot, $file.FullName)
95+
if ($relativePath -match '(^|[\\/])(bin|obj|\.git)([\\/]|$)' -or $file.Extension -in @('.snk', '.pfx', '.p12', '.pem', '.key')) { continue }
96+
if ($file.Attributes -band [IO.FileAttributes]::ReparsePoint) { throw "Unexpected linked Docker context file: $relativePath" }
97+
$destination = Join-Path $context $relativePath
98+
New-Item -ItemType Directory -Force (Split-Path $destination -Parent) | Out-Null
99+
Copy-Item -LiteralPath $file.FullName -Destination $destination
100+
}
101+
}
102+
foreach ($keyName in @('Microsoft.OpenApi.Hidi.public.snk', 'Microsoft.OpenApi.OData.public.snk')) {
103+
$keyPath = Join-Path $sourceRoot 'tool' $keyName
104+
$key = [IO.File]::ReadAllBytes($keyPath)
105+
if ($key.Length -ne 160 -or $key[12] -ne 6 -or [Text.Encoding]::ASCII.GetString($key, 20, 4) -ne 'RSA1') {
106+
throw "Expected the public-only strong-name identity: $keyName"
107+
}
108+
New-Item -ItemType Directory -Force (Join-Path $context 'tool') | Out-Null
109+
Copy-Item -LiteralPath $keyPath -Destination (Join-Path $context 'tool' $keyName)
110+
}
111+
$keys = @(Get-ChildItem -LiteralPath $context -File -Recurse -Force -Filter '*.snk')
112+
if ($keys.Count -ne 2) { throw "Expected exactly two public-only signing keys in the Docker context." }
113+
foreach ($file in Get-ChildItem -LiteralPath $context -File -Recurse -Force) {
114+
$relativePath = [IO.Path]::GetRelativePath($context, $file.FullName)
115+
if ($relativePath -match '(^|[\\/])(bin|obj|\.git)([\\/]|$)' -or $file.Extension -in @('.pfx', '.p12', '.pem', '.key')) {
116+
throw "Forbidden Docker context file: $relativePath"
117+
}
118+
if ($file.Extension -eq '.snk' -and $relativePath -notmatch '^tool[\\/]Microsoft\.OpenApi\.(Hidi|OData)\.public\.snk$') {
119+
throw "Unexpected Docker signing key: $relativePath"
120+
}
121+
}
122+
displayName: Stage public-only hidi Docker context
77123
- pwsh: |
78124
$version = ([xml](Get-Content src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj)).Project.PropertyGroup.Version
79125
if ($version -notmatch '^3\.\d+\.\d+(-[0-9A-Za-z.-]+)?$') { throw "Expected a hidi 3.x version, got $version." }
@@ -222,26 +268,31 @@ extends:
222268
templateContext:
223269
type: releaseJob
224270
isProduction: true
271+
inputs:
272+
- input: pipelineArtifact
273+
artifactName: HidiDockerContext
274+
targetPath: '$(Pipeline.Workspace)/hidi-docker-context'
225275
environment: hidi-container
226276
strategy:
227277
runOnce:
228278
deploy:
229279
pool:
230280
vmImage: ubuntu-latest
231281
steps:
232-
- checkout: self
233282
- pwsh: |
234283
$version = ([xml](Get-Content src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj)).Project.PropertyGroup.Version
235284
if ('$(Build.SourceBranch)' -ne "refs/tags/hidi-v$version") { throw "Hidi tag does not match project version." }
236285
if ([version]($version -split '-')[0] -le [version]'3.10.2') { throw "Do not republish the migration baseline or an older hidi version." }
237286
Write-Host "##vso[task.setvariable variable=HidiReleaseVersion]$version"
238287
displayName: Read independent hidi version
288+
workingDirectory: '$(Pipeline.Workspace)/hidi-docker-context'
239289
- task: AzureCLI@2
240290
displayName: Publish multi-platform hidi image
241291
inputs:
242292
azureSubscription: ACR Images Push Service Connection
243293
scriptType: bash
244294
scriptLocation: inlineScript
295+
workingDirectory: '$(Pipeline.Workspace)/hidi-docker-context'
245296
inlineScript: |
246297
set -euo pipefail
247298
az acr login --name msgraphprodregistry
@@ -259,26 +310,31 @@ extends:
259310
templateContext:
260311
type: releaseJob
261312
isProduction: true
313+
inputs:
314+
- input: pipelineArtifact
315+
artifactName: HidiDockerContext
316+
targetPath: '$(Pipeline.Workspace)/hidi-docker-context'
262317
environment: hidi-container
263318
strategy:
264319
runOnce:
265320
deploy:
266321
pool:
267322
vmImage: ubuntu-latest
268323
steps:
269-
- checkout: self
270324
- pwsh: |
271325
$version = ([xml](Get-Content src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj)).Project.PropertyGroup.Version
272326
if ($version -notmatch '^3\.\d+\.\d+$') { throw "Expected a stable hidi 3.x base version." }
273327
$previewVersion = "$version.$([DateTime]::UtcNow.ToString('yyyyMMdd'))$(Build.BuildId)"
274328
Write-Host "##vso[task.setvariable variable=HidiPreviewVersion]$previewVersion"
275329
displayName: Compute independent hidi preview tag
330+
workingDirectory: '$(Pipeline.Workspace)/hidi-docker-context'
276331
- task: AzureCLI@2
277332
displayName: Publish multi-platform hidi preview image
278333
inputs:
279334
azureSubscription: ACR Images Push Service Connection
280335
scriptType: bash
281336
scriptLocation: inlineScript
337+
workingDirectory: '$(Pipeline.Workspace)/hidi-docker-context'
282338
inlineScript: |
283339
set -euo pipefail
284340
az acr login --name msgraphprodregistry

‎src/Microsoft.OpenApi.Hidi/readme.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ artifacts are signed in Azure Pipelines. Docker builds opt into
9797
key without changing normal OData signing. Private `.snk` resources are excluded
9898
from the Docker context and must not be copied into new Hidi resources.
9999

100+
The official build stages a separate `HidiDockerContext` artifact containing only
101+
the Docker build inputs, Hidi/OData source projects and their two public keys,
102+
without `bin`, `obj`, Git metadata or private signing resources. Stable and preview
103+
container release jobs consume that same build artifact without checking out the
104+
repository, as required by the 1ES release-job policy.
105+
100106
The migration baseline 3.10.2 is already published. Destination Hidi NuGet,
101107
GitHub release, stable Docker and preview Docker publishing are disabled until
102108
source cutover. The first destination stable release must advance the Hidi

0 commit comments

Comments
 (0)