release.yml 3.84 KB
Newer Older
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

jobs:
- job: validate_version_number
  pool:
    vmImage: Ubuntu 18.04

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

  - script: |
      export BRANCH_TAG=`git describe --tags --abbrev=0`
      echo $BRANCH_TAG
      if [[ $BRANCH_TAG = v$(NNI_RELEASE) && $(NNI_RELEASE) =~ ^v[0-9](.[0-9])+$ ]]; 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

  - script: |
      echo $(NNI_RELEASE)
      if [[ $(NNI_RELEASE) =~ ^[0-9](.[0-9])+a[0-9]$ ]]; then
        echo 'Valid prerelease version $(NNI_RELEASE)'
        echo `git describe --tags --abbrev=0`
      else
        echo 'Invalid build version $(NNI_RELEASE)'
        exit 1
      fi
    condition: ne( variables['build_type'], 'rerelease' )
    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: |
      python -m pip install --upgrade pip setuptools twine
      python test/vso_tools/build_wheel.py $(NNI_RELEASE)

      if [ $(build_type) = 'release' ]
        echo 'uploading release package to pypi...'
        python -m twine upload -u nni -p $(pypi_password) dist/*
      then
      else
        echo 'uploading prerelease package to testpypi...'
        python -m twine upload -u nni -p $(pypi_password) --repository-url https://test.pypi.org/legacy/ dist/*
      fi
    displayName: Build and upload wheel

  - script: |
      if [ $(build_type) = 'release' ]
      then
        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} .
      docker tag ${IMAGE_NAME} ${IMAGE_NAME}:$(NNI_RELEASE)
      docker push ${IMAGE_NAME}
      docker push ${IMAGE_NAME}:$(NNI_RELEASE)
    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: |
      python -m pip install --upgrade pip setuptools twine
      python test/vso_tools/build_wheel.py $(NNI_RELEASE)

      if [ $(build_type) = 'release' ]
        echo '## uploading to pypi ##'
        python -m twine upload -u nni -p $(pypi_password) dist/*
      then
      else
        echo '## uploading to testpypi ##'
        python -m twine upload -u nni -p $(pypi_password) --repository-url https://test.pypi.org/legacy/ dist/*
      fi
    displayName: Build and upload wheel

- 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: |
      python -m pip install --upgrade pip setuptools twine
      python test/vso_tools/build_wheel.py $(NNI_RELEASE)

      if($env:BUILD_TYPE -eq 'release'){
        Write-Host '## uploading to pypi ##'
        python -m twine upload -u nni -p $(pypi_password) dist/*
      }
      else{
        Write-Host '## uploading to testpypi ##'
        python -m twine upload -u nni -p $(pypi_password) --repository-url https://test.pypi.org/legacy/ dist/*
      }
    displayName: Build and upload wheel