deployment-pipelines.yml 6.03 KB
Newer Older
chicm-ms's avatar
chicm-ms committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Copyright (c) Microsoft Corporation
# All rights reserved.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
chicm-ms's avatar
chicm-ms committed
20
21

jobs:
chicm-ms's avatar
chicm-ms committed
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
- 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
55
- job: 'Build_upload_nni_ubuntu'
chicm-ms's avatar
chicm-ms committed
56
57
  dependsOn: version_number_validation
  condition: succeeded()
chicm-ms's avatar
chicm-ms committed
58
59
60
61
62
63
64
65
66
67
68
69
  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
70

chicm-ms's avatar
chicm-ms committed
71
72
73
74
  - script: |
      cd deployment/pypi
      if [ $(build_type) = 'prerelease' ]
      then
chicm-ms's avatar
chicm-ms committed
75
76
        # NNI build scripts (Makefile) uses branch tag as package version number
        git tag $(build_version)
chicm-ms's avatar
chicm-ms committed
77
78
79
80
81
82
        echo 'building prerelease package...'
        make version_ts=true build
      else
        echo 'building release package...'
        make build
      fi
chicm-ms's avatar
chicm-ms committed
83
    condition: eq( variables['upload_package'], 'true')
chicm-ms's avatar
chicm-ms committed
84
    displayName: 'build nni bdsit_wheel'
chicm-ms's avatar
chicm-ms committed
85

chicm-ms's avatar
chicm-ms committed
86
87
88
89
90
91
92
93
94
95
  - 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
96
    condition: eq( variables['upload_package'], 'true')
chicm-ms's avatar
chicm-ms committed
97
98
99
100
101
102
103
    displayName: 'upload nni package to pypi/testpypi'

  - script: |
      cd deployment/docker

      if [ $(build_type) = 'prerelease' ]
      then
chicm-ms's avatar
chicm-ms committed
104
105
        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
106
        export IMG_TAG=`git describe --tags --abbrev=0`.`date -u +%y%m%d%H%M`
chicm-ms's avatar
chicm-ms committed
107
        echo 'updating docker file for testpyi...'
chicm-ms's avatar
chicm-ms committed
108
109
110
111
112
        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
113
      fi
chicm-ms's avatar
chicm-ms committed
114
115
116
117
118
119
120
121
122
123
124
      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
125
    condition: eq( variables['build_docker_img'], 'true')
chicm-ms's avatar
chicm-ms committed
126
127
128
    displayName: 'build and upload nni docker image'

- job: 'Build_upload_nni_macos'
chicm-ms's avatar
chicm-ms committed
129
130
  dependsOn: version_number_validation
  condition: succeeded()
chicm-ms's avatar
chicm-ms committed
131
132
133
134
135
136
137
138
139
140
141
  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
142

chicm-ms's avatar
chicm-ms committed
143
144
145
  - script: |
      make install-dependencies
    displayName: 'Install nni dependencies'
chicm-ms's avatar
chicm-ms committed
146

chicm-ms's avatar
chicm-ms committed
147
148
149
150
  - script: |
      cd deployment/pypi
      if [ $(build_type) = 'prerelease' ]
      then
chicm-ms's avatar
chicm-ms committed
151
152
        # NNI build scripts (Makefile) uses branch tag as package version number
        git tag $(build_version)
chicm-ms's avatar
chicm-ms committed
153
154
155
156
157
158
        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
159
    condition: eq( variables['upload_package'], 'true')
chicm-ms's avatar
chicm-ms committed
160
    displayName: 'build nni bdsit_wheel'
chicm-ms's avatar
chicm-ms committed
161

chicm-ms's avatar
chicm-ms committed
162
163
164
165
166
167
168
169
170
171
  - 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
172
    condition: eq( variables['upload_package'], 'true')
chicm-ms's avatar
chicm-ms committed
173
    displayName: 'upload nni package to pypi/testpypi'