-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-pipelines.yml
118 lines (100 loc) · 4.15 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
pool:
vmImage: 'windows-2022'
name: $(SourceBranchName)+1.$(Date:yy.MMdd)$(Rev:r)
steps:
- script: echo Starting build pipeline!
displayName: 'Hello from Albanian Xrm'
- powershell: |
echo "##vso[task.setvariable variable=configuration;isOutput=true]$(IF($env:BRANCH -eq "refs/heads/master"){"Azure Pipelines"}else{"release"})"
echo "##vso[task.setvariable variable=BuildNumber;isOutput=true]$(($env:BuildNumber).Substring(($env:BuildNumber).LastIndexOf('+')+1))"
name: MyVars
env:
BRANCH: $(Build.SourceBranch)
BuildNumber: $(Build.BuildNumber)
displayName: 'Set Configuration Variable'
- task: DownloadSecureFile@1
name: SignKey
inputs:
secureFile: 'AlbanianXrm.snk'
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Signing Secret'
- task: DownloadSecureFile@1
name: InternalsVisibleTo
inputs:
secureFile: 'InternalsVisibleTo.cs'
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'InternalsVisibleTo Secret'
- powershell: echo "##vso[task.setvariable variable=Path;isOutput=true]$((get-item $env:SECURE_FILE).Directory.FullName)"
name: secretFolder
env:
Secure_File: $(SignKey.secureFilePath)
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Secret folder'
- task: CopyFiles@2
inputs:
sourceFolder: $(secretFolder.Path)
contents: AlbanianXrm.snk
targetFolder: 'PowerPlatform.EntitySerializer'
overWrite: true
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Overwrite AlbanianXrm.PowerPlatform.EntitySerializer SignKey'
- task: CopyFiles@2
inputs:
sourceFolder: $(secretFolder.Path)
contents: InternalsVisibleTo.cs
targetFolder: 'PowerPlatform.EntitySerializer'
overWrite: true
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Overwrite AlbanianXrm.PowerPlatform.EntitySerializer InternalsVisibleTo'
- task: CopyFiles@2
inputs:
sourceFolder: $(secretFolder.Path)
contents: AlbanianXrm.snk
targetFolder: 'PowerPlatform.EntitySerializer.Tests'
overWrite: true
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Overwrite AlbanianXrm.PowerPlatform.EntitySerializer.Tests SignKey'
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
projects: '$(Parameters.solution)'
- task: DotNetCoreCLI@2
inputs:
command: 'build'
arguments: '--configuration $(BuildConfiguration) -p:Version=$(MyVars.BuildNumber)'
displayName: 'dotnet build $(BuildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'dotnet test'
inputs:
command: test
projects: '**/*Tests/*.csproj'
arguments: '--configuration $(BuildConfiguration) --collect "XPlat Code coverage" '
- script: 'dotnet tool install --global dotnet-reportgenerator-globaltool --version 5.1.26'
displayName: 'Install ReportGenerator tool'
- script: 'reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/coverlet/reports -reporttypes:"Cobertura"'
displayName: 'Create reports'
- task: PublishCodeCoverageResults@2
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/coverlet/reports/Cobertura.xml'
- task: NuGetCommand@2
inputs:
command: pack
packagesToPack: PowerPlatform.EntitySerializer.Sources\PowerPlatform.EntitySerializer.Sources.nuspec
versioningScheme: byEnvVar
versionEnvVar: MyVars.BuildNumber
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
- task: CopyFiles@2
displayName: 'Preparing NuGet packages'
inputs:
Contents: '**\AlbanianXrm.PowerPlatform.EntitySerializer*nupkg'
TargetFolder: '$(Build.ArtifactStagingDirectory)\NuGets'
flattenFolders: true
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)\NuGets'
ArtifactName: 'NuGets'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))