-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathci-build.yml
More file actions
236 lines (212 loc) · 11 KB
/
ci-build.yml
File metadata and controls
236 lines (212 loc) · 11 KB
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# Build and generate the Java client library for the Microsoft Graph beta endpoint.
name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
trigger:
tags:
include:
- "v*"
parameters:
- name: previewBranch
type: string
default: "refs/heads/main"
- name: deployToGitHub
type: boolean
default: false
- name: deployToMaven
type: boolean
default: false
resources:
repositories:
- repository: 1ESPipelineTemplates
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release
extends:
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
sdl:
sourceAnalysisPool:
name: Azure-Pipelines-1ESPT-ExDShared
os: windows
image: windows-latest
stages:
- stage: build
jobs:
- job: build
pool:
name: 1es-ubuntu-latest-m
os: linux
#TODO maybe missing template context with sdl baselines?
steps:
- checkout: self
- task: JavaToolInstaller@1
inputs:
versionSpec: '21'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- task: DownloadSecureFile@1
name: downloadLocalProperties
inputs:
secureFile: 'local.properties'
- task: DownloadSecureFile@1
name: downloadSecringGpg
inputs:
secureFile: 'secring.gpg'
- pwsh: |
Copy-Item $(downloadSecringGpg.secureFilePath) secring.gpg -Verbose
Copy-Item $(downloadLocalProperties.secureFilePath) local.properties -Verbose
displayName: Copy secring and 'local.properties'
- script: ./gradlew publishToMavenLocal -PmavenCentralPublishingEnabled=true -PmavenCentralSnapshotArtifactSuffix=""
displayName: Publish to local Maven for verification
condition: contains(variables['build.sourceBranch'], 'refs/tags/v')
- script: ./gradlew publishToMavenLocal -PmavenCentralPublishingEnabled=true
displayName: Publish to local Maven for verification
condition: not(contains(variables['build.sourceBranch'], 'refs/tags/v'))
- script: ./gradlew publishMavenPublicationToADORepository -PmavenCentralPublishingEnabled=true -PmavenCentralSnapshotArtifactSuffix=""
displayName: Publish to local Maven ADO for ESRP
condition: contains(variables['build.sourceBranch'], 'refs/tags/v')
- script: ./gradlew publishMavenPublicationToADORepository -PmavenCentralPublishingEnabled=true
displayName: Publish to local Maven ADO for ESRP
condition: not(contains(variables['build.sourceBranch'], 'refs/tags/v'))
- pwsh: |
$contents = Get-Content gradle.properties -Raw
$major = $contents | Select-String -Pattern 'mavenMajorVersion\s*=\s*([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
$minor = $contents | Select-String -Pattern 'mavenMinorVersion\s*=\s*([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
$patch = $contents | Select-String -Pattern 'mavenPatchVersion\s*=\s*([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
$snapshot_suffix = if ($Env:BRANCH_NAME.StartsWith('refs/tags/v')) { '' } else { '-SNAPSHOT' }
$version = "$major.$minor.$patch$snapshot_suffix"
echo "Current version is $version"
echo "##vso[task.setvariable variable=PACKAGE_VERSION;]$version"
displayName: Get current version
name: GetVersion
env:
BRANCH_NAME: $(Build.SourceBranch)
- pwsh: |
.\scripts\validatePackageContents.ps1 -ArtifactId microsoft-graph-beta -Version $(PACKAGE_VERSION) -ValidateMavenMetadata $false
displayName: Inspect contents of local Maven cache
- pwsh: |
$packageFullPath = Join-Path -Path "./" -ChildPath "build/publishing-repository/com/microsoft/graph/microsoft-graph-beta" -AdditionalChildPath "$(PACKAGE_VERSION)"
echo "Package full path: $packageFullPath"
echo "##vso[task.setvariable variable=PACKAGE_PATH;]$packageFullPath"
displayName: Get the package full path
- task: 1ES.PublishPipelineArtifact@1
displayName: "Publish Artifact: jars"
inputs:
artifactName: jars
targetPath: "$(PACKAGE_PATH)"
- stage: deploy
# Allow deployment when: 1. build trigger by tag, 2. source branch matches preview branch or 3. manually triggered pipeline. All with succeeded build stage.
condition: and(or(contains(variables['build.sourceBranch'], 'refs/tags/v'), eq(variables['build.sourceBranch'], '${{ parameters.previewBranch }}'),eq(variables['Build.Reason'], 'Manual')), succeeded())
dependsOn: build
jobs:
- deployment: deploy_github
condition: or(and(contains(variables['build.sourceBranch'], 'refs/tags/v'), succeeded()), and(eq('${{ parameters.deployToGitHub }}', 'true'), succeeded()))
pool:
name: Azure-Pipelines-1ESPT-ExDShared
os: linux
image: ubuntu-latest
templateContext:
type: releaseJob
isProduction: true
inputs:
- input: pipelineArtifact
artifactName: jars
targetPath: "$(Pipeline.Workspace)"
environment: kiota-github-releases
strategy:
runOnce:
deploy:
steps:
- pwsh: |
$zips = Get-ChildItem -Path "$(Pipeline.Workspace)" -Filter "*.jar"
$zip = $zips | Select-Object -First 1
$zipName = $zip.Name
if ($zipName -match "\d+.\d+.\d+")
{
$version = $matches[0]
echo "Current version is $version"
echo "##vso[task.setvariable variable=artifactVersion;]$version"
}
else
{
Write-Error "No valid version found in jar file name."
exit 1
}
- task: GitHubRelease@1
inputs:
gitHubConnection: "microsoftkiota"
tagSource: userSpecifiedTag
tag: "v$(artifactVersion)"
title: "v$(artifactVersion)"
assets: |
$(Pipeline.Workspace)/**/*.jar
$(Pipeline.Workspace)/**/*.jar.md5
$(Pipeline.Workspace)/**/*.jar.sha1
$(Pipeline.Workspace)/**/*.jar.sha256
$(Pipeline.Workspace)/**/*.jar.sha512
$(Pipeline.Workspace)/**/*.jar.asc
$(Pipeline.Workspace)/**/*.jar.asc.md5
$(Pipeline.Workspace)/**/*.jar.asc.sha1
$(Pipeline.Workspace)/**/*.jar.asc.sha256
$(Pipeline.Workspace)/**/*.jar.asc.sha512
$(Pipeline.Workspace)/**/*.pom
$(Pipeline.Workspace)/**/*.pom.md5
$(Pipeline.Workspace)/**/*.pom.sha1
$(Pipeline.Workspace)/**/*.pom.sha256
$(Pipeline.Workspace)/**/*.pom.sha512
$(Pipeline.Workspace)/**/*.pom.asc
$(Pipeline.Workspace)/**/*.pom.asc.md5
$(Pipeline.Workspace)/**/*.pom.asc.sha1
$(Pipeline.Workspace)/**/*.pom.asc.sha256
$(Pipeline.Workspace)/**/*.pom.asc.sha512
$(Pipeline.Workspace)/**/*.module
$(Pipeline.Workspace)/**/*.module.md5
$(Pipeline.Workspace)/**/*.module.sha1
$(Pipeline.Workspace)/**/*.module.sha256
$(Pipeline.Workspace)/**/*.module.sha512
$(Pipeline.Workspace)/**/*.module.asc
$(Pipeline.Workspace)/**/*.module.asc.md5
$(Pipeline.Workspace)/**/*.module.asc.sha1
$(Pipeline.Workspace)/**/*.module.asc.sha256
$(Pipeline.Workspace)/**/*.module.asc.sha512
addChangeLog: false
action: edit
- deployment: deploy_maven
# snapshots are not supported by ESRP release for now, but they are planning to add support. When it happens, simply remove the condition
condition: or(and(contains(variables['build.sourceBranch'], 'refs/tags/v'), succeeded()), and(eq('${{ parameters.deployToMaven }}', 'true'), succeeded()))
pool:
name: Azure-Pipelines-1ESPT-ExDShared
os: linux
image: ubuntu-latest
templateContext:
type: releaseJob
isProduction: true
inputs:
- input: pipelineArtifact
artifactName: jars
targetPath: "$(Pipeline.Workspace)"
dependsOn: []
environment: maven_central
strategy:
runOnce:
deploy:
steps:
- task: EsrpRelease@9
inputs:
connectedservicename: "Federated DevX ESRP Managed Identity Connection"
usemanagedidentity: false
keyvaultname: "akv-prod-eastus"
authcertname: "ReferenceLibraryPrivateCert"
signcertname: "ReferencePackagePublisherCertificate"
clientid: "65035b7f-7357-4f29-bf25-c5ee5c3949f8"
intent: "PackageDistribution"
contenttype: "Maven"
contentsource: "Folder"
folderlocation: "$(Pipeline.Workspace)"
waitforreleasecompletion: true
owners: mmainer@microsoft.com,gavinbarron@microsoft.com
approvers: mmainer@microsoft.com
serviceendpointurl: "https://api.esrp.microsoft.com"
mainpublisher: "ESRPRELPACMAN"
domaintenantid: "cdc5aeea-15c5-4db6-b079-fcadd2505dc2"