1
+ # Copyright (c) Microsoft Corporation. All rights reserved.
2
+ # Licensed under the MIT License.
3
+
4
+ name : $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
5
+
6
+ trigger :
7
+ tags :
8
+ include :
9
+ - " v*"
10
+ branches :
11
+ include :
12
+ - main
13
+
14
+ parameters :
15
+ - name : previewBranch
16
+ type : string
17
+ default : " refs/heads/main"
18
+
19
+ resources :
20
+ repositories :
21
+ - repository : 1ESPipelineTemplates
22
+ type : git
23
+ name : 1ESPipelineTemplates/1ESPipelineTemplates
24
+ ref : refs/tags/release
25
+
26
+ extends :
27
+ template : v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
28
+ parameters :
29
+ sdl :
30
+ sourceAnalysisPool :
31
+ name : Azure-Pipelines-1ESPT-ExDShared
32
+ os : windows
33
+ image : windows-latest
34
+
35
+ stages :
36
+ - stage : build
37
+ jobs :
38
+ - job : build
39
+ pool :
40
+ name : Azure-Pipelines-1ESPT-ExDShared
41
+ os : linux
42
+ image : ubuntu-latest
43
+ # TODO maybe missing template context with sdl baselines?
44
+ steps :
45
+ - checkout : self
46
+ persistCredentials : true
47
+
48
+ - task : JavaToolInstaller@1
49
+ inputs :
50
+ versionSpec : ' 21'
51
+ jdkArchitectureOption : ' x64'
52
+ jdkSourceOption : ' PreInstalled'
53
+
54
+ - task : DownloadSecureFile@1
55
+ name : downloadLocalProperties
56
+ inputs :
57
+ secureFile : ' local.properties'
58
+
59
+ - task : DownloadSecureFile@1
60
+ name : downloadSecringGpg
61
+ inputs :
62
+ secureFile : ' secring.gpg'
63
+
64
+ - pwsh : |
65
+ Copy-Item $(downloadSecringGpg.secureFilePath) secring.gpg -Verbose
66
+ Copy-Item $(downloadLocalProperties.secureFilePath) local.properties -Verbose
67
+ displayName: Copy secring and 'local.properties'
68
+
69
+ - script : ./gradlew --no-daemon publishToMavenLocal -PmavenCentralPublishingEnabled=true -PmavenCentralSnapshotArtifactSuffix=""
70
+ displayName : Publish to local Maven for verification
71
+ # condition: contains(variables['build.sourceBranch'], 'refs/tags/v')
72
+
73
+ # - script: ./gradlew --no-daemon publishToMavenLocal -PmavenCentralPublishingEnabled=true
74
+ # displayName: Publish to local Maven for verification
75
+ # condition: not(contains(variables['build.sourceBranch'], 'refs/tags/v'))
76
+
77
+ - script : ./gradlew --no-daemon publishMavenPublicationToADORepository -PmavenCentralPublishingEnabled=true -PmavenCentralSnapshotArtifactSuffix=""
78
+ displayName : Publish to local Maven ADO for ESRP
79
+ # condition: contains(variables['build.sourceBranch'], 'refs/tags/v')
80
+
81
+ # - script: ./gradlew --no-daemon publishMavenPublicationToADORepository -PmavenCentralPublishingEnabled=true
82
+ # displayName: Publish to local Maven ADO for ESRP
83
+ # condition: not(contains(variables['build.sourceBranch'], 'refs/tags/v'))
84
+
85
+ - pwsh : |
86
+ $contents = Get-Content gradle.properties -Raw
87
+ $major = $contents | Select-String -Pattern 'mavenMajorVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
88
+ $minor = $contents | Select-String -Pattern 'mavenMinorVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
89
+ $patch = $contents | Select-String -Pattern 'mavenPatchVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
90
+ # $snapshot_suffix = if ($Env:BRANCH_NAME.StartsWith('refs/tags/v')) { '' } else { '-SNAPSHOT' }
91
+ $version = "$major.$minor.$patch$snapshot_suffix"
92
+ echo "Current version is $version"
93
+ echo "##vso[task.setvariable variable=PACKAGE_VERSION;]$version"
94
+ displayName: Get current version
95
+ name: GetVersion
96
+ env:
97
+ BRANCH_NAME: $(Build.SourceBranchName)
98
+
99
+ - pwsh : |
100
+ .\scripts\validatePackageContents.ps1 -ArtifactId microsoft-graph -Version $(PACKAGE_VERSION) -ValidateMavenMetadata $false
101
+ displayName: Inspect contents of local Maven cache
102
+
103
+ - pwsh : |
104
+ .\scripts\zipPackageContent.ps1 -OutputDirectory $Env:OUTPUT_DIRECTORY -ArtifactId microsoft-graph -PackageSegment abstractions -Version $(PACKAGE_VERSION)
105
+ echo "list of zips:"
106
+ Get-ChildItem -Path $Env:OUTPUT_DIRECTORY -Filter "*.zip" | ForEach-Object { Write-Host $_.FullName }
107
+ displayName: Zip contents of local Maven cache
108
+ env:
109
+ OUTPUT_DIRECTORY: $(Build.ArtifactStagingDirectory)
110
+
111
+ - task : 1ES.PublishPipelineArtifact@1
112
+ displayName : " Publish Artifact: jars"
113
+ inputs :
114
+ artifactName : jars
115
+ targetPath : " $(Build.ArtifactStagingDirectory)"
116
+
117
+ - stage : deploy
118
+ # condition: and(or(contains(variables['build.sourceBranch'], 'refs/tags/v'), eq(variables['build.sourceBranch'], '${{ parameters.previewBranch }}')), succeeded())
119
+ dependsOn : build
120
+ jobs :
121
+ - deployment : deploy_github
122
+ condition : and(contains(variables['build.sourceBranch'], 'refs/tags/v'), succeeded())
123
+ pool :
124
+ name : Azure-Pipelines-1ESPT-ExDShared
125
+ os : linux
126
+ image : ubuntu-latest
127
+ templateContext :
128
+ type : releaseJob
129
+ isProduction : true
130
+ inputs :
131
+ - input : pipelineArtifact
132
+ artifactName : jars
133
+ targetPath : " $(Pipeline.Workspace)"
134
+ environment : kiota-github-releases
135
+ strategy :
136
+ runOnce :
137
+ deploy :
138
+ steps :
139
+ - pwsh : |
140
+ $zips = Get-ChildItem -Path "$(Pipeline.Workspace)" -Filter "*.zip"
141
+ $zip = $zips | Select-Object -First 1
142
+ $zipName = $zip.Name
143
+ if ($zipName -match "\d+.\d+.\d+")
144
+ {
145
+ $version = $matches[0]
146
+ echo "Current version is $version"
147
+ echo "##vso[task.setvariable variable=artifactVersion;]$version"
148
+ }
149
+ else
150
+ {
151
+ Write-Error "No valid version found in zip file name."
152
+ exit 1
153
+ }
154
+
155
+ - pwsh : |
156
+ $zips = Get-ChildItem -Path "$(Pipeline.Workspace)" -Filter "*.zip"
157
+ foreach ($zip in $zips) {
158
+ $targetPath = $zip.FullName.Replace(".zip", "")
159
+ Expand-Archive -Path $zip.FullName -DestinationPath $targetPath
160
+ Remove-Item -Path $zip.FullName -Force
161
+ }
162
+ displayName: Unzip artifacts
163
+
164
+ - task : GitHubRelease@1
165
+ inputs :
166
+ gitHubConnection : " microsoftkiota"
167
+ tagSource : userSpecifiedTag
168
+ tag : " v$(artifactVersion)"
169
+ title : " v$(artifactVersion)"
170
+ assets : |
171
+ $(Pipeline.Workspace)/**/*.jar
172
+ $(Pipeline.Workspace)/**/*.jar.md5
173
+ $(Pipeline.Workspace)/**/*.jar.sha1
174
+ $(Pipeline.Workspace)/**/*.jar.sha256
175
+ $(Pipeline.Workspace)/**/*.jar.sha512
176
+ $(Pipeline.Workspace)/**/*.jar.asc
177
+ $(Pipeline.Workspace)/**/*.jar.asc.md5
178
+ $(Pipeline.Workspace)/**/*.jar.asc.sha1
179
+ $(Pipeline.Workspace)/**/*.jar.asc.sha256
180
+ $(Pipeline.Workspace)/**/*.jar.asc.sha512
181
+ $(Pipeline.Workspace)/**/*.pom
182
+ $(Pipeline.Workspace)/**/*.pom.md5
183
+ $(Pipeline.Workspace)/**/*.pom.sha1
184
+ $(Pipeline.Workspace)/**/*.pom.sha256
185
+ $(Pipeline.Workspace)/**/*.pom.sha512
186
+ $(Pipeline.Workspace)/**/*.pom.asc
187
+ $(Pipeline.Workspace)/**/*.pom.asc.md5
188
+ $(Pipeline.Workspace)/**/*.pom.asc.sha1
189
+ $(Pipeline.Workspace)/**/*.pom.asc.sha256
190
+ $(Pipeline.Workspace)/**/*.pom.asc.sha512
191
+ $(Pipeline.Workspace)/**/*.module
192
+ $(Pipeline.Workspace)/**/*.module.md5
193
+ $(Pipeline.Workspace)/**/*.module.sha1
194
+ $(Pipeline.Workspace)/**/*.module.sha256
195
+ $(Pipeline.Workspace)/**/*.module.sha512
196
+ $(Pipeline.Workspace)/**/*.module.asc
197
+ $(Pipeline.Workspace)/**/*.module.asc.md5
198
+ $(Pipeline.Workspace)/**/*.module.asc.sha1
199
+ $(Pipeline.Workspace)/**/*.module.asc.sha256
200
+ $(Pipeline.Workspace)/**/*.module.asc.sha512
201
+
202
+ addChangeLog : false
203
+ action : edit
204
+
205
+ - deployment : deploy_maven
206
+ # snapshots are not supported by ESRP release for now, but they are planning to add support. When it happens, simply remove the condition
207
+ # condition: and(contains(variables['build.sourceBranch'], 'refs/tags/v'), succeeded())
208
+ pool :
209
+ name : Azure-Pipelines-1ESPT-ExDShared
210
+ os : linux
211
+ image : ubuntu-latest
212
+ templateContext :
213
+ type : releaseJob
214
+ isProduction : true
215
+ inputs :
216
+ - input : pipelineArtifact
217
+ artifactName : jars
218
+ targetPath : " $(Pipeline.Workspace)"
219
+ dependsOn : []
220
+ environment : maven_central
221
+ strategy :
222
+ runOnce :
223
+ deploy :
224
+ steps :
225
+ - task : EsrpRelease@9
226
+ inputs :
227
+ connectedservicename : " Federated DevX ESRP Managed Identity Connection"
228
+ usemanagedidentity : false
229
+ keyvaultname : " akv-prod-eastus"
230
+ authcertname : " ReferenceLibraryPrivateCert"
231
+ signcertname : " ReferencePackagePublisherCertificate"
232
+ clientid : " 65035b7f-7357-4f29-bf25-c5ee5c3949f8"
233
+ intent : " PackageDistribution"
234
+ contenttype : " Maven"
235
+ contentsource : " Folder"
236
+ folderlocation : " $(Pipeline.Workspace)"
237
+ waitforreleasecompletion : true
238
+ owners : vibiret@microsoft.com
239
+ approvers : mmainer@microsoft.com
240
+ serviceendpointurl : " https://api.esrp.microsoft.com"
241
+ mainpublisher : " ESRPRELPACMAN"
242
+ domaintenantid : " cdc5aeea-15c5-4db6-b079-fcadd2505dc2"
0 commit comments