microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
.azdo/publish.yaml
227lines · modecode
| 1 | # ============================================================================= |
| 2 | # This pipeline publishes NuGet packages. Manually triggered only. |
| 3 | # - "Internal": pushes unsigned packages to the internal TeamsSDKPreviews feed. |
| 4 | # - "Public": signs (Authenticode + NuGet) and pushes to nuget.org (requires approval). |
| 5 | # Version is determined by Nerdbank.GitVersioning (nbgv) from version.json. |
| 6 | # |
| 7 | # MIGRATED TO 1ES OFFICIAL PIPELINE TEMPLATE: This pipeline now extends from |
| 8 | # 1ES.Official.PipelineTemplate to ensure compliance with M365 security requirements. |
| 9 | # ============================================================================= |
| 10 | |
| 11 | resources: |
| 12 | repositories: |
| 13 | - repository: 1esPipelines |
| 14 | type: git |
| 15 | name: 1ESPipelineTemplates/1ESPipelineTemplates |
| 16 | ref: refs/tags/release |
| 17 | |
| 18 | trigger: none |
| 19 | |
| 20 | pr: none |
| 21 | |
| 22 | parameters: |
| 23 | - name: publishType |
| 24 | displayName: 'Publish Type' |
| 25 | type: string |
| 26 | default: 'Internal' |
| 27 | values: |
| 28 | - Internal |
| 29 | - Public |
| 30 | |
| 31 | variables: |
| 32 | buildConfiguration: 'Release' |
| 33 | folderPath: '$(Build.SourcesDirectory)' |
| 34 | ${{ if eq(parameters.publishType, 'Public') }}: |
| 35 | appRegistrationTenantId: 'cdc5aeea-15c5-4db6-b079-fcadd2505dc2' |
| 36 | authenticodeSignId: '2d5c4ab9-0b7e-4f60-bb92-70322df77b94' |
| 37 | nugetSignId: 'a94a770a-9a7b-4888-a3ea-24584b851e49' |
| 38 | |
| 39 | extends: |
| 40 | template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines |
| 41 | parameters: |
| 42 | pool: |
| 43 | name: Azure-Pipelines-1ESPT-ExDShared |
| 44 | image: ubuntu-22.04 |
| 45 | os: linux |
| 46 | |
| 47 | sdl: |
| 48 | sourceAnalysisPool: |
| 49 | name: Azure-Pipelines-1ESPT-ExDShared |
| 50 | image: windows-2022 |
| 51 | os: windows |
| 52 | |
| 53 | # Required for M365PT tracking and drift management |
| 54 | customBuildTags: |
| 55 | - ES365AIMigrationTooling |
| 56 | |
| 57 | stages: |
| 58 | |
| 59 | - ${{ if eq(parameters.publishType, 'Internal') }}: |
| 60 | - stage: Build_Test_Pack_Push_Internal |
| 61 | displayName: 'Build, Test, Pack, and Push (Internal)' |
| 62 | jobs: |
| 63 | - job: BuildTestPackPush |
| 64 | displayName: 'Build, Test, Pack, and Push to Internal Feed' |
| 65 | steps: |
| 66 | - checkout: self |
| 67 | - task: UseDotNet@2 |
| 68 | displayName: 'Use .NET 8' |
| 69 | inputs: |
| 70 | packageType: 'sdk' |
| 71 | version: '8.0.x' |
| 72 | |
| 73 | - task: UseDotNet@2 |
| 74 | displayName: 'Use .NET 10' |
| 75 | inputs: |
| 76 | packageType: 'sdk' |
| 77 | version: '10.0.x' |
| 78 | |
| 79 | - pwsh: | |
| 80 | $nugetConfig = @" |
| 81 | <?xml version="1.0" encoding="utf-8"?> |
| 82 | <configuration> |
| 83 | <packageSources> |
| 84 | <clear /> |
| 85 | <add key="TeamsSDKPreviews" value="https://pkgs.dev.azure.com/DomoreexpGithub/Github_Pipelines/_packaging/TeamsSDKPreviews/nuget/v3/index.json" /> |
| 86 | </packageSources> |
| 87 | </configuration> |
| 88 | "@ |
| 89 | $nugetConfig | Out-File -FilePath "$(Build.SourcesDirectory)/nuget.config" -Encoding utf8 |
| 90 | displayName: 'Create nuget.config' |
| 91 | |
| 92 | - task: NuGetAuthenticate@1 |
| 93 | displayName: 'Authenticate with NuGet feeds' |
| 94 | |
| 95 | - script: dotnet restore |
| 96 | displayName: 'Restore' |
| 97 | |
| 98 | - script: dotnet build --no-restore --configuration $(buildConfiguration) |
| 99 | displayName: 'Build' |
| 100 | |
| 101 | - script: dotnet test --no-build --verbosity normal --logger trx --configuration $(buildConfiguration) |
| 102 | displayName: 'Test' |
| 103 | |
| 104 | - task: PublishTestResults@2 |
| 105 | displayName: 'Publish Test Results' |
| 106 | condition: succeededOrFailed() |
| 107 | inputs: |
| 108 | testResultsFormat: 'VSTest' |
| 109 | testResultsFiles: '**/*.trx' |
| 110 | mergeTestResults: true |
| 111 | |
| 112 | - task: DotNetCoreCLI@2 |
| 113 | displayName: 'Pack' |
| 114 | inputs: |
| 115 | command: 'pack' |
| 116 | packagesToPack: 'Libraries/**/*.csproj' |
| 117 | nobuild: true |
| 118 | configuration: '$(buildConfiguration)' |
| 119 | outputDir: '$(Build.ArtifactStagingDirectory)' |
| 120 | buildProperties: 'SymbolPackageFormat=snupkg' |
| 121 | |
| 122 | - task: 1ES.PublishNuget@1 |
| 123 | displayName: 'Push NuGet Packages to Internal Feed' |
| 124 | inputs: |
| 125 | useDotNetTask: false |
| 126 | packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg' |
| 127 | packageParentPath: '$(Build.ArtifactStagingDirectory)' |
| 128 | publishVstsFeed: '$(System.TeamProject)/TeamsSDKPreviews' |
| 129 | nuGetFeedType: internal |
| 130 | allowPackageConflicts: false # Allow duplicate versions for preview testing |
| 131 | publishPackageMetadata: true |
| 132 | retryCountOnTaskFailure: 2 |
| 133 | |
| 134 | - task: 1ES.PublishPipelineArtifact@1 |
| 135 | displayName: 'Publish NuGet Packages as Pipeline Artifact' |
| 136 | inputs: |
| 137 | targetPath: '$(Build.ArtifactStagingDirectory)' |
| 138 | artifactName: 'Packages' |
| 139 | |
| 140 | - ${{ if eq(parameters.publishType, 'Public') }}: |
| 141 | - stage: Build_Test_Sign_Pack |
| 142 | displayName: 'Build, Test, Sign, and Pack (Public)' |
| 143 | jobs: |
| 144 | - job: BuildTestSignPack |
| 145 | displayName: 'Build, Test, Sign, and Pack' |
| 146 | steps: |
| 147 | - checkout: self |
| 148 | |
| 149 | - task: UseDotNet@2 |
| 150 | displayName: 'Use .NET 8' |
| 151 | inputs: |
| 152 | packageType: 'sdk' |
| 153 | version: '8.0.x' |
| 154 | |
| 155 | - task: UseDotNet@2 |
| 156 | displayName: 'Use .NET 10' |
| 157 | inputs: |
| 158 | packageType: 'sdk' |
| 159 | version: '10.0.x' |
| 160 | |
| 161 | - pwsh: | |
| 162 | $nugetConfig = @" |
| 163 | <?xml version="1.0" encoding="utf-8"?> |
| 164 | <configuration> |
| 165 | <packageSources> |
| 166 | <clear /> |
| 167 | <add key="TeamsSDKPreviews" value="https://pkgs.dev.azure.com/DomoreexpGithub/Github_Pipelines/_packaging/TeamsSDKPreviews/nuget/v3/index.json" /> |
| 168 | </packageSources> |
| 169 | </configuration> |
| 170 | "@ |
| 171 | $nugetConfig | Out-File -FilePath "$(Build.SourcesDirectory)/nuget.config" -Encoding utf8 |
| 172 | displayName: 'Create nuget.config' |
| 173 | |
| 174 | - task: NuGetAuthenticate@1 |
| 175 | displayName: 'Authenticate with NuGet feeds' |
| 176 | |
| 177 | - script: dotnet restore |
| 178 | displayName: 'Restore' |
| 179 | |
| 180 | - script: dotnet build --no-restore --configuration $(buildConfiguration) |
| 181 | displayName: 'Build' |
| 182 | |
| 183 | - script: dotnet test --no-build --verbosity normal --logger trx --configuration $(buildConfiguration) |
| 184 | displayName: 'Test' |
| 185 | |
| 186 | - task: PublishTestResults@2 |
| 187 | displayName: 'Publish Test Results' |
| 188 | condition: succeededOrFailed() |
| 189 | inputs: |
| 190 | testResultsFormat: 'VSTest' |
| 191 | testResultsFiles: '**/*.trx' |
| 192 | mergeTestResults: true |
| 193 | |
| 194 | - template: .azdo/templates/sign-and-pack.yaml@self |
| 195 | |
| 196 | - task: 1ES.PublishPipelineArtifact@1 |
| 197 | displayName: 'Publish NuGet Packages as Pipeline Artifact' |
| 198 | inputs: |
| 199 | targetPath: '$(Build.ArtifactStagingDirectory)' |
| 200 | artifactName: 'Packages' |
| 201 | |
| 202 | - ${{ if eq(parameters.publishType, 'Public') }}: |
| 203 | - stage: PushToNuGet |
| 204 | displayName: 'Push Packages to nuget.org' |
| 205 | dependsOn: Build_Test_Sign_Pack |
| 206 | jobs: |
| 207 | - deployment: PushPackages |
| 208 | displayName: 'Manual Approval Required to Push Packages' |
| 209 | environment: |
| 210 | name: 'teams-net-publish' |
| 211 | strategy: |
| 212 | runOnce: |
| 213 | deploy: |
| 214 | steps: |
| 215 | - download: current |
| 216 | artifact: Packages |
| 217 | |
| 218 | - task: 1ES.PublishNuget@1 |
| 219 | displayName: 'Push Packages to nuget.org' |
| 220 | inputs: |
| 221 | useDotNetTask: false |
| 222 | packagesToPush: '$(Pipeline.Workspace)/Packages/*.nupkg' |
| 223 | packageParentPath: '$(Pipeline.Workspace)/Packages' |
| 224 | nuGetFeedType: external |
| 225 | publishFeedCredentials: 'Microsoft.Teams.*' |
| 226 | publishPackageMetadata: true |
| 227 | retryCountOnTaskFailure: 2 |
| 228 | |