From 7768c6fce34ca53245d78dc0f49bd0dfa6676bcd Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 27 Jan 2020 12:32:48 -0800 Subject: [PATCH] Publish Github release (#432) --- eng/PublishRelease.ps1 | 27 +++++++++++++++++++ eng/pipelines/build.yml | 13 ++++----- .../AutoRest.CSharp.V3.csproj | 17 +----------- 3 files changed, 33 insertions(+), 24 deletions(-) create mode 100644 eng/PublishRelease.ps1 diff --git a/eng/PublishRelease.ps1 b/eng/PublishRelease.ps1 new file mode 100644 index 00000000..e1974439 --- /dev/null +++ b/eng/PublishRelease.ps1 @@ -0,0 +1,27 @@ +param($Token, $BuildNumber, $Sha, $WorkingDirectory, $PackageJson) + +$WorkingDirectory = Resolve-Path $WorkingDirectory + +cp $PackageJson $WorkingDirectory -Force + +pushd $WorkingDirectory +try +{ + $currentVersion = node -p -e "require('./package.json').version"; + $devVersion="$currentVersion-dev.$BuildNumber" + + Write-Host "Setting version to $devVersion" + + npm version --no-git-tag-version $devVersion > Out-Null; + + $file = npm pack -q; + $name = [System.IO.Path]::GetFileNameWithoutExtension($file) + + Write-Host "Publishing $file" + +cmd /c "npx -q publish-release --token $Token --repo autorest.csharp --owner azure --name $name --tag $devVersion --notes=prerelease-build --prerelease --editRelease false --assets $file --target_commitish $Sha 2>&1" +} +finally +{ + popd +} \ No newline at end of file diff --git a/eng/pipelines/build.yml b/eng/pipelines/build.yml index 93065692..f427f5e9 100644 --- a/eng/pipelines/build.yml +++ b/eng/pipelines/build.yml @@ -38,11 +38,8 @@ jobs: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 DOTNET_CLI_TELEMETRY_OPTOUT: 1 DOTNET_MULTILEVEL_LOOKUP: 0 - - script: | - dotnet pack /t:NpmPackage src/AutoRest.CSharp.V3/AutoRest.CSharp.V3.csproj -o $(Build.ArtifactStagingDirectory) - displayName: "Publish NPM package" - - task: PublishPipelineArtifact@1 - condition: succeeded() - inputs: - artifactName: packages - path: $(Build.ArtifactStagingDirectory) \ No newline at end of file + - ${{if and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal'))}}: + - pwsh: ./eng/PublishRelease.ps1 -WorkingDirectory ./artifacts/bin/AutoRest.CSharp.V3/Debug/netcoreapp3.0/ -PackageJson ./src/AutoRest.CSharp.V3/package.json -Token $(Github-azuresdkci-personalaccesstoken) -Artifacts $(Build.ArtifactStagingDirectory) -BuildNumber $(Build.BuildNumber) -Sha $(Build.SourceVersion) + condition: succeeded() + failOnStderr: false + displayName: 'Publish to GitHub' diff --git a/src/AutoRest.CSharp.V3/AutoRest.CSharp.V3.csproj b/src/AutoRest.CSharp.V3/AutoRest.CSharp.V3.csproj index a85527a6..104c6a2c 100644 --- a/src/AutoRest.CSharp.V3/AutoRest.CSharp.V3.csproj +++ b/src/AutoRest.CSharp.V3/AutoRest.CSharp.V3.csproj @@ -26,20 +26,5 @@ - - - - - - - - - - - %(OutputOfPackLines.Identity) - - - - - +