Skip to content

Commit 66af950

Browse files
committed
.azure-pipelines/release.yml: add GitHub and NuGet.org publishing
Add a new stage (after build) to publish the assets to GitHub and NuGet.org. Each target (GitHub and NuGet.org) need to run in separate jobs due to restrictions of the 1ES pipeline templates: - Publishing a NuGet package requires us to use template `outputs` - `type: releaseJob` cannot specify outputs - `type: releaseJob` is required to use the `GitHubRelease` task Signed-off-by: Matthew John Cheetham <[email protected]>
1 parent 68d6cd6 commit 66af950

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

.azure-pipelines/release.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ parameters:
1414
type: boolean
1515
default: false
1616
displayName: 'Enable ESRP code signing'
17+
- name: 'github'
18+
type: boolean
19+
default: false
20+
displayName: 'Enable GitHub release publishing'
21+
- name: 'nuget'
22+
type: boolean
23+
default: false
24+
displayName: 'Enable NuGet package publishing'
1725

1826
#
1927
# 1ES Pipeline Templates do not allow using a matrix strategy so we create
@@ -61,6 +69,10 @@ variables:
6169
value: '1ESGitClient-ESRP-App'
6270
- name: 'esrpMIConnectionName'
6371
value: '1ESGitClient-ESRP-MI'
72+
- name: 'githubConnectionName'
73+
value: 'GitHub-GitCredentialManager'
74+
- name: 'nugetConnectionName'
75+
value: '1ESGitClient-NuGet'
6476
# ESRP signing variables set in the pipeline settings:
6577
# - esrpEndpointUrl
6678
# - esrpClientId
@@ -717,3 +729,103 @@ extends:
717729
"Parameters": {}
718730
}
719731
]
732+
733+
- stage: release
734+
displayName: 'Release'
735+
dependsOn: [build]
736+
condition: and(succeeded(), or(eq('${{ parameters.github }}', true), eq('${{ parameters.nuget }}', true)))
737+
jobs:
738+
- job: release_validation
739+
displayName: 'Release validation'
740+
pool:
741+
name: GitClientPME-1ESHostedPool-intel-pc
742+
image: ubuntu-x86_64-ado1es
743+
os: linux
744+
steps:
745+
- task: Bash@3
746+
displayName: 'Read version file'
747+
name: version
748+
inputs:
749+
targetType: inline
750+
script: |
751+
echo "##vso[task.setvariable variable=value;isOutput=true;isReadOnly=true]$(cat ./VERSION | sed -E 's/.[0-9]+$//')"
752+
753+
- job: github
754+
displayName: 'Publish GitHub release'
755+
dependsOn: release_validation
756+
condition: and(succeeded(), eq('${{ parameters.github }}', true))
757+
pool:
758+
name: GitClientPME-1ESHostedPool-intel-pc
759+
image: ubuntu-x86_64-ado1es
760+
os: linux
761+
variables:
762+
version: $[dependencies.release_validation.outputs['version.value']]
763+
templateContext:
764+
type: releaseJob
765+
isProduction: true
766+
inputs:
767+
# Installers and packages
768+
- input: pipelineArtifact
769+
artifactName: 'win-x86'
770+
targetPath: $(Pipeline.Workspace)/assets/win-x86
771+
- input: pipelineArtifact
772+
artifactName: 'osx-x64'
773+
targetPath: $(Pipeline.Workspace)/assets/osx-x64
774+
- input: pipelineArtifact
775+
artifactName: 'osx-arm64'
776+
targetPath: $(Pipeline.Workspace)/assets/osx-arm64
777+
- input: pipelineArtifact
778+
artifactName: 'linux-x64'
779+
targetPath: $(Pipeline.Workspace)/assets/linux-x64
780+
- input: pipelineArtifact
781+
artifactName: 'dotnet-tool'
782+
targetPath: $(Pipeline.Workspace)/assets/dotnet-tool
783+
steps:
784+
- task: GitHubRelease@1
785+
displayName: 'Create Draft GitHub Release'
786+
condition: and(succeeded(), eq('${{ parameters.github }}', true))
787+
inputs:
788+
gitHubConnection: $(githubConnectionName)
789+
repositoryName: git-ecosystem/git-credential-manager
790+
tag: 'v$(version)'
791+
tagSource: userSpecifiedTag
792+
target: release
793+
title: 'GCM $(version)'
794+
isDraft: true
795+
addChangeLog: false
796+
assets: |
797+
$(Pipeline.Workspace)/assets/win-x86/*.exe
798+
$(Pipeline.Workspace)/assets/win-x86/*.zip
799+
$(Pipeline.Workspace)/assets/osx-x64/*.pkg
800+
$(Pipeline.Workspace)/assets/osx-x64/*.tar.gz
801+
$(Pipeline.Workspace)/assets/osx-arm64/*.pkg
802+
$(Pipeline.Workspace)/assets/osx-arm64/*.tar.gz
803+
$(Pipeline.Workspace)/assets/linux-x64/*.deb
804+
$(Pipeline.Workspace)/assets/linux-x64/*.tar.gz
805+
$(Pipeline.Workspace)/assets/dotnet-tool/*.nupkg
806+
$(Pipeline.Workspace)/assets/dotnet-tool/*.snupkg
807+
808+
- job: nuget
809+
displayName: 'Publish NuGet package'
810+
dependsOn: release_validation
811+
condition: and(succeeded(), eq('${{ parameters.nuget }}', true))
812+
pool:
813+
name: GitClientPME-1ESHostedPool-intel-pc
814+
image: ubuntu-x86_64-ado1es
815+
os: linux
816+
variables:
817+
version: $[dependencies.release_validation.outputs['version.value']]
818+
templateContext:
819+
inputs:
820+
- input: pipelineArtifact
821+
artifactName: 'dotnet-tool'
822+
targetPath: $(Pipeline.Workspace)/assets/dotnet-tool
823+
outputs:
824+
- output: nuget
825+
condition: and(succeeded(), eq('${{ parameters.nuget }}', true))
826+
displayName: 'Publish .NET Tool NuGet package'
827+
packagesToPush: '$(Pipeline.Workspace)/assets/dotnet-tool/*.nupkg;$(Pipeline.Workspace)/assets/dotnet-tool/*.snupkg'
828+
packageParentPath: $(Pipeline.Workspace)/assets/dotnet-tool
829+
nuGetFeedType: external
830+
publishPackageMetadata: true
831+
publishFeedCredentials: $(nugetConnectionName)

0 commit comments

Comments
 (0)