-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
230 lines (200 loc) · 6.88 KB
/
azure-pipelines.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
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
trigger:
branches:
include:
- main
paths:
exclude:
- README.md
- LICENSE
- .vscode/*
pr:
drafts: false
branches:
include:
- main
paths:
exclude:
- README.md
- LICENSE
resources:
repositories:
- repository: build-pipeline-scripts
type: git
ref: master
name: iModelTechnologies/imodeljs-build-pipeline-scripts
- repository: itwinjs-core
type: github
endpoint: iModelJs
name: iTwin/itwinjs-core
ref: refs/heads/master
stages:
- stage: Build
displayName: Build
jobs:
- job: Build
strategy:
matrix:
linux:
imageName: 'ubuntu-latest'
# mac:
# imageName: 'macos-latest'
windows:
imageName: 'windows-latest'
pool:
vmImage: '$(imageName)'
steps:
- checkout: self
persistCredentials: true
clean: true
- task: NodeTool@0
inputs:
versionSpec: '22.11.0'
displayName: 'Install Node.js'
- script: |
npm install
displayName: 'install packages'
# - script: |
# npm ci
# displayName: 'npm ci'
- script: |
npm run lint
displayName: 'npm run lint'
- script: |
npm run build
displayName: 'npm run build'
- script: |
npm run test:standalone
displayName: 'npm run test:standalone'
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
- script: |
npm run test:integration
displayName: 'npm run test:integration'
env:
imjs_buddi_resolve_url_using_region: $(env)
test_project_id: $(test_project_id)
test_user_name: $(test_user_name)
test_user_password: $(test_user_password)
test_client_id: $(test_client_id)
test_redirect_uri: $(test_redirect_uri)
test_scopes: $(test_scopes)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
- script: |
npm run documentation
displayName: 'npm install and build documentation'
- script: |
npm run extract
displayName: 'extract code snippets'
- task: CopyFiles@2
displayName: 'Copy generated docs to: $(Build.StagingDirectory)/docs/'
inputs:
SourceFolder: $(Build.SourcesDirectory)/documentation/
TargetFolder: $(Build.StagingDirectory)/docs/
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: Connector-Framework Docs'
inputs:
PathtoPublish: '$(Build.StagingDirectory)/docs/'
ArtifactName: 'Connector-Framework Docs'
- bash: |
checkVersion() {
localVer=$1
name=$2
remoteVer=$(npm view $name version)
if [ -z "$remoteVer" ]; then
remoteVer=0.0.0
fi
olderVer=$(printf '%s\n' "$localVer" "$remoteVer" | sort -V | head -n1)
if [ "$localVer" != "$remoteVer" ] && [ "$remoteVer" = "$olderVer" ]; then
echo true
else
echo false
fi
}
version=$(node -p "require('./package.json').version")
name=$(node -p "require('./package.json').name")
update=$(checkVersion $version $name)
if [ "$update" = "true" ] ; then
echo "package publishing conditions are met."
shouldPublish=true
else
echo "package publishing conditions not met."
shouldPublish=false
fi
echo "##vso[task.setvariable variable=shouldPublish;isOutput=true]$shouldPublish"
echo "##vso[task.setvariable variable=version;isOutput=true]$version"
echo "##vso[task.setvariable variable=name;isOutput=true]$name"
displayName: 'Store Build Info'
name: info
condition: and(succeeded(), eq(variables.attempt_publish, true), eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Agent.OS'], 'Linux'))
- bash: |
echo "shouldPublish: $(info.shouldPublish)"
echo $(System.DefaultWorkingDirectory)
pwd
ls
displayName: 'Show Build Info'
condition: and(succeeded(), eq(variables['info.shouldPublish'], 'true'))
- script: |
npm pack
displayName: 'npm pack @itwin/connector-framework'
condition: and(succeeded(), eq(variables['info.shouldPublish'], 'true'))
- task: CopyFiles@2
inputs:
sourceFolder: $(System.DefaultWorkingDirectory)
contents: '*.tgz'
targetFolder: $(Build.ArtifactStagingDirectory)/connector-framework
displayName: 'Copy @itwin/connector-framework'
condition: and(succeeded(), eq(variables['info.shouldPublish'], 'true'))
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/connector-framework'
artifactName: connector-framework
displayName: 'Publish Connector Framework Artifact'
condition: and(succeeded(), eq(variables['info.shouldPublish'], 'true'))
- stage: Publish
displayName: Publish
condition: and(succeeded(), eq(dependencies.Build.outputs['Build.linux.info.shouldPublish'], 'true'))
dependsOn: Build
jobs:
- template: templates/npmjs-publish-deployment.yaml@build-pipeline-scripts
parameters:
path: '*.tgz'
artifactName: connector-framework
name: ConnectorFramework
dryrun: false
- job: ReleaseTag
displayName: Release Tag
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
persistCredentials: true
clean: true
- pwsh: |
$versionNum=(Get-Content ./package.json | ConvertFrom-Json).version
git config user.name 'imodeljs-admin'
git config user.email '[email protected]'
git tag -a "release/$versionNum" -m "v$versionNum"
git push origin "release/$versionNum"
displayName: 'git tag'
- stage: Validate_Docs
dependsOn: Build
condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'PullRequest', 'Manual'))
jobs:
- template: common/config/azure-pipelines/jobs/docs-build.yaml@itwinjs-core
parameters:
checkout: itwinjs-core
useCurrentConnectorFrameworkDocsArtifact: true
- stage: Tag_Docs
dependsOn: Validate_Docs
condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'Manual'))
jobs:
- job: Tag_Docs
displayName: Tag Docs
pool:
vmImage: 'ubuntu-latest'
steps:
- task: tagBuildOrRelease@0
displayName: Tag Docs
inputs:
type: "Build"
tags: "hasDocs"
condition: and(contains(variables['Build.SourceVersionMessage'], '[publish docs]'), not(contains(variables['Build.SourceVersionMessage'], '(dev)')))