-
Notifications
You must be signed in to change notification settings - Fork 2
/
azure-pipelines.yml
169 lines (140 loc) · 4.4 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
trigger:
branches:
include:
- main
paths:
exclude:
- docs/*
- README.md
- LICENSE
pr:
drafts: false
branches:
include:
- main
paths:
exclude:
- docs/*
- README.md
- LICENSE
resources:
repositories:
- repository: build-pipeline-scripts
type: git
ref: master
name: iModelTechnologies/imodeljs-build-pipeline-scripts
stages:
- stage: Build
displayName: Build
jobs:
- job: BuildPCFPackages
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: '16.17.0'
displayName: 'Install Node.js'
# @itwin/pcf build
- script: |
npm ci
displayName: 'npm ci'
workingDirectory: core
- script: |
npm run build
displayName: 'npm run build'
workingDirectory: core
- script: |
npm run test:unit
displayName: 'npm run test:unit'
workingDirectory: core
- script: |
npm run test:integration
displayName: 'npm run test:integration'
workingDirectory: core
env:
imjs_test_project_id: $(test_project_id)
imjs_test_imodel_id: $(test_imodel_id)
imjs_test_client_id: $(test_client_id)
imjs_test_client_secret: $(test_client_secret)
imjs_test_regular_user_name: $(test_user_name)
imjs_test_regular_user_password: $(test_user_password)
- bash: |
cp ../README.md .
cp ../LICENSE .
npm pack
displayName: 'npm pack'
workingDirectory: core
- task: CopyFiles@2
inputs:
sourceFolder: core
contents: '*.tgz'
targetFolder: $(Build.ArtifactStagingDirectory)/core
displayName: 'Copy @itwin/pcf'
# publish artifact
- bash: |
coreVer=$(node -p "require('./core/package.json').version")
coreName=$(node -p "require('./core/package.json').name")
checkVer() {
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
}
updateCore=$(checkVer $coreVer $coreName)
if [ "$updateCore" = "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=coreVer;isOutput=true]$coreVer"
echo "##vso[task.setvariable variable=coreName;isOutput=true]$coreName"
displayName: 'Store Build Info'
name: info
condition: and(succeeded(), eq(variables.try_publish, true), eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Agent.OS'], 'Linux'))
- bash: |
echo "shouldPublish: $(info.shouldPublish)"
echo "coreVer: $(info.coreVer)"
echo "coreName: $(info.coreName)"
ls
ls core
displayName: 'Show Build Info'
condition: and(succeeded(), eq(variables['info.shouldPublish'], 'true'))
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/core'
artifactName: core
displayName: 'Publish PCF Core Artifact'
condition: and(succeeded(), eq(variables['info.shouldPublish'], 'true'))
- stage: Publish
displayName: Publish
condition: and(succeeded(), eq(dependencies.Build.outputs['BuildPCFPackages.linux.info.shouldPublish'], 'true'))
dependsOn: Build
jobs:
- template: templates/npmjs-publish-deployment.yaml@build-pipeline-scripts
parameters:
path: '*.tgz'
artifactName: core
name: core