Skip to content

Commit 19891ff

Browse files
committed
Publish release packages and symbols only for main CI runs
The Release pipeline now evaluates the CI run it consumes, as v8-jsi does: it publishes only when that run built refs/heads/main, and otherwise renames the run "Skipped - ..." and skips publishing. The Release pipeline's own branch is not a condition. CI no longer uploads symbols. It stages the same PDBs as a published-symbols pipeline artifact, and the gated Release stage lists and publishes them with PublishSymbols@2.
1 parent 728e4bc commit 19891ff

2 files changed

Lines changed: 87 additions & 10 deletions

File tree

‎.ado/publish.yml‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ extends:
377377
pathtoPublish: $(Build.ArtifactStagingDirectory)
378378
artifactName: published-packages
379379
targetPath: $(Build.StagingDirectory)/pkg
380+
- output: pipelineArtifact
381+
artifactName: published-symbols
382+
targetPath: $(Build.StagingDirectory)/symbols
380383

381384
pool:
382385
name: Azure-Pipelines-1ESPT-ExDShared
@@ -493,19 +496,17 @@ extends:
493496
-Path "$(Build.SourcesDirectory)/out/bin/Release/NodeApi/aot/win-x64/publish/Microsoft.JavaScript.NodeApi.node.dll" `
494497
-NewName "Microsoft.JavaScript.NodeApi.node"
495498
496-
# Make symbols available through http://symweb.
497-
- task: PublishSymbols@2
498-
displayName: Publish symbols
499+
- task: CopyFiles@2
500+
displayName: Stage symbols
499501
inputs:
500-
IndexSources: false # PublishSymbols does not support GitHub sources
501-
SymbolsFolder: $(Build.SourcesDirectory)/out/bin/Release
502-
SearchPattern: |
502+
SourceFolder: $(Build.SourcesDirectory)/out/bin/Release
503+
Contents: |
503504
**/Microsoft.JavaScript.NodeApi.pdb
504505
**/win-x64/publish/Microsoft.JavaScript.NodeApi.node.pdb
505506
**/Microsoft.JavaScript.NodeApi.DotNetHost.pdb
506507
**/Microsoft.JavaScript.NodeApi.Generator.pdb
507-
SymbolServerType: TeamServices
508-
UseNetCoreClientTool: true
508+
TargetFolder: $(Build.StagingDirectory)/symbols
509+
flattenFolders: false
509510

510511
# Do not build or publish assemblies to avoid overriding signed binaries.
511512
- script: dotnet pack --configuration Release --no-build -p:NoPublish=true

‎.ado/release.yml‎

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33
#
4-
# The Release pipeline to publish NPM and NuGet packages
4+
# The Release pipeline to publish symbols and NPM and NuGet packages
55
# to public ADO feeds and, through ESRP Release, to npmjs.com and NuGet.org.
66
#
77

@@ -52,9 +52,85 @@ extends:
5252
networkIsolationMode: Enforce
5353

5454
stages:
55+
- stage: gate
56+
displayName: Evaluate release
57+
jobs:
58+
- job: evaluate
59+
displayName: Check that the CI run is from main
60+
steps:
61+
- checkout: none
62+
63+
# Missing or unresolved CI branches fail closed. The Release branch is logged
64+
# only: any Release branch may publish artifacts already built by main CI.
65+
- pwsh: |
66+
$branch = $env:CI_SOURCE_BRANCH
67+
$ciRunName = $env:CI_RUN_NAME
68+
$stamp = $env:BUILD_BUILDNUMBER
69+
Write-Host "CI run: $ciRunName (ID: $env:CI_RUN_ID)"
70+
Write-Host "CI branch: $branch"
71+
Write-Host "Release branch: $env:RELEASE_SOURCE_BRANCH (informational only)"
72+
if ($branch -ceq 'refs/heads/main') {
73+
$shouldRelease = 'True'
74+
$buildNumber = "Release - $ciRunName - $stamp"
75+
Write-Host "Releasing artifacts from main CI."
76+
} else {
77+
$shouldRelease = 'False'
78+
$buildNumber = "Skipped - $ciRunName ($($branch -replace '^refs/heads/', '')) - $stamp"
79+
Write-Host "Skipping: only CI runs of main are released; this one is from '$branch'. Nothing is published."
80+
}
81+
# Build numbers can't contain " ' / : < > \ | ? @ *, exceed 255 characters, or end with '.'.
82+
$buildNumber = $buildNumber -replace '["''/:<>\\|?@*]', '_'
83+
$buildNumber = $buildNumber.Substring(0, [Math]::Min(255, $buildNumber.Length)).TrimEnd('.')
84+
Write-Host "##vso[build.updatebuildnumber]$buildNumber"
85+
Write-Host "##vso[task.setvariable variable=shouldRelease;isOutput=true]$shouldRelease"
86+
name: gate
87+
displayName: Decide whether to release
88+
env:
89+
CI_SOURCE_BRANCH: $(resources.pipeline.microsoft_node-api-dotnet_ci.sourceBranch)
90+
CI_RUN_NAME: $(resources.pipeline.microsoft_node-api-dotnet_ci.runName)
91+
CI_RUN_ID: $(resources.pipeline.microsoft_node-api-dotnet_ci.runID)
92+
RELEASE_SOURCE_BRANCH: $(Build.SourceBranch)
93+
BUILD_BUILDNUMBER: $(Build.BuildNumber)
94+
95+
- pwsh: Write-Host 'Releasing'
96+
displayName: RELEASING - the CI run is from main
97+
condition: eq(variables['gate.shouldRelease'], 'True')
98+
99+
- pwsh: Write-Host 'Skipping'
100+
displayName: SKIPPED - the CI run is not from main, nothing is published
101+
condition: eq(variables['gate.shouldRelease'], 'False')
102+
55103
- stage: main_release
56-
displayName: Publish packages
104+
displayName: Publish packages and symbols
105+
dependsOn: gate
106+
condition: and(succeeded(), eq(dependencies.gate.outputs['evaluate.gate.shouldRelease'], 'True'))
57107
jobs:
108+
- job: publish_symbols
109+
displayName: Publish symbols
110+
timeoutInMinutes: 30
111+
templateContext:
112+
type: releaseJob
113+
isProduction: true
114+
inputs:
115+
- input: pipelineArtifact
116+
pipeline: microsoft_node-api-dotnet_ci
117+
artifactName: published-symbols
118+
targetPath: $(Pipeline.Workspace)/symbols
119+
120+
steps:
121+
- pwsh: Get-ChildItem -LiteralPath '$(Pipeline.Workspace)/symbols' -Recurse -Filter *.pdb | ForEach-Object FullName
122+
displayName: List symbols to publish
123+
124+
# Make symbols available through http://symweb.
125+
- task: PublishSymbols@2
126+
displayName: Publish symbols
127+
inputs:
128+
IndexSources: false # PublishSymbols does not support GitHub sources
129+
SymbolsFolder: $(Pipeline.Workspace)/symbols
130+
SearchPattern: '**/*.pdb'
131+
SymbolServerType: TeamServices
132+
UseNetCoreClientTool: true
133+
58134
- job: nuget_ms_react_native_public_job
59135
displayName: NuGet to ADO ms/react-native-public feed
60136
templateContext:

0 commit comments

Comments
 (0)