deployment-pipelines.yml 7.81 KB
Newer Older
liuzhe-lz's avatar
liuzhe-lz committed
1
2
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
chicm-ms's avatar
chicm-ms committed
3
4

jobs:
chicm-ms's avatar
chicm-ms committed
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
- job: 'version_number_validation'
  pool:
    vmImage: 'Ubuntu 16.04'
  strategy:
    matrix:
      Python36:
        PYTHON_VERSION: '3.6'
  steps:
  - script: |
      echo $(build_version)
      if [[ $(build_version) =~ ^v[0-9](.[0-9]){1,3}$ ]]; then
        echo 'valid build version $(build_version)'
        echo `git describe --tags --abbrev=0`
      else
        echo 'invalid build version $(build_version)'
        exit 1
      fi
    condition: eq( variables['build_type'], 'prerelease' )
    displayName: 'Validate prerelease version number'

  - script: |
      export BRANCH_TAG=`git describe --tags --abbrev=0`
      echo $BRANCH_TAG
      if [[ $BRANCH_TAG = $(build_version) && $BRANCH_TAG =~ ^v[0-9](.[0-9]){1,3}$ ]]; then
        echo 'Build version match branch tag'
      else
        echo 'Build version does not match branch tag'
        exit 1
      fi
    condition: eq( variables['build_type'], 'release' )
    displayName: 'Validate release version number and branch tag'


chicm-ms's avatar
chicm-ms committed
38
- job: 'Build_upload_nni_ubuntu'
chicm-ms's avatar
chicm-ms committed
39
40
  dependsOn: version_number_validation
  condition: succeeded()
chicm-ms's avatar
chicm-ms committed
41
42
43
44
45
46
47
48
49
50
51
52
  pool:
    vmImage: 'Ubuntu 16.04'
  strategy:
    matrix:
      Python36:
        PYTHON_VERSION: '3.6'

  steps:
  - script: |
      python3 -m pip install --upgrade pip setuptools --user
      python3 -m pip install twine --user
    displayName: 'Install twine'
chicm-ms's avatar
chicm-ms committed
53

chicm-ms's avatar
chicm-ms committed
54
55
56
57
  - script: |
      cd deployment/pypi
      if [ $(build_type) = 'prerelease' ]
      then
chicm-ms's avatar
chicm-ms committed
58
59
        # NNI build scripts (Makefile) uses branch tag as package version number
        git tag $(build_version)
chicm-ms's avatar
chicm-ms committed
60
61
62
63
64
65
        echo 'building prerelease package...'
        make version_ts=true build
      else
        echo 'building release package...'
        make build
      fi
chicm-ms's avatar
chicm-ms committed
66
    condition: eq( variables['upload_package'], 'true')
chicm-ms's avatar
chicm-ms committed
67
    displayName: 'build nni bdsit_wheel'
chicm-ms's avatar
chicm-ms committed
68

chicm-ms's avatar
chicm-ms committed
69
70
71
72
73
74
75
76
77
78
  - script: |
      cd deployment/pypi
      if [ $(build_type) = 'prerelease' ]
      then
        echo 'uploading prerelease package to testpypi...'
        python3 -m twine upload -u $(testpypi_user) -p $(testpypi_pwd) --repository-url https://test.pypi.org/legacy/ dist/*
      else
        echo 'uploading release package to pypi...'
        python3 -m twine upload -u $(pypi_user) -p $(pypi_pwd) dist/*
      fi
chicm-ms's avatar
chicm-ms committed
79
    condition: eq( variables['upload_package'], 'true')
chicm-ms's avatar
chicm-ms committed
80
81
82
83
84
85
86
    displayName: 'upload nni package to pypi/testpypi'

  - script: |
      cd deployment/docker

      if [ $(build_type) = 'prerelease' ]
      then
chicm-ms's avatar
chicm-ms committed
87
88
        docker login -u $(docker_hub_dev_user) -p $(docker_hub_dev_pwd)
        export IMG_NAME=$(dev_docker_img)
chicm-ms's avatar
chicm-ms committed
89
        export IMG_TAG=`git describe --tags --abbrev=0`.`date -u +%y%m%d%H%M`
chicm-ms's avatar
chicm-ms committed
90
        echo 'updating docker file for testpyi...'
chicm-ms's avatar
chicm-ms committed
91
92
93
94
95
        sed -ie 's/RUN python3 -m pip --no-cache-dir install nni/RUN python3 -m pip install --user --no-cache-dir --index-url https:\/\/test.pypi.org\/simple --extra-index-url https:\/\/pypi.org\/simple nni/' Dockerfile
      else
        docker login -u $(docker_hub_user) -p $(docker_hub_pwd)
        export IMG_NAME=msranni/nni
        export IMG_TAG=`git describe --tags --abbrev=0`
chicm-ms's avatar
chicm-ms committed
96
      fi
chicm-ms's avatar
chicm-ms committed
97
98
99
100
101
102
103
104
105
106
107
      echo $IMG_NAME:$IMG_TAG
      cat Dockerfile
      docker build -f Dockerfile -t $IMG_NAME:$IMG_TAG .
      docker push $IMG_NAME:$IMG_TAG

      if [ $(update_latest_tag) = 'true' ]
      then
        docker tag $IMG_NAME:$IMG_TAG $IMG_NAME:latest
        docker push $IMG_NAME:latest
      fi

chicm-ms's avatar
chicm-ms committed
108
    condition: eq( variables['build_docker_img'], 'true')
chicm-ms's avatar
chicm-ms committed
109
110
111
    displayName: 'build and upload nni docker image'

- job: 'Build_upload_nni_macos'
chicm-ms's avatar
chicm-ms committed
112
113
  dependsOn: version_number_validation
  condition: succeeded()
chicm-ms's avatar
chicm-ms committed
114
115
116
117
118
119
120
121
122
123
124
  pool:
    vmImage: 'macOS 10.13'
  strategy:
    matrix:
      Python36:
        PYTHON_VERSION: '3.6'
  steps:
  - script: |
      python3 -m pip install --upgrade pip setuptools --user
      python3 -m pip install twine --user
    displayName: 'Install twine'
chicm-ms's avatar
chicm-ms committed
125

chicm-ms's avatar
chicm-ms committed
126
127
128
  - script: |
      make install-dependencies
    displayName: 'Install nni dependencies'
chicm-ms's avatar
chicm-ms committed
129

chicm-ms's avatar
chicm-ms committed
130
131
132
133
  - script: |
      cd deployment/pypi
      if [ $(build_type) = 'prerelease' ]
      then
chicm-ms's avatar
chicm-ms committed
134
135
        # NNI build scripts (Makefile) uses branch tag as package version number
        git tag $(build_version)
chicm-ms's avatar
chicm-ms committed
136
137
138
139
140
141
        echo 'building prerelease package...'
        PATH=$HOME/Library/Python/3.7/bin:$PATH make version_ts=true build
      else
        echo 'building release package...'
        PATH=$HOME/Library/Python/3.7/bin:$PATH make build
      fi
chicm-ms's avatar
chicm-ms committed
142
    condition: eq( variables['upload_package'], 'true')
chicm-ms's avatar
chicm-ms committed
143
    displayName: 'build nni bdsit_wheel'
chicm-ms's avatar
chicm-ms committed
144

chicm-ms's avatar
chicm-ms committed
145
146
147
148
149
150
151
152
153
154
  - script: |
      cd deployment/pypi
      if [ $(build_type) = 'prerelease' ]
      then
        echo 'uploading prerelease package to testpypi...'
        python3 -m twine upload -u $(testpypi_user) -p $(testpypi_pwd) --repository-url https://test.pypi.org/legacy/ dist/*
      else
        echo 'uploading release package to pypi...'
        python3 -m twine upload -u $(pypi_user) -p $(pypi_pwd) dist/*
      fi
chicm-ms's avatar
chicm-ms committed
155
    condition: eq( variables['upload_package'], 'true')
chicm-ms's avatar
chicm-ms committed
156
    displayName: 'upload nni package to pypi/testpypi'
157

158
- job: 'Build_upload_nni_win32'
159
160
161
162
163
164
165
166
167
  dependsOn: version_number_validation
  condition: succeeded()
  pool:
    vmImage: 'vs2017-win2016'
  strategy:
    matrix:
      Python36:
        PYTHON_VERSION: '3.6'
  steps:
168
169
170
  - powershell: |
      python -m pip install --upgrade pip setuptools
      python -m pip install twine
171
172
    displayName: 'Install twine'

173
174
175
  - powershell: |
      cd deployment\pypi
      if($env:BUILD_TYPE -eq 'prerelease'){
176
        # NNI build scripts (powershell) uses branch tag as package version number
177
178
179
180
181
182
183
184
        git tag $env:BUILD_VERSION
        Write-Host 'building prerelease package...'
        .\install.ps1 -version_os 32 -version_ts $True
      }
      else{
        Write-Host 'building release package...'
        .\install.ps1 -version_os 32 -version_ts $False
      }
185
186
187
    condition: eq( variables['upload_package'], 'true')
    displayName: 'build nni bdsit_wheel'

188
189
190
191
  - powershell: |
      cd deployment\pypi
      if($env:BUILD_TYPE -eq 'prerelease'){
        Write-Host 'uploading prerelease package to testpypi...'
192
        python -m twine upload -u $(testpypi_user) -p $(testpypi_pwd) --repository-url https://test.pypi.org/legacy/ dist/*
193
194
195
      }
      else{
        Write-Host 'uploading release package to pypi...'
196
        python -m twine upload -u $(pypi_user) -p $(pypi_pwd) dist/*
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
231
232
233
234
      }
    condition: eq( variables['upload_package'], 'true')
    displayName: 'upload nni package to pypi/testpypi'

- job: 'Build_upload_nni_win_amd64'
  dependsOn: version_number_validation
  condition: succeeded()
  pool:
    vmImage: 'vs2017-win2016'
  strategy:
    matrix:
      Python36:
        PYTHON_VERSION: '3.6'
  steps:
  - powershell: |
      python -m pip install --upgrade pip setuptools
      python -m pip install twine
    displayName: 'Install twine'

  - powershell: |
      cd deployment\pypi
      if($env:BUILD_TYPE -eq 'prerelease'){
        # NNI build scripts (powershell) uses branch tag as package version number
        git tag $env:BUILD_VERSION
        Write-Host 'building prerelease package...'
        .\install.ps1 -version_os 64 -version_ts $True
      }
      else{
        Write-Host 'building release package...'
        .\install.ps1 -version_os 64 -version_ts $False
      }
    condition: eq( variables['upload_package'], 'true')
    displayName: 'build nni bdsit_wheel'

  - powershell: |
      cd deployment\pypi
      if($env:BUILD_TYPE -eq 'prerelease'){
        Write-Host 'uploading prerelease package to testpypi...'
235
        python -m twine upload -u $(testpypi_user) -p $(testpypi_pwd) --repository-url https://test.pypi.org/legacy/ dist/*
236
237
238
      }
      else{
        Write-Host 'uploading release package to pypi...'
239
        python -m twine upload -u $(pypi_user) -p $(pypi_pwd) dist/*
240
      }
241
    condition: eq( variables['upload_package'], 'true')
242
    displayName: 'upload nni package to pypi/testpypi'