-
Notifications
You must be signed in to change notification settings - Fork 3
/
azure-pipelines.yml
179 lines (162 loc) · 7.23 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
trigger:
- master
pr: none
variables:
azureSubscription: 'Sunshine Service Connection'
azureResourceNamePrefix: sunshine
buildConfiguration: 'Release'
azureResourceLocation: 'Australia East'
jobs:
- job: PrepareArtifactStorage
displayName: Setup Artifact Storage Azure Resources
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: AzureResourceGroupDeployment@2
displayName: 'Azure Deployment: Artifact Storage'
inputs:
azureSubscription: '$(azureSubscription)'
resourceGroupName: '$(azureResourceNamePrefix)-shared'
location: '$(azureResourceLocation)'
templateLocation: Linked artifact
csmFile: '$(Build.SourcesDirectory)/.build/artifact-storage.json'
overrideParameters: '-name $(azureResourceNamePrefix) -location "$(azureResourceLocation)"'
deploymentOutputs: ResourceGroupDeploymentOutputs
- task: PowerShell@2
displayName: Convert ARM output to environment variables
name: artifactVars
inputs:
targetType: filePath
filePath: '$(Build.SourcesDirectory)/.build/Set-ArtifactStorageResourceManagerOutput.ps1'
arguments: -ResourceManagerOutput '$(ResourceGroupDeploymentOutputs)'
- job: Build
pool:
vmImage: 'Ubuntu-16.04'
steps:
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
arguments: '--configuration $(BuildConfiguration)'
publishWebProjects: false
zipAfterPublish: false
displayName: dotnet publish
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.SourcesDirectory)/src/Sunshine.Downloader/bin/$(BuildConfiguration)/netcoreapp2.2/publish'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/Sunshine.Downloader-$(Build.BuildId).zip'
displayName: Archive Downloader
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.SourcesDirectory)/src/Sunshine.Functions/bin/$(BuildConfiguration)/netcoreapp2.1/publish'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/Sunshine.Functions-$(Build.BuildId).zip'
displayName: Archive Functions
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.SourcesDirectory)/src/Sunshine.MockApi/bin/$(BuildConfiguration)/netcoreapp2.2/publish'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/Sunshine.MockApi-$(Build.BuildId).zip'
displayName: Archive MockApi
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
continueOnError: true
inputs:
artifactName: Apps
- job: PublishReleaseScripts
displayName: Publish Release stage artifacts
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: CopyFiles@2
displayName: Copy Release Scripts
inputs:
contents: $(Build.SourcesDirectory)/.release/**
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
continueOnError: true
inputs:
artifactName: arm
- job: PrepareAzureACR
displayName: Prepare Azure ACR
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: AzureResourceGroupDeployment@2
displayName: 'Azure Deployment:Create ACR'
inputs:
azureSubscription: '$(azureSubscription)'
resourceGroupName: '$(azureResourceNamePrefix)-shared'
location: '$(azureResourceLocation)'
templateLocation: Linked artifact
csmFile: '$(Build.SourcesDirectory)/.build/acr.json'
overrideParameters: '-name $(azureResourceNamePrefix) -registrySku "Basic" -location "$(azureResourceLocation)"'
deploymentOutputs: ResourceGroupDeploymentOutputs
- task: PowerShell@2
displayName: Convert ARM output to environment variables
name: armVar
inputs:
targetType: filePath
filePath: '$(Build.SourcesDirectory)/.build/Set-BuildResourceManagerOutput.ps1'
arguments: -ResourceManagerOutput '$(ResourceGroupDeploymentOutputs)'
- template: .build/template.iot-edge.yml
parameters:
name: BuildImages_amd64
CONTAINER_REGISTRY_SERVER: $[dependencies.PrepareAzureACR.outputs['armVar.CONTAINER_REGISTRY_SERVER']]
SUBSCRIPTION_ID: $[dependencies.PrepareAzureACR.outputs['armVar.SUBSCRIPTION_ID']]
CONTAINER_REGISTRY_SERVER_NAME: $[dependencies.PrepareAzureACR.outputs['armVar.CONTAINER_REGISTRY_SERVER_NAME']]
ARTIFACT_STORAGE_NAME: $[dependencies.PrepareArtifactStorage.outputs['artifactVars.ARTIFACT_STORAGE_NAME']]
defaultPlatform: amd64
azureResourceNamePrefix: $(azureResourceNamePrefix)
azureSubscription: $(azureSubscription)
- template: .build/template.iot-edge.yml
parameters:
name: BuildImages_arm32v7
CONTAINER_REGISTRY_SERVER: $[dependencies.PrepareAzureACR.outputs['armVar.CONTAINER_REGISTRY_SERVER']]
SUBSCRIPTION_ID: $[dependencies.PrepareAzureACR.outputs['armVar.SUBSCRIPTION_ID']]
CONTAINER_REGISTRY_SERVER_NAME: $[dependencies.PrepareAzureACR.outputs['armVar.CONTAINER_REGISTRY_SERVER_NAME']]
ARTIFACT_STORAGE_NAME: $[dependencies.PrepareArtifactStorage.outputs['artifactVars.ARTIFACT_STORAGE_NAME']]
defaultPlatform: arm32v7
azureResourceNamePrefix: $(azureResourceNamePrefix)
azureSubscription: $(azureSubscription)
- template: .build/template.iot-edge.yml
parameters:
name: BuildImages_amd64_debug
CONTAINER_REGISTRY_SERVER: $[dependencies.PrepareAzureACR.outputs['armVar.CONTAINER_REGISTRY_SERVER']]
SUBSCRIPTION_ID: $[dependencies.PrepareAzureACR.outputs['armVar.SUBSCRIPTION_ID']]
CONTAINER_REGISTRY_SERVER_NAME: $[dependencies.PrepareAzureACR.outputs['armVar.CONTAINER_REGISTRY_SERVER_NAME']]
ARTIFACT_STORAGE_NAME: $[dependencies.PrepareArtifactStorage.outputs['artifactVars.ARTIFACT_STORAGE_NAME']]
defaultPlatform: amd64.debug
azureResourceNamePrefix: $(azureResourceNamePrefix)
azureSubscription: $(azureSubscription)
- job: PrepareAzureIoTEnvrionment
displayName: Prepare Azure IoT Environment
pool:
vmImage: 'Ubuntu-16.04'
variables:
resourceGroupName: sunshine-prod
steps:
- task: AzureResourceGroupDeployment@2
displayName: 'Azure Deployment:Create Or Update Resource Group action on sunshine-prod'
inputs:
azureSubscription: '$(azureSubscription)'
resourceGroupName: '$(azureResourceNamePrefix)-prod'
location: '$(azureResourceLocation)'
templateLocation: Linked artifact
csmFile: '$(System.DefaultWorkingDirectory)/.build/azure-environment.json'
overrideParameters: '-name $(azureResourceNamePrefix) -location "$(azureResourceLocation)"'
deploymentOutputs: ResourceGroupDeploymentOutputs
- task: PowerShell@2
displayName: Publish ARM outputs for asset
inputs:
targetType: filePath
filePath: '$(Build.SourcesDirectory)/.build/Set-ReleaseResourceManagerOutput.ps1'
arguments: -ResourceManagerOutput '$(ResourceGroupDeploymentOutputs)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
continueOnError: true
inputs:
artifactName: arm