release.yml 3.97 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
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
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: |
liuzhe-lz's avatar
liuzhe-lz committed
55
      python -m pip install --upgrade pip setuptools wheel twine
56
      python test/vso_tools/build_wheel.py $(NNI_RELEASE)
liuzhe-lz's avatar
liuzhe-lz committed
57
    displayName: Build wheel
58

liuzhe-lz's avatar
liuzhe-lz committed
59
60
  - script: |
      if [ $(build_type) = 'release' ]; then
61
62
63
64
65
66
        echo 'uploading release package to pypi...'
        python -m twine upload -u nni -p $(pypi_password) dist/*
      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
liuzhe-lz's avatar
liuzhe-lz committed
67
    displayName: Upload wheel
68
69

  - script: |
liuzhe-lz's avatar
liuzhe-lz committed
70
      if [ $(build_type) = 'release' ]; then
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
        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: |
liuzhe-lz's avatar
liuzhe-lz committed
98
      python -m pip install --upgrade pip setuptools wheel twine
99
      python test/vso_tools/build_wheel.py $(NNI_RELEASE)
liuzhe-lz's avatar
liuzhe-lz committed
100
    displayName: Build wheel
101

liuzhe-lz's avatar
liuzhe-lz committed
102
103
  - script: |
      if [ $(build_type) = 'release' ]; then
104
105
106
107
108
109
        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
110
    displayName: Upload wheel
111
112
113
114
115
116
117
118
119
120
121
122
123
124

- 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
125
      python -m pip install --upgrade pip setuptools wheel twine
126
      python test/vso_tools/build_wheel.py $(NNI_RELEASE)
liuzhe-lz's avatar
liuzhe-lz committed
127
    displayName: Build wheel
128

liuzhe-lz's avatar
liuzhe-lz committed
129
  - powershell: |
130
131
132
133
134
135
136
137
      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/*
      }
liuzhe-lz's avatar
liuzhe-lz committed
138
    displayName: Upload wheel