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