1+ trigger :
2+ - ' *'
3+
4+ pool :
5+ vmImage : ' windows-2022'
6+
7+ variables :
8+ solution : ' **/*.sln'
9+ buildPlatform : ' Any CPU'
10+ buildConfiguration : ' Release'
11+
12+ jobs :
13+ # ############################
14+ # Build_SqlQueryTools #
15+ # ############################
16+ - job : Build_SqlQueryTools
17+ displayName : ' Build latest SqlQueryTools commit'
18+ steps :
19+
20+ - task : NuGetToolInstaller@1
21+ displayName : ' Install nuget tool 4.7.1'
22+ inputs :
23+ versionSpec : ' 4.7.1'
24+
25+ - task : NuGetCommand@2
26+ displayName : ' Restore nuget packages for SqlQueryTools solution'
27+ inputs :
28+ command : ' restore'
29+ restoreSolution : ' **/SqlQueryTools.sln'
30+
31+ - task : VSBuild@1
32+ displayName : ' Build SqlQueryTools solution'
33+ inputs :
34+ solution : ' **\SqlQueryTools.sln'
35+ maximumCpuCount : true
36+ platform : ' $(buildPlatform)'
37+ configuration : ' $(buildConfiguration)'
38+
39+ - task : CopyFiles@2
40+ displayName : ' Copy result of build to Artifact folder'
41+ inputs :
42+ SourceFolder : ' $(Build.SourcesDirectory)'
43+ Contents : |
44+ README.md
45+ publish.extension.manifest.json
46+ **/SqlQueryTools.vsix
47+ TargetFolder : ' $(Build.StagingDirectory)/Artifact'
48+ CleanTargetFolder : true
49+ flattenFolders : true
50+
51+ - task : PublishPipelineArtifact@1
52+ displayName : ' Publish Artifact folder'
53+ inputs :
54+ targetPath : ' $(Build.StagingDirectory)/Artifact'
55+ artifact : ' SqlQueryTools'
56+ publishLocation : ' pipeline'
57+
58+ - task : PowerShell@2
59+ name : CurrentVsixManifest
60+ displayName : ' Read current vsix version from manifest file'
61+ inputs :
62+ targetType : ' inline'
63+ script : |
64+ $vsixManifestPath = Resolve-Path $(Build.SourcesDirectory)\src\SqlQueryTools\source.extension.vsixmanifest
65+ [xml]$vsixManifestContent = Get-Content $vsixManifestPath
66+ $vsixVersion = $vsixManifestContent.PackageManifest.Metadata.Identity.Version
67+ echo "Found vsix version = $vsixVersion"
68+ echo "##vso[task.setvariable variable=VsixVersion;isOutput=true]$vsixVersion"
69+
70+ # ###########################################
71+ # Get_Previous_SqlQueryTools_Release #
72+ # ###########################################
73+ - job : Get_Previous_SqlQueryTools_Release
74+ displayName : ' Get previous SqlQueryTools release'
75+ dependsOn :
76+ - Build_SqlQueryTools
77+ condition : and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
78+ steps :
79+
80+ - checkout : none
81+
82+ - task : DownloadGitHubRelease@0
83+ displayName : ' Download the latest release from GitHub'
84+ inputs :
85+ connection : ' github release connection'
86+ userRepository : ' gmarginet/SqlQueryTools'
87+ defaultVersionType : ' latest'
88+ itemPattern : ' **/*.vsix'
89+ downloadPath : ' $(Build.StagingDirectory)/PreviousGitHubRelease'
90+
91+ - task : ExtractFiles@1
92+ displayName : ' Extract the latest release'
93+ inputs :
94+ archiveFilePatterns : ' $(System.ArtifactsDirectory)/PreviousGitHubRelease/*.vsix'
95+ destinationFolder : ' $(System.ArtifactsDirectory)/PreviousGitHubRelease/Content'
96+ cleanDestinationFolder : true
97+ overwriteExistingFiles : false
98+
99+ - task : PowerShell@2
100+ name : PreviousVsixManifest
101+ displayName : ' Read previous vsix version from manifest file'
102+ inputs :
103+ targetType : ' inline'
104+ script : |
105+ $vsixManifestPath = Resolve-Path $(System.ArtifactsDirectory)\PreviousGitHubRelease\Content\extension.vsixmanifest
106+ [xml]$vsixManifestContent = Get-Content $vsixManifestPath
107+ $vsixVersion = $vsixManifestContent.PackageManifest.Metadata.Identity.Version
108+ echo "Found vsix version = $vsixVersion"
109+ echo "##vso[task.setvariable variable=VsixVersion;isOutput=true]$vsixVersion"
110+
111+ # #############################
112+ # Deploy_SqlQueryTools #
113+ # #############################
114+ - job : Deploy_SqlQueryTools
115+ displayName : ' Deploy latest SqlQueryTools commit'
116+ dependsOn :
117+ - Build_SqlQueryTools
118+ - Get_Previous_SqlQueryTools_Release
119+ condition : |
120+ and(
121+ succeeded(),
122+ eq(variables['Build.SourceBranch'], 'refs/heads/master'),
123+ ne(dependencies.Build_SqlQueryTools.outputs['CurrentVsixManifest.VsixVersion'],
124+ dependencies.Get_Previous_SqlQueryTools_Release.outputs['PreviousVsixManifest.VsixVersion'])
125+ )
126+ variables :
127+ currentVsixVersion : $[ dependencies.Build_SqlQueryTools.outputs['CurrentVsixManifest.VsixVersion'] ]
128+ steps :
129+
130+ - checkout : none
131+
132+ - task : DownloadPipelineArtifact@2
133+ displayName : ' Download artifact'
134+ inputs :
135+ buildType : ' current'
136+ artifactName : ' SqlQueryTools'
137+ targetPath : ' $(Build.StagingDirectory)/Artifact'
138+
139+ - task : GitHubRelease@1
140+ displayName : ' Publish new release to GitHub'
141+ inputs :
142+ gitHubConnection : ' github release connection'
143+ repositoryName : ' gmarginet/SqlQueryTools'
144+ action : ' create'
145+ target : ' $(Build.SourceVersion)'
146+ tagSource : ' userSpecifiedTag'
147+ tag : ' v$(currentVsixVersion)'
148+ assets : ' $(Build.StagingDirectory)/Artifact/SqlQueryTools.vsix'
149+ changeLogCompareToRelease : ' lastFullRelease'
150+ changeLogType : ' issueBased'
151+ changeLogLabels :
152+
153+ - task : PowerShell@2
154+ displayName : ' Publish new release to Marketplace'
155+ env :
156+ PAT_MARKETPLACE : $(PAT_Marketplace)
157+ inputs :
158+ targetType : ' inline'
159+ script : |
160+ $pat = ${env:PAT_MARKETPLACE}
161+ $payloadPath = Resolve-Path $(Build.StagingDirectory)\Artifact\SqlQueryTools.vsix
162+ $publishManifestPath = Resolve-Path $(Build.StagingDirectory)\Artifact\publish.extension.manifest.json
163+ $Installation = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -format json | ConvertFrom-Json
164+ $vsixPublisher = Join-Path -Path $Installation.installationPath -ChildPath "VSSDK\VisualStudioIntegration\Tools\Bin\VsixPublisher.exe" -Resolve
165+ & $vsixPublisher publish -payload $payloadPath -publishManifest $publishManifestPath -personalAccessToken $pat -ignoreWarnings "VSIXValidatorWarning01,VSIXValidatorWarning02,VSIXValidatorWarning08"
0 commit comments