-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
azure-pipelines.yml
118 lines (100 loc) · 3.64 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
# OpenUPM azure pipelines
name: $(Build.BuildId)
trigger: none
variables:
### context variables
# repoUrl: https://github.com/owner/reponame
# repoBranch: master
# packageName: com.namespace.pkgname
# packageVersion: semver
### pre-defined variables
repoDir: repo
registryUrl: https://package.openupm.com
distTag: latest
### dynamic variables
# distTag: latest
# packageFolder: path-to-package.json
pool:
vmImage: "ubuntu-latest"
steps:
- script: |
echo repoUrl: $REPOURL
echo repoBranch: $REPOBRANCH
echo packageName: $PACKAGENAME
echo packageVersion: $PACKAGEVERSION
[[ -z "$REPOURL" ]] && echo 'variable repoUrl not found' && exit 1
[[ -z "$REPOBRANCH" ]] && echo 'variable repoBranch not found' && exit 1
[[ -z "$PACKAGENAME" ]] && echo 'variable packageName not found' && exit 1
[[ -z "$PACKAGEVERSION" ]] && echo 'variable packageVersion not found' && exit 1
echo "##vso[task.setvariable variable=NODE_OPTIONS]--max_old_space_size=2048"
exit 0
displayName: "Prepare context variables"
- script: |
echo "##vso[build.updatebuildnumber]$(packageName)-$(packageVersion)-$(Build.BuildId)"
displayName: "Update build number"
- task: NodeTool@0
inputs:
versionSpec: "18.x"
displayName: "Install Node.js"
- task: Npm@1
inputs:
command: custom
customCommand: "install -g [email protected]"
displayName: "Upgrade npm to v10.4.0"
- task: Npm@1
inputs:
command: custom
customCommand: "install -g husky"
displayName: "Install husky globally"
- task: Npm@1
inputs:
command: install
displayName: "Install dependencies"
- task: DeleteFiles@1
inputs:
contents: $(repoDir)
displayName: "Clean $(repoDir) folder"
- script: |
git config --global url."https://github.com/".insteadOf [email protected]:
git config --global url."https://".insteadOf git://
displayName: Git config
- script: GIT_CLONE_PROTECTION_ACTIVE=false git clone --recursive --shallow-submodules --depth 1 --branch $(repoBranch) $(repoUrl) $(repoDir)
displayName: "Clone to $(repoDir) repository"
- script: |
# Get LATEST_VERSION
LATEST_VERSION=`npm --registry=$(registryUrl) show $(packageName) version` || LATEST_VERSION=0.0.0
[[ -z "$LATEST_VERSION" ]] && LATEST_VERSION=0.0.0
echo LATEST_VERSION: $LATEST_VERSION
echo packageVersion: $(packageVersion)
# Get DIST_TAG
DIST_TAG=`node getDistTag.js $(packageVersion) $LATEST_VERSION`
echo DIST_TAG: $DIST_TAG
echo "##vso[task.setvariable variable=distTag;]$DIST_TAG"
displayName: "Set distTag variable"
- script: |
npm install -g json
echo Locate package.json for: $(packageName)
node findPackage.js $(packageName) $(repoDir) result.json
if [[ ! -f "result.json" ]]; then
echo "Error: ENOENT, error path package.json with name=$(packageName)"
exit 1
fi
PACKAGEFOLDER=$(cat result.json | json 'dirname')
echo "PACKAGEFOLDER: $PACKAGEFOLDER"
echo "##vso[task.setvariable variable=packageFolder;]$PACKAGEFOLDER"
displayName: "Detect package.json location"
- script: |
cd "$(packageFolder)"
if [ -f "package.json" ]; then
npm install -g json
json -I -f package.json -e 'this.publishConfig = { registry: "https://package.openupm.com" }'
cat package.json
fi
displayName: "Override publishConfig"
- task: Npm@1
inputs:
command: custom
customCommand: "publish --tag=$(distTag) --registry=$(registryUrl)"
customEndpoint: openupm
workingDir: $(packageFolder)
displayName: "Publish to OpenUPM"