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