Skip to content

Commit f39f50e

Browse files
committed
ci: Add Azure Pipeline
1 parent b04cd1a commit f39f50e

File tree

4 files changed

+205
-0
lines changed

4 files changed

+205
-0
lines changed

build/azure-pipelines.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
trigger:
2+
branches:
3+
include:
4+
- main
5+
6+
variables:
7+
- name: NUGET_VERSION
8+
value: 6.14.0
9+
- name: windowsHostedAgentImage
10+
value: 'windows-2025'
11+
- name: ArtifactName
12+
value: Packages
13+
- name: SolutionFileName
14+
value: DeviceCore.sln
15+
- name: IsReleaseBranch # Should this branch name use the release stage.
16+
value: $[or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), startsWith(variables['Build.SourceBranch'], 'refs/heads/feature/'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))]
17+
18+
stages:
19+
- stage: Build
20+
jobs:
21+
- job: Windows
22+
strategy:
23+
maxParallel: 3
24+
matrix:
25+
Packages:
26+
ApplicationConfiguration: Release
27+
ApplicationPlatform: Any CPU
28+
GeneratePackageOnBuild: true
29+
30+
pool:
31+
vmImage: $(windowsHostedAgentImage)
32+
33+
variables:
34+
- name: PackageOutputPath # Path where NuGet packages will be copied to.
35+
value: $(Build.ArtifactStagingDirectory)
36+
37+
workspace:
38+
clean: all # Cleanup the workspace before starting.
39+
40+
steps:
41+
- template: stage-build.yml
42+
43+
- stage: Release
44+
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['IsReleaseBranch'], 'true')) # Only release when the build is not for a Pull Request and branch name fits.
45+
jobs:
46+
- job: Publish_NuGet_External
47+
48+
pool:
49+
vmImage: $(windowsHostedAgentImage)
50+
51+
workspace:
52+
clean: all # Cleanup the workspace before starting.
53+
54+
steps:
55+
- template: stage-release.yml

build/gitversion.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# The version is driven by conventional commits via xxx-version-bump-message.
2+
# Anything merged to main creates a new stable version.
3+
# Only builds from main and feature/* are pushed to nuget.org.
4+
5+
assembly-versioning-scheme: MajorMinorPatch
6+
mode: MainLine
7+
next-version: '' # Use git tags to set the base version.
8+
continuous-delivery-fallback-tag: ""
9+
commit-message-incrementing: Enabled
10+
major-version-bump-message: "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)"
11+
minor-version-bump-message: "^(feat)(\\([\\w\\s-]*\\))?:"
12+
patch-version-bump-message: "^(build|chore|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:"
13+
no-bump-message: "^(ci)(\\([\\w\\s-]*\\))?:" # You can use the "ci" type to avoid bumping the version when your changes are limited to the build or .github folders.
14+
branches:
15+
main:
16+
regex: ^master$|^main$
17+
tag: ''
18+
dev:
19+
regex: dev/.*?/(.*?)
20+
tag: dev.{BranchName}
21+
source-branches: [main]
22+
feature:
23+
tag: feature.{BranchName}
24+
regex: feature/(.*?)
25+
source-branches: [main]
26+
ignore:
27+
sha: []

build/stage-build.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
parameters:
2+
DotNetVersion: '8.0.401'
3+
UnoCheck_Version: '1.30.1'
4+
UnoCheck_Manifest: 'https://raw.githubusercontent.com/unoplatform/uno.check/0ca039bef4097295fc6c2c5c282ae18a797160c1/manifests/uno.ui.manifest.json'
5+
6+
steps:
7+
- task: GitVersion/setup@0
8+
inputs:
9+
versionSpec: '5.10.1'
10+
displayName: 'Install GitVersion'
11+
12+
- task: GitVersion/execute@0
13+
inputs:
14+
useConfigFile: true
15+
configFilePath: $(Build.SourcesDirectory)/build/gitversion.yml
16+
displayName: 'Calculate version'
17+
18+
- task: UseDotNet@2
19+
displayName: 'Use .NET SDK ${{ parameters.DotNetVersion }}'
20+
retryCountOnTaskFailure: 3
21+
inputs:
22+
packageType: sdk
23+
version: ${{ parameters.DotNetVersion }}
24+
includePreviewVersions: true
25+
26+
- powershell: |
27+
& dotnet tool update --global uno.check --version ${{ parameters.UnoCheck_Version }} --add-source https://api.nuget.org/v3/index.json
28+
& uno-check -v --ci --non-interactive --fix --skip xcode --skip gtk3 --skip vswin --skip vsmac --skip androidsdk --skip androidemulator --manifest ${{ parameters.UnoCheck_Manifest }}
29+
displayName: Install .NET Workloads | Uno-check
30+
errorActionPreference: continue
31+
ignoreLASTEXITCODE: true
32+
retryCountOnTaskFailure: 3
33+
34+
- task: MSBuild@1
35+
displayName: 'Restore solution packages'
36+
inputs:
37+
solution: $(Build.SourcesDirectory)/$(SolutionFileName)
38+
msbuildLocationMethod: version
39+
msbuildVersion: latest
40+
msbuildArchitecture: x64
41+
msbuildArguments: >
42+
/t:restore
43+
configuration: $(ApplicationConfiguration)
44+
platform: $(ApplicationPlatform)
45+
clean: false
46+
maximumCpuCount: true
47+
restoreNugetPackages: false
48+
logProjectEvents: false
49+
createLogFile: false
50+
51+
- task: MSBuild@1
52+
displayName: 'Build solution in $(ApplicationConfiguration) | $(ApplicationPlatform)'
53+
inputs:
54+
solution: $(Build.SourcesDirectory)/$(SolutionFileName)
55+
msbuildLocationMethod: version
56+
msbuildVersion: latest
57+
msbuildArchitecture: x64
58+
configuration: $(ApplicationConfiguration)
59+
platform: $(ApplicationPlatform)
60+
clean: false
61+
maximumCpuCount: true
62+
restoreNugetPackages: false
63+
logProjectEvents: false
64+
createLogFile: false
65+
msbuildArguments: > # Set the version of the packages, will have no effect on application projects (Heads).
66+
/p:PackageVersion=$(GitVersion.SemVer)
67+
/p:ContinuousIntegrationBuild=true
68+
69+
- script: >
70+
dotnet test $(Build.SourcesDirectory)/$(SolutionFileName)
71+
/p:Configuration=$(ApplicationConfiguration)
72+
/p:CollectCoverage=true
73+
/p:CoverletOutputFormat=cobertura
74+
/p:CoverletOutput=$(Build.SourcesDirectory)/coverage
75+
/p:ExcludeByFile="**/*.g.cs"
76+
--logger trx
77+
--no-build
78+
displayName: 'Run tests'
79+
condition: succeeded()
80+
81+
- task: PublishTestResults@2
82+
displayName: 'Publish test results'
83+
condition: succeededOrFailed()
84+
inputs:
85+
testRunner: VSTest
86+
testResultsFiles: '**/*.trx'
87+
88+
- task: PublishBuildArtifacts@1
89+
displayName: 'Publish artifact $(ApplicationConfiguration)'
90+
inputs:
91+
PathtoPublish: $(PackageOutputPath)
92+
ArtifactName: $(ArtifactName)
93+
ArtifactType: Container
94+
95+
- task: PostBuildCleanup@3
96+
displayName: 'Post-Build cleanup : Cleanup files to keep build server clean!'
97+
condition: always()

build/stage-release.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
steps:
2+
- checkout: none
3+
4+
- task: DownloadBuildArtifacts@0
5+
inputs:
6+
buildType: current
7+
downloadType: single
8+
artifactName: $(ArtifactName)
9+
10+
- task: NuGetToolInstaller@1
11+
displayName: 'Install NuGet $(NUGET_VERSION)'
12+
inputs:
13+
versionSpec: $(NUGET_VERSION)
14+
checkLatest: false
15+
16+
- task: NuGetCommand@2
17+
displayName: 'Push to Nuget.org'
18+
inputs:
19+
command: 'push'
20+
packagesToPush: '$(Build.ArtifactStagingDirectory)/$(ArtifactName)/*.nupkg'
21+
nuGetFeedType: 'external'
22+
publishFeedCredentials: 'NuGet.org - nventive'
23+
24+
- task: PostBuildCleanup@3
25+
displayName: 'Post-Build cleanup : Cleanup files to keep build server clean!'
26+
condition: always()

0 commit comments

Comments
 (0)