-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-test-deploy.yml
168 lines (148 loc) · 7.54 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
# 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\Grasshopper\Libraries\*.ghlink
displayName: 'Delete orphan .ghlink files'
- task: NuGetToolInstaller@1
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '7.x' # Specify the version you need, e.g., '7.0.100'
- task: NuGetCommand@2
displayName: 'Restoring NuGet packages'
inputs:
command: 'restore'
restoreSolution: 'AdSecGH.sln'
- task: VSBuild@1
displayName: 'Building project in $(configuration)'
inputs:
solution: 'AdSecGH.sln'
msbuildArgs: '/p:AppxBundlePlatforms="x64" /p:AppxPackageDir="$(build.artifactStagingDirectory)\AppxPackages" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload /m /nr:false'
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\adsecCore .\AdSecCoreTests\bin\Release\net7.0\AdSecCoreTests.dll
dotnet test --collect:"XPlat Code Coverage" /TestAdapterPath:$env:UserProfile\.nuget\packages\coverlet.collector\6.0.2\build --results-directory .\results\adsecgh .\AdSecGHTests\bin\x64\Release\net48\AdSecGHTests.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 tests
failOnStderr: false
- 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_adsecCore = (Resolve-Path $(System.DefaultWorkingDirectory)/results/adsecCore/*/coverage.cobertura.xml).Path
echo $coverage_file_adsecCore
$coverage_file_adsecgh = (Resolve-Path $(System.DefaultWorkingDirectory)/results/adsecgh/*/coverage.cobertura.xml).Path
echo $coverage_file_adsecgh
$coverage_file_integration = (Resolve-Path $(System.DefaultWorkingDirectory)/results/integration/*/coverage.cobertura.xml).Path
echo $coverage_file_integration
Copy-Item $coverage_file_adsecCore $(System.DefaultWorkingDirectory)\results\coverage_adsecCore.xml
Copy-Item $coverage_file_adsecgh $(System.DefaultWorkingDirectory)\results\coverage_adsecgh.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 -t $env:CODECOV_TOKEN --dir $(System.DefaultWorkingDirectory)\results --file coverage_adsecCore.xml -F adsecCore
.\codecov -t $env:CODECOV_TOKEN --dir $(System.DefaultWorkingDirectory)\results --file coverage_adsecgh.xml -F adsecgh
.\codecov -t $env:CODECOV_TOKEN --dir $(System.DefaultWorkingDirectory)\results --file coverage_integration.xml -F adsecgh_integration
env:
CODECOV_TOKEN: $(CODECOV_TOKEN)
displayName: Upload Code Coverage to codecovio
failOnStderr: true
- task: PowerShell@2
displayName: Check for existing tags
inputs:
targetType: 'inline'
script: |
$versionInfo = $(Get-Item .\AdSecGH\bin\x64\Release\net48\AdSecGH.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 + "-beta"
$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: |
cd AdSecGH\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: AdSecIcon.png'
Add-Content manifest.yml 'keywords:'
Add-Content manifest.yml '- oasys'
Add-Content manifest.yml '- adsec'
Add-Content manifest.yml '- adsecgh'
Add-Content manifest.yml '- section'
Add-Content manifest.yml '- concrete'
Add-Content manifest.yml '- composite'
Add-Content manifest.yml '- structural'
Add-Content manifest.yml '- concreteanalysis'
Add-Content manifest.yml '- structuraldesign'
..\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 AdSecGH
& 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\MSBuild.exe' AdSecGH.csproj /t:pack /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:DebugType=portable /property:Configuration=Debug
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/AdSec-Grasshopper'
action: 'edit'
target: '$(Build.SourceVersion)'
tag: '$(dotSeparatedTag)'
title: 'AdSecGH version $(dotSeparatedTag)'
releaseNotesSource: 'inline'
releaseNotesInline: |
Created from commit https://github.com/arup-group/AdSec-Grasshopper/commit/$(Build.SourceVersion)
assets: |
$(System.DefaultWorkingDirectory)/**/*.yak
$(System.DefaultWorkingDirectory)/**/*.nupkg
$(System.DefaultWorkingDirectory)/**/*.snupkg
assetUploadMode: 'replace'
isDraft: true
isPreRelease: true
addChangeLog: false
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), ne(variables.TAG_EXISTS, 'true'))
displayName: 'Publishing assets to Github'