release.yml 4.32 KB
Newer Older
1
2
3
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

liuzhe-lz's avatar
liuzhe-lz committed
4
5
6
trigger: none
pr: none

7
8
9
10
11
12
13
14
15
16
17
18
jobs:
- job: validate_version_number
  pool:
    vmImage: Ubuntu 18.04

  steps:
  - task: UsePythonVersion@0
    inputs:
      versionSpec: 3.8
    displayName: Configure Python version

  - script: |
19
20
      echo $(build_type)
      echo $(NNI_RELEASE)
21
22
      export BRANCH_TAG=`git describe --tags --abbrev=0`
      echo $BRANCH_TAG
liuzhe's avatar
liuzhe committed
23
      if [[ $BRANCH_TAG == v$(NNI_RELEASE) && $(NNI_RELEASE) =~ ^[0-9](.[0-9])+$ ]]; then
24
25
26
27
28
29
30
31
32
        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

  - script: |
33
      echo $(build_type)
34
      echo $(NNI_RELEASE)
35
      if [[ $(NNI_RELEASE) =~ ^[0-9](.[0-9])+(a|b|rc)[0-9]$ ]]; then
36
37
38
39
40
41
        echo 'Valid prerelease version $(NNI_RELEASE)'
        echo `git describe --tags --abbrev=0`
      else
        echo 'Invalid build version $(NNI_RELEASE)'
        exit 1
      fi
42
    condition: ne( variables['build_type'], 'release' )
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
    displayName: Validate prerelease version number

- job: linux
  dependsOn: validate_version_number
  condition: succeeded()
  pool:
    vmImage: Ubuntu 18.04

  steps:
  - task: UsePythonVersion@0
    inputs:
      versionSpec: 3.8
    displayName: Configure Python version

  - script: |
liuzhe-lz's avatar
liuzhe-lz committed
58
      python -m pip install --upgrade pip setuptools wheel twine
59
      python -m pip install -r dependencies/develop.txt
60
      python test/vso_tools/build_wheel.py $(NNI_RELEASE)
liuzhe-lz's avatar
liuzhe-lz committed
61
    displayName: Build wheel
62

liuzhe-lz's avatar
liuzhe-lz committed
63
  - script: |
64
65
      if [[ $(build_type) == 'release' || $(build_type) == 'rc' ]]; then
        echo 'uploading to pypi...'
66
67
        python -m twine upload -u nni -p $(pypi_password) dist/*
      else
68
        echo 'uploading to testpypi...'
69
70
        python -m twine upload -u nni -p $(pypi_password) --repository-url https://test.pypi.org/legacy/ dist/*
      fi
liuzhe-lz's avatar
liuzhe-lz committed
71
    displayName: Upload wheel
72
73

  - script: |
74
      if [[ $(build_type) == 'release' || $(build_type) == 'rc' ]]; then
75
76
77
78
79
80
81
82
83
        docker login -u msranni -p $(docker_hub_password)
        export IMAGE_NAME=msranni/nni
      else
        docker login -u nnidev -p $(docker_hub_password)
        export IMAGE_NAME=nnidev/nni-test
      fi

      echo "## Building ${IMAGE_NAME}:$(NNI_RELEASE) ##"
      docker build --build-arg NNI_RELEASE=$(NNI_RELEASE) -t ${IMAGE_NAME} .
liuzhe-lz's avatar
liuzhe-lz committed
84
85
      docker tag ${IMAGE_NAME} ${IMAGE_NAME}:v$(NNI_RELEASE)
      docker push ${IMAGE_NAME}:v$(NNI_RELEASE)
86
87
88
      if [[ $(build_type) != 'rc' ]]; then
        docker push ${IMAGE_NAME}
      fi
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
    displayName: Build and upload docker image

- job: macos
  dependsOn: validate_version_number
  condition: succeeded()
  pool:
    vmImage: macOS-10.15

  steps:
  - task: UsePythonVersion@0
    inputs:
      versionSpec: 3.8
    displayName: Configure Python version

  - script: |
liuzhe-lz's avatar
liuzhe-lz committed
104
      python -m pip install --upgrade pip setuptools wheel twine
QuanluZhang's avatar
QuanluZhang committed
105
      python -m pip install jupyter jupyterlab
106
      python test/vso_tools/build_wheel.py $(NNI_RELEASE)
liuzhe-lz's avatar
liuzhe-lz committed
107
    displayName: Build wheel
108

liuzhe-lz's avatar
liuzhe-lz committed
109
  - script: |
110
      if [[ $(build_type) == 'release' || $(build_type) == 'rc' ]]; then
111
112
113
114
115
116
        echo '## uploading to pypi ##'
        python -m twine upload -u nni -p $(pypi_password) dist/*
      else
        echo '## uploading to testpypi ##'
        python -m twine upload -u nni -p $(pypi_password) --repository-url https://test.pypi.org/legacy/ dist/*
      fi
liuzhe-lz's avatar
liuzhe-lz committed
117
    displayName: Upload wheel
118
119
120
121
122
123
124
125
126
127
128
129
130
131

- job: windows
  dependsOn: validate_version_number
  condition: succeeded()
  pool:
    vmImage: windows-2019

  steps:
  - task: UsePythonVersion@0
    inputs:
      versionSpec: 3.8
    displayName: Configure Python version

  - powershell: |
liuzhe-lz's avatar
liuzhe-lz committed
132
      python -m pip install --upgrade pip setuptools wheel twine
QuanluZhang's avatar
QuanluZhang committed
133
      python -m pip install jupyter jupyterlab
134
      python test/vso_tools/build_wheel.py $(NNI_RELEASE)
liuzhe-lz's avatar
liuzhe-lz committed
135
    displayName: Build wheel
136

liuzhe-lz's avatar
liuzhe-lz committed
137
  - powershell: |
138
      if ($env:BUILD_TYPE -eq 'release' -Or $env:BUILD_TYPE -eq 'rc') {
139
140
        Write-Host '## uploading to pypi ##'
        python -m twine upload -u nni -p $(pypi_password) dist/*
141
      } else {
142
143
144
        Write-Host '## uploading to testpypi ##'
        python -m twine upload -u nni -p $(pypi_password) --repository-url https://test.pypi.org/legacy/ dist/*
      }
liuzhe-lz's avatar
liuzhe-lz committed
145
    displayName: Upload wheel