forked from iTwin/itwins-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
97 lines (87 loc) · 3.22 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
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 install -g pnpm
displayName: install pnpm globally
- script: pnpm install
displayName: "Install dependencies"
- script: pnpm run build
displayName: "Build"
- script: pnpm run lint
displayName: "Lint"
- script: npm pack
displayName: "Pack"
# publish artifact
- bash: |
itwinsClientVersion=$(node -p "require('./package.json').version")
itwinsClientName=$(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 $itwinsClientVersion $itwinsClientName)
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=itwinsClientVersion;isOutput=true]$itwinsClientVersion"
echo "##vso[task.setvariable variable=itwinsClientName;isOutput=true]$itwinsClientName"
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-itwins-client-$(info.itwinsClientVersion).tgz"
artifactName: iTwinsClient
displayName: "Publish iTwins client"
condition: and(succeeded(), eq(variables['info.shouldPublish'], 'true'))
- 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: iTwinsClient
name: iTwinsClient