-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
103 lines (93 loc) · 3.71 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
variables:
CurrentSemanticVersionBase: '1.0.0'
PreviewNumber: $[counter(variables['CurrentSemanticVersionBase'], 1001)]
CurrentSemanticVersion: '$(CurrentSemanticVersionBase)-preview$(PreviewNumber)'
NugetPackageVersion: '$(CurrentSemanticVersion)'
RESOLVED_NET_VERSION: '7.0.200'
LATEST_NET_VERSION: '7.0.x'
PathToControlsCsproj: 'src/Resolved.It.Maui.Controls/Resolved.It.Maui.Controls.csproj'
PathToCoreCsproj: 'src/Resolved.It.Maui.Core/Resolved.It.Maui.Core.csproj'
trigger:
branches:
include:
- main
tags:
include:
- '*'
paths:
exclude:
- README.md
- azure-pipelines.yml
- art/*
- build/*
- .idea/*
pr:
autoCancel: 'true'
branches:
include:
- main
- develop
paths:
exclude:
- README.md
jobs:
- job: build_library
displayName: Build Library
strategy:
matrix:
'Windows':
image: 'windows-latest'
pool:
vmImage: $(image)
steps:
# if this is a tagged build for Resolved.It.Maui.Controls, then update the version number
- powershell: |
$buildSourceBranch = "$(Build.SourceBranch)"
$tagVersion = $buildSourceBranch.Substring($buildSourceBranch.LastIndexOf("/") + 1)
Write-Host("Branch = $buildSourceBranch, Version = $tagVersion");
Write-Host ("##vso[task.setvariable variable=NugetPackageVersion;]$tagVersion")
displayName: Set NuGet Version to Tag Number
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/') # Only run this step when a Tag has triggered the CI Pipeline
# if this is a PR build, then update the version number
- powershell: |
$prNumber = $env:System_PullRequest_PullRequestNumber
$commitId = "$($env:System_PullRequest_SourceCommitId)".Substring(0, 7)
$fullVersionString = "$(CurrentSemanticVersionBase)-build-$prNumber.$(Build.BuildId)+$commitId"
Write-Host("GitHub PR = $prNumber, Commit = $commitId");
Write-Host ("##vso[task.setvariable variable=NugetPackageVersion;]$fullVersionString")
Write-Host "##vso[build.updatebuildnumber]$fullVersionString"
displayName: Set NuGet Version to PR Version
condition: and(succeeded(), eq(variables['build.reason'], 'PullRequest')) # Only run this step when a Pull Request has triggered the CI Pipeline
- task: UseDotNet@2
displayName: Install .NET v$(RESOLVED_NET_VERSION)
inputs:
packageType: 'sdk'
version: '$(RESOLVED_NET_VERSION)'
- task: CmdLine@2
displayName: 'Install .NET MAUI Workload $(RESOLVED_NET_VERSION)'
inputs:
script: dotnet workload install maui
- task: CmdLine@2
displayName: 'Pack Resolved.It.Maui.Core NuGet'
inputs:
script: 'dotnet pack $(PathToCoreCsproj) -c Release -p:PackageVersion=$(NugetPackageVersion)'
- task: CmdLine@2
displayName: 'Pack Resolved.It.Maui.Controls NuGet'
inputs:
script: 'dotnet pack $(PathToControlsCsproj) -c Release -p:PackageVersion=$(NugetPackageVersion)'
# Copy all NuGet packages
- task: PowerShell@2
displayName: 'Copy NuGet Packages to Staging Directory'
inputs:
targetType: 'inline'
script: |
$source = ".\src"
$filter = "nupkg"
Get-ChildItem -Path $source -Recurse | Where-Object { $_.Extension -match $filter } | Copy-Item -Destination "$(Build.ArtifactStagingDirectory)"
pwsh: true
# Publish build artifacts
- task: PublishBuildArtifacts@1
displayName: 'Publish NuGets'
inputs:
artifactName: nuget
pathToPublish: '$(Build.ArtifactStagingDirectory)'