-
Notifications
You must be signed in to change notification settings - Fork 70
/
azure-pipelines.yml
144 lines (127 loc) · 4.49 KB
/
azure-pipelines.yml
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
133
134
135
136
137
138
139
140
141
142
143
144
trigger:
branches:
include:
- refs/tags/v*
pool:
name: Azure-IoT-EdgeExperience-1ES-Hosted-Linux
demands:
- ImageOverride -equals MMSUbuntu18.04TLS
steps:
- task: UsePythonVersion@0
displayName: "Install Python"
inputs:
versionSpec: '3.7'
addToPath: true
architecture: 'x64'
- task: Bash@3
displayName: "Install Python packages"
inputs:
targetType: 'inline'
script: |
pip install tox
pip install twine
sudo apt-get install gcc libpq-dev -y
sudo apt-get install python-dev python-pip -y
sudo apt-get install python3-dev python3-pip python3-venv python3-wheel -y
pip3 install wheel
- task: Bash@3
displayName: "Update AIKey"
inputs:
targetType: 'inline'
script: 'sed -i "/__AIkey__/c __AIkey__ = ''$(AIKEY)''" ./iotedgedev/__init__.py'
- task: Bash@3
inputs:
targetType: 'inline'
script: |
if [[ $(Build.SourceBranch) =~ ^refs/tags/v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "##vso[task.setvariable variable=WHEEL_PUBLISH_FLAG;]true"
fi
VERSION=$(cat ./iotedgedev/__init__.py | grep '__version__' | grep -oP "'\K[^']+")
echo "##vso[task.setvariable variable=VERSION;]$VERSION"
- task: Bash@3
displayName: "Build wheel"
inputs:
targetType: 'inline'
script: |
python setup.py bdist_wheel
pip install dist/iotedgedev-${VERSION}-py3-none-any.whl && iotedgedev --version
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.SourcesDirectory)'
archiveFile: '$(Build.ArtifactStagingDirectory)/iotedgedev-$(VERSION)-win32-ia32.zip'
- task: Bash@3
displayName: "Revert AIKey to Original"
inputs:
targetType: 'inline'
script: 'sed -i "/__AIkey__/c __AIkey__ = ''$(TEST_AIKEY)''" ./iotedgedev/__init__.py'
- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
displayName: 'SBOM Generation Task'
inputs:
BuildDropPath: '$(Build.SourcesDirectory)/dist'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/dist'
ArtifactName: 'drop'
publishLocation: 'Container'
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.SourcesDirectory)/dist/'
Contents: '*'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: Bash@3
displayName: 'Upload to Blob'
condition: and(succeeded(), eq(variables['WHEEL_PUBLISH_FLAG'], 'true'))
inputs:
targetType: 'inline'
script: |
export AZCOPY_SPA_CLIENT_SECRET=$(AZURESDKPARTNERDROPS-SERVICE-PRINCIPAL-KEY)
azcopy login --service-principal --application-id $(APPID)
azcopy copy "$(Build.ArtifactStagingDirectory)/*" "https://azuresdkpartnerdrops.blob.core.windows.net/drops/azure-iot-edge-tools-iotedgedev/python/$(VERSION)/"
- task: GitHubRelease@0
condition: and(succeeded(), eq(variables['WHEEL_PUBLISH_FLAG'], 'true'))
inputs:
gitHubConnection: 'github.com_marianan'
repositoryName: '$(Build.Repository.Name)'
action: 'create'
target: '$(Build.SourceVersion)'
tagSource: 'manual'
tag: '$(Build.SourceBranch)'
releaseNotesSource: 'input'
isPreRelease: true
addChangeLog: false
- task: Bash@3
displayName: "Build Docker image"
inputs:
targetType: 'inline'
script: './build-docker.sh iotedgedevtoolscontainerregistry.azurecr.io/public/iotedge/iotedgedev linux'
workingDirectory: 'docker/tool'
- task: Bash@3
displayName: "Test local Docker image"
inputs:
targetType: 'inline'
script: |
PACKAGEVERSION=$(cat ../../iotedgedev/__init__.py | grep '__version__' | grep -oP "'\K[^']+")
echo "##vso[task.setvariable variable=VERSION]$PACKAGEVERSION"
mkdir /home/vsts/iotedge
docker run -v /var/run/docker.sock:/var/run/docker.sock -v /home/vsts/iotedge:/home/iotedge iotedgedevtoolscontainerregistry.azurecr.io/public/iotedge/iotedgedev:${PACKAGEVERSION}
workingDirectory: 'docker/tool'
- task: Docker@2
condition: and(succeeded(), eq(variables['WHEEL_PUBLISH_FLAG'], 'true'))
displayName: "Push docker image to acr"
inputs:
containerRegistry: 'IoTEdgeDev-Docker'
repository: 'public/iotedge/iotedgedev'
command: 'push'
tags: |
$(VERSION)
latest
- task: Bash@3
condition: and(succeeded(), eq(variables['WHEEL_PUBLISH_FLAG'], 'true'))
displayName: "Test last uploaded Docker image"
inputs:
targetType: 'inline'
script: |
docker pull mcr.microsoft.com/iotedge/iotedgedev
docker run mcr.microsoft.com/iotedge/iotedgedev
iotedgedev --version
workingDirectory: 'docker/tool'