-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
azure-pipelines.yml
125 lines (102 loc) · 4.56 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
119
120
121
122
123
124
125
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
branches:
include:
- "*"
tags:
include:
- "*"
jobs:
- job: Build
displayName: Build
pool:
vmImage: "windows-2019"
variables:
buildConfiguration: "Release"
artifactsFolder: "$(Build.SourcesDirectory)/artifacts/"
steps:
- task: UseDotNet@2
displayName: "Use .NET 5.x"
inputs:
version: "5.x"
packageType: sdk
- powershell: $version = '0.0.0'; echo "##vso[task.setvariable variable=version]$version"
displayName: Set default version
- powershell: $version = ($env:Build_SourceBranch -replace 'refs/tags/v',''); echo $version; echo "##vso[task.setvariable variable=version]$version"
displayName: Get version from tag
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
- powershell: ((Get-Content -path .\CertDump\CertDump.csproj -Raw) -replace '0.0.0',$env:version) | Set-Content -Path .\CertDump\CertDump.csproj
displayName: Replace version with git tag
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
- powershell: dotnet pack -c $(buildConfiguration) -o $(artifactsFolder) /p:NativeCompilationDuringPublish=false
displayName: Pack global tool
- powershell: cp $(artifactsFolder)\CertDump.*.nupkg $(Build.ArtifactStagingDirectory)
displayName: Copy CertDump.nupkg to "Artifacts Staging Directory"
- powershell: dotnet publish -c $(buildConfiguration) -r win-x64 -o $(artifactsFolder)
displayName: Build native Windows executable
- powershell: cp $(artifactsFolder)\CertDump.exe $(Build.ArtifactStagingDirectory)
displayName: Copy CertDump.exe to "Artifacts Staging Directory"
- task: PowerShell@2
displayName: "Build MSI setup"
inputs:
targetPath: "filePath"
filePath: "$(Build.SourcesDirectory)/src/Installer/build-msi.ps1"
arguments: "-version $env:version"
workingDirectory: "$(Build.SourcesDirectory)/src/Installer"
- powershell: cp $(artifactsFolder)\CertDump.msi $(Build.ArtifactStagingDirectory)
displayName: Copy CertDump.msi to "Artifacts Staging Directory"
- task: PublishBuildArtifacts@1
displayName: Publish
inputs:
pathtoPublish: "$(Build.ArtifactStagingDirectory)"
artifactName: certdump
- powershell: ls $(Build.ArtifactStagingDirectory)
displayName: "List artifacts"
- job: Release
dependsOn:
- Build
pool:
vmImage: "windows-2019"
steps:
- task: UseDotNet@2
displayName: "Use .NET 5.x"
inputs:
version: "5.x"
packageType: sdk
- task: DownloadBuildArtifacts@0
displayName: Download Windows executable
inputs:
buildType: "current"
downloadType: "single"
artifactName: "certdump"
downloadPath: "$(System.ArtifactsDirectory)"
- task: NuGetToolInstaller@0
displayName: Install NuGet
inputs:
versionSpec: "5.4.0"
- powershell: $version = ($env:Build_SourceBranch -replace 'refs/tags/v',''); echo $version; echo "##vso[task.setvariable variable=version]$version"
displayName: Get version from tag
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
- task: NuGetCommand@2
displayName: "Publish tool to NuGet.org"
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
command: push
nuGetFeedType: external
allowPackageConflicts: true
publishFeedCredentials: "Nuget.org"
packagesToPush: "$(System.ArtifactsDirectory)/certdump/*.*nupkg"
- task: GitHubRelease@0
displayName: Create GitHub Release
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
gitHubConnection: "CertDumpRelease"
repositoryName: "secana/CertDump"
title: "CertDump Windows x64 $(version)"
addChangeLog: false
assets: |
$(System.ArtifactsDirectory)/certdump/*.exe
$(System.ArtifactsDirectory)/certdump/*.msi