-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-test-deploy.yml
232 lines (205 loc) · 10.7 KB
/
build-test-deploy.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# https://aka.ms/yaml
trigger:
- main
variables:
- group: s3PushInstallers
- group: pipeline-tokens
- name: configuration
value: Release
pool: 'rhino-compute'
steps:
- powershell: Remove-Item -Path 'C:\Users\**\AppData\Roaming\McNeel\Rhinoceros\packages' -Recurse
displayName: 'Delete Rhino plugins'
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
displayName: 'Restoring NuGet packages'
inputs:
command: 'restore'
restoreSolution: 'OasysGH.sln'
- template: install-azure-sign-tool.yml
- powershell: |
AzureSignTool sign `
--description-url "https://oasys-software.com" `
--azure-key-vault-url "https://oasysevkv.vault.azure.net/" `
--azure-key-vault-tenant-id "4ae48b41-0137-4599-8661-fc641fe77bea" `
--azure-key-vault-client-id "$(AZURE_CLIENT_ID)" `
--azure-key-vault-client-secret "$(AZURE_CLIENT_SECRET)" `
--azure-key-vault-certificate "OasysCodeSigning" `
--timestamp-rfc3161 "http://timestamp.digicert.com" `
--verbose `
$(Build.SourcesDirectory).\lib\Oasys.Taxonomy.Geometry.dll `
$(Build.SourcesDirectory).\lib\Oasys.Taxonomy.IGeometry.dll `
$(Build.SourcesDirectory).\lib\Oasys.Taxonomy.Profiles.dll `
$(Build.SourcesDirectory).\lib\Oasys.Taxonomy.IProfiles.dll
displayName: Sign taxonomy lib files
env:
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID)
AZURE_CLIENT_SECRET : $(AZURE_CLIENT_SECRET)
- task: VSBuild@1
displayName: 'Building project in $(configuration)'
inputs:
solution: 'OasysGH.sln'
msbuildArgs: '/p:AppxBundlePlatforms="x64" /p:AppxPackageDir="$(build.artifactStagingDirectory)\AppxPackages" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload /m /nr:false /p:TreatWarningsAsErrors="true"'
platform: 'x64'
configuration: '$(configuration)'
clean: true
env:
MSBUILDDISABLENODEREUSE: 1
- powershell: |
dotnet test --collect:"XPlat Code Coverage" /TestAdapterPath:$env:UserProfile\.nuget\packages\coverlet.collector\6.0.2\build --results-directory .\results\oasysgh .\OasysGHTests\bin\x64\Release\net48\OasysGHTests.dll
dotnet test --collect:"XPlat Code Coverage" /TestAdapterPath:$env:UserProfile\.nuget\packages\coverlet.collector\6.0.2\build --results-directory .\results\unitnumber .\GH_UnitNumberTests\bin\x64\Release\net48\GH_UnitNumberTests.dll
dotnet test --collect:"XPlat Code Coverage" /TestAdapterPath:$env:UserProfile\.nuget\packages\coverlet.collector\6.0.2\build --results-directory .\results\integration .\IntegrationTests\bin\x64\Release\net48\IntegrationTests.dll
displayName: dotnet test
failOnStderr: true
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/results/unitnumber/**/coverage.cobertura.xml'
pathToSources: '$(System.DefaultWorkingDirectory)'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
displayName: Create Azure UnitNumber CodeCoverage
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/results/oasysgh/**/coverage.cobertura.xml'
pathToSources: '$(System.DefaultWorkingDirectory)'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
displayName: Create Azure OasysGH CodeCoverage
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/results/integration/**/coverage.cobertura.xml'
pathToSources: '$(System.DefaultWorkingDirectory)'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
displayName: Create Azure IntegrationTests CodeCoverage
- powershell: |
if (200 -ne (Invoke-WebRequest -Uri https://codecov.io/validate -Body (Get-Content -Raw -LiteralPath .\codecov.yml) -Method post | Select-Object StatusCode).StatusCode) {
Write-Output "codecov.yml is invalid"
Invoke-WebRequest -Uri https://codecov.io/validate -Body (Get-Content -Raw -LiteralPath .\codecov.yml) -Method post
exit(1)
} else {
Write-Output "codecov.yml is valid"
}
displayName: Validate codecov.yml
failOnStderr: true
- powershell: |
$coverage_file_unitnumber = (Resolve-Path $(System.DefaultWorkingDirectory)/results/unitnumber/*/coverage.cobertura.xml).Path
echo $coverage_file_unitnumber
$coverage_file_oasysgh = (Resolve-Path $(System.DefaultWorkingDirectory)/results/oasysgh/*/coverage.cobertura.xml).Path
echo $coverage_file_oasysgh
$coverage_file_integration = (Resolve-Path $(System.DefaultWorkingDirectory)/results/integration/*/coverage.cobertura.xml).Path
echo $coverage_file_integration
Copy-Item $coverage_file_unitnumber $(System.DefaultWorkingDirectory)\results\coverage_unitnumber.xml
Copy-Item $coverage_file_oasysgh $(System.DefaultWorkingDirectory)\results\coverage_oasysgh.xml
Copy-Item $coverage_file_integration $(System.DefaultWorkingDirectory)\results\coverage_integration.xml
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
ls $(System.DefaultWorkingDirectory)\
cd $(System.DefaultWorkingDirectory)\
.\codecov.exe -t $env:CODECOV_TOKEN --dir $(System.DefaultWorkingDirectory)\results --file coverage_unitnumber.xml -F unitnumber
.\codecov.exe -t $env:CODECOV_TOKEN --dir $(System.DefaultWorkingDirectory)\results --file coverage_oasysgh.xml -F oasysgh
.\codecov.exe -t $env:CODECOV_TOKEN --dir $(System.DefaultWorkingDirectory)\results --file coverage_integration.xml -F integration
env:
CODECOV_TOKEN: $(CODECOV_TOKEN)
displayName: Upload Code Coverage to codecovio
failOnStderr: true
- publish: $(System.DefaultWorkingDirectory)\results\coverage_unitnumber.xml
displayName: Publish UnitNumberTests xml to Azure
artifact: UnitNumberTestsCoverage
continueOnError: true
- publish: $(System.DefaultWorkingDirectory)\results\coverage_oasysgh.xml
displayName: Publish OasysGHTests xml to Azure
artifact: OasysGHTestsCoverage
continueOnError: true
- publish: $(System.DefaultWorkingDirectory)\results\coverage_integration.xml
displayName: Publish IntegrationTests xml to Azure
artifact: IntegrationTestsCoverage
continueOnError: true
- task: PowerShell@2
displayName: Check for existing tags
inputs:
targetType: 'inline'
script: |
$versionInfo = $(Get-Item .\OasysGH\bin\x64\Release\net48\OasysGH.dll).VersionInfo
echo $versionInfo
$fullVersion = [array]${versionInfo}.FileVersion.split('.')
$currentTime = $(Get-Date -Format "dddd MM/dd/yyyy HH:mm")
$majorVersion = [string]$fullVersion[0]
$minorVersion = [string]$fullVersion[1]
$spVersion = [string]$fullVersion[2]
$buildNumber = [string]$fullVersion[3]
$tag = [array]@($exeName,$majorVersion,$minorVersion,$spVersion,$buildNumber)
$tagNumbersOnly = [array]@($majorVersion,$minorVersion,$spVersion,$buildNumber)
$dotSeparatedTag = $majorVersion + "." + $minorVersion + "." + $spVersion
$underscoreSeparatedTag = $majorVersion + "_" + $minorVersion + "_" + $spVersion + "_" + $buildNumber
$tagNumbersOnlyUnderscore = $majorVersion + "_" + $minorVersion + "_" + $spVersion + "_" + $buildNumber
$tagNumbersOnlydot = $majorVersion + "." + $minorVersion + "." + $spVersion + "." + $buildNumber
Write-Host ("##vso[task.setvariable variable=dotSeparatedTag]$dotSeparatedTag")
git rev-parse $dotSeparatedTag
if($lastExitCode -eq 0){Write-Host ("##vso[task.setvariable variable=TAG_EXISTS]true")}
if($lastExitCode -eq 0){
$tagExists = 'true'
echo $tagExists
}
errorActionPreference: 'continue'
workingDirectory: '$(System.DefaultWorkingDirectory)'
ignoreLASTEXITCODE: true
- powershell: |
AzureSignTool sign `
--description-url "https://oasys-software.com" `
--azure-key-vault-url "https://oasysevkv.vault.azure.net/" `
--azure-key-vault-tenant-id "4ae48b41-0137-4599-8661-fc641fe77bea" `
--azure-key-vault-client-id "$(AZURE_CLIENT_ID)" `
--azure-key-vault-client-secret "$(AZURE_CLIENT_SECRET)" `
--azure-key-vault-certificate "OasysCodeSigning" `
--timestamp-rfc3161 "http://timestamp.digicert.com" `
--verbose `
$(Build.SourcesDirectory).\OasysGH\bin\x64\Release\net48\OasysGH.dll `
$(Build.SourcesDirectory).\GH_UnitNumber\bin\x64\Release\net48\GH_UnitNumber.dll
displayName: Sign GH output file before adding to Nuget installer
env:
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID)
AZURE_CLIENT_SECRET : $(AZURE_CLIENT_SECRET)
- powershell: |
cd GH_UnitNumber\bin\x64\Release
curl https://files.mcneel.com/yak/tools/latest/yak.exe -o yak.exe
.\yak version
cd net48
..\yak spec
Add-Content manifest.yml 'icon: UnitNumberIcon.png'
..\yak build --platform win
$yakCurrentVersName = Get-ChildItem -Path . -Filter "*.yak"
$yakRh7Name = $yakCurrentVersName -Replace "rh6_27", "rh7_0"
Rename-Item -Path $yakCurrentVersName -NewName $yakRh7Name
..\yak build --platform win
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), ne(variables.TAG_EXISTS, 'true'))
displayName: Package yak
- powershell: |
cd OasysGH
& 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\MSBuild.exe' OasysGH.csproj /t:pack /p:NoBuild=true /p:Platform=x64 /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:DebugType=portable /property:Configuration=Release
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), ne(variables.TAG_EXISTS, 'true'))
displayName: Package NuGet
- task: GitHubRelease@1
inputs:
gitHubConnection: 'github.com_MJCramp'
repositoryName: 'arup-group/OasysGH'
action: 'edit'
target: '$(Build.SourceVersion)'
tag: '$(dotSeparatedTag)'
title: 'OasysGH version $(dotSeparatedTag)'
releaseNotesSource: 'inline'
releaseNotesInline: |
Created from commit https://github.com/arup-group/OasysGH/commit/$(Build.SourceVersion)
assets: |
$(System.DefaultWorkingDirectory)/**/*.yak
$(System.DefaultWorkingDirectory)/**/*.nupkg
$(System.DefaultWorkingDirectory)/**/*.snupkg
assetUploadMode: 'replace'
isDraft: true
isPreRelease: false
addChangeLog: false
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), ne(variables.TAG_EXISTS, 'true'))
displayName: 'Publishing assets to Github'
- powershell: Remove-Item -Path C:\Users\**\AppData\Roaming\Grasshopper\Libraries\*.ghlink
displayName: 'Delete orphan .ghlink files'
condition: always()