-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathazure-pipelines.yml
106 lines (94 loc) · 3.29 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
trigger:
- main
pr:
drafts: false
branches:
include:
- main
resources:
repositories:
- repository: build-pipeline-scripts
type: git
ref: master
name: iModelTechnologies/imodeljs-build-pipeline-scripts
stages:
- stage: Build
displayName: Build
jobs:
- job: BuildPackages
strategy:
matrix:
linux:
imageName: 'ubuntu-latest'
mac:
imageName: 'macos-latest'
windows:
imageName: 'windows-latest'
pool:
vmImage: $(imageName)
steps:
- script: npm ci
displayName: 'Install dependencies'
- script: npm run build
displayName: 'Build'
- script: npm run lint
displayName: 'Lint'
- script: npm run test:unit
displayName: Run unit tests
- script: npm audit --registry=https://registry.npmjs.org --audit-level=high --omit=dev
displayName: 'Audit'
- script: npm pack
displayName: 'Pack'
# publish artifact
- bash: |
insightsClientVersion=$(node -p "require('./package.json').version")
insightsClientName=$(node -p "require('./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
}
updateClient=$(checkVer $insightsClientVersion $insightsClientName)
if [ "$updateClient" = "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=insightsClientVersion;isOutput=true]$insightsClientVersion"
echo "##vso[task.setvariable variable=insightsClientName;isOutput=true]$insightsClientName"
displayName: 'Store Build Info'
name: info
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Agent.OS'], 'Linux'))
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/itwin-insights-client-$(info.insightsClientVersion).tgz'
artifactName: InsightsClient
displayName: 'Publish Insights client'
condition: and(succeeded(), eq(variables['info.shouldPublish'], 'true'))
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/junit_results.xml'
displayName: "Publish test results"
- stage: Publish
displayName: Publish
condition: and(succeeded(), eq(dependencies.Build.outputs['BuildPackages.linux.info.shouldPublish'], 'true'))
dependsOn: Build
jobs:
- template: templates/npmjs-publish-deployment.yaml@build-pipeline-scripts
parameters:
path: '*.tgz'
artifactName: InsightsClient
name: InsightsClient