Skip to content

Commit

Permalink
Showing 2 changed files with 118 additions and 1 deletion.
103 changes: 103 additions & 0 deletions azure-pipelines/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
trigger: none # We only want to trigger manually or based on resources
pr: none

resources:
pipelines:
- pipeline: CI
source: Nerdbank.Streams
trigger:
tags:
- auto-release

stages:
- stage: GitHubRelease
displayName: GitHub Release
jobs:
- deployment: create
pool:
vmImage: ubuntu-latest
environment: No-Approval
strategy:
runOnce:
deploy:
steps:
- download: none
- powershell: |
Write-Host "##vso[build.updatebuildnumber]$(resources.pipeline.CI.runName)"
displayName: Set pipeline name
- task: GitHubRelease@1
displayName: GitHub release (create)
inputs:
gitHubConnection: GitHub AArnott
repositoryName: $(Build.Repository.Name)
target: $(resources.pipeline.CI.sourceCommit)
tagSource: userSpecifiedTag
tag: v$(resources.pipeline.CI.runName)
title: v$(resources.pipeline.CI.runName)
isDraft: true
changeLogCompareToRelease: lastNonDraftRelease
changeLogType: issueBased
changeLogLabels: |
[
{ "label" : "bug", "displayName" : "Fixes", "state" : "closed" },
{ "label" : "enhancement", "displayName": "Enhancements", "state" : "closed" }
]
- stage: nuget_org
displayName: nuget.org
dependsOn: GitHubRelease
jobs:
- deployment: push
pool:
vmImage: ubuntu-latest
environment: No-Approval
strategy:
runOnce:
deploy:
steps:
- download: CI
artifact: deployables-Windows
displayName: Download deployables-Windows artifact
patterns: 'deployables-Windows/NuGet/*'
- task: NuGetToolInstaller@1
displayName: Use NuGet 5.x
inputs:
versionSpec: 5.x
- task: NuGetCommand@2
displayName: NuGet push
inputs:
command: push
packagesToPush: $(Pipeline.Workspace)/CI/deployables-Windows/NuGet/*.nupkg
nuGetFeedType: external
publishFeedCredentials: nuget.org

- stage: npmjs_org
displayName: npmjs.org
dependsOn: GitHubRelease
jobs:
- deployment: push
pool:
vmImage: ubuntu-latest
environment: No-Approval
strategy:
runOnce:
deploy:
steps:
- download: CI
artifact: deployables-Windows
displayName: Download deployables-Windows artifact
patterns: 'deployables-Windows/npm/*'
- powershell: |
$tgz = (Get-ChildItem "$(Pipeline.Workspace)/CI/deployables-Windows/npm/*.tgz")[0].FullName
npm init -y
npm install $tgz
workingDirectory: $(Agent.TempDirectory)
displayName: Prepare to publish TGZ
- task: Npm@1
displayName: npm publish
inputs:
command: publish
workingDir: $(Agent.TempDirectory)/node_modules/nerdbank-streams
verbose: false
publishEndpoint: npmjs.org
16 changes: 15 additions & 1 deletion src/Nerdbank.Streams/PipeExtensions.cs
Original file line number Diff line number Diff line change
@@ -471,7 +471,21 @@ private static PipeReader UsePipeReader(this Stream stream, int sizeHint = 0, Pi
// we can return a decorated PipeReader that calls us from its Complete method directly.
var combinedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
#pragma warning disable CS0618 // Type or member is obsolete
pipe.Writer.OnReaderCompleted((ex, state) => ((CancellationTokenSource)state).Cancel(), combinedTokenSource);
pipe.Writer.OnReaderCompleted(
(ex, state) =>
{
try
{
((CancellationTokenSource)state).Cancel();
}
catch (AggregateException cancelException)
{
// .NET Core may throw this when canceling async I/O (https://github.com/dotnet/runtime/issues/39902).
// Just swallow it. We've canceled what we intended to.
cancelException.Handle(x => x is ObjectDisposedException);
}
},
combinedTokenSource);

// When this argument is provided, it provides a means to ensure we don't hang while reading from an I/O pipe
// that doesn't respect the CancellationToken. Disposing a Stream while reading is a means to terminate the ReadAsync operation.

0 comments on commit 5f56226

Please sign in to comment.