-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
167 lines (152 loc) · 5.65 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
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
parameters:
- name: buildVersion
type: string
default: '0.0.0.0'
trigger:
batch: true
branches:
include:
- master
pool:
name: PH
variables:
buildConfiguration: 'Pipeline'
buildVersion: 'Will be set dynamically'
year: 'Will be set dynamically'
revision: $[counter(format('{0:dd}', pipeline.startTime), 1)]
stages:
- stage: BuildStage
jobs:
- job: BuildJob
steps:
- task: PowerShell@2
displayName: 'Install Modules'
name: "InstallModules"
inputs:
targetType: 'inline'
script: |
"Validate Modules" | Write-Host
$Modules = Get-Module -ListAvailable
if ("Pester" -notin $Modules.Name) {
"Install Pester" | Write-Host
Install-Module -Name Pester -Scope CurrentUser -Force
}
if ("psake" -notin $Modules.Name) {
"Install psake" | Write-Host
Install-Module -Name psake -Scope CurrentUser -Force
}
if ("PSDeploy" -notin $Modules.Name) {
"Install PSDeploy" | Write-Host
Install-Module -Name PSDeploy -Scope CurrentUser -Force
}
if ("PSScriptAnalyzer" -notin $Modules.Name) {
"Install PSScriptAnalyzer" | Write-Host
Install-Module -Name PSScriptAnalyzer -Scope CurrentUser -Force
}
"Register NuGet PackageSource" | Write-Host
Register-PackageSource -Name NuGet -Location "https://api.NuGet.org/v3/index.json" -ProviderName NuGet -Force
pwsh: true
failOnStderr: true
condition: succeeded()
- task: PowerShell@2
displayName: 'Preparing Build Number'
name: BuildVersioning
inputs:
targetType: 'inline'
script: |
$currentDate = $(Get-Date)
$year = $currentDate.Year
$month = $currentDate.Month
$day = $currentDate.Day
"Current date: {0}" -f $currentDate | Write-Host
"Current year: {0}" -f $year | Write-Host
"Current month: {0}" -f $month | Write-Host
"Current day: {0}" -f $day | Write-Host
"Revision: {0}" -f $env:revision | Write-Host
$versionString = "{0:d4}.{1:d2}.{2:d2}.{3}" -f $year,$month,$day,($env:revision -eq $null ? 0 : $env:revision)
"Version: {0}" -f $versionString | Write-Host
Write-Host "##vso[task.setvariable variable=buildVersion;isOutput=true]$versionString"
Write-Host "##vso[task.setvariable variable=year;isOutput=true]$year"
pwsh: true
failOnStderr: true
condition: succeeded()
- task: PowerShell@2
displayName: 'Build Module'
name: "BuildTask"
inputs:
filePath: '$(System.DefaultWorkingDirectory)/Build/build.ps1'
arguments: ' -Task Build -BuildVersion $(BuildVersioning.buildVersion)'
pwsh: true
failOnStderr: true
condition: succeeded()
- task: PublishPipelineArtifact@1
displayName: 'Publish Build Output'
inputs:
targetPath: '$(System.DefaultWorkingDirectory)/buildoutput'
artifactName: 'BuildOutput'
condition: succeeded()
- stage: PackageStage
dependsOn: [BuildStage]
jobs:
- job: 'Create_Artifacts'
variables:
buildVersion: $[ stageDependencies.BuildStage.BuildJob.outputs['BuildVersioning.buildVersion'] ]
year: $[ stageDependencies.BuildStage.BuildJob.outputs['BuildVersioning.year'] ]
steps:
- checkout: self
path: 'OmadaSqlTroubleshooter'
persistCredentials: true
clean: true
- task: DownloadPipelineArtifact@2
displayName: 'Download Build Output'
inputs:
artifactName: 'BuildOutput'
targetPath: '$(System.DefaultWorkingDirectory)/buildoutput'
- task: NuGetCommand@2
displayName: 'Pack project'
inputs:
command: pack
packagesToPack: '$(System.DefaultWorkingDirectory)/OmadaSqlTroubleshooter.nuspec'
packDestination: '$(Build.ArtifactStagingDirectory)'
versioningScheme: byEnvVar
versionEnvVar: buildVersion
buildProperties: 'VERSION=$(buildVersion);YEAR=$(year)'
condition: succeededOrFailed()
- task: NuGetCommand@2
displayName: 'NuGet push'
inputs:
command: push
nuGetFeedType: internal
publishVstsFeed: 'Fortigi-Generic/OmadaSqlTroubleshooter'
allowPackageConflicts: true
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
condition: succeeded()
continueOnError: false
# - task: CmdLine@2
# inputs:
# script: |
# echo "Create tag: $(buildVersion)"
# git config --global user.email "mark@fortigi.nl"
# git config --global user.name "Mark van Eijken"
# git tag -a v$(buildVersion) -m "Release version $(buildVersion)"
# git push https://user:$(System.AccessToken)@dev.azure.com/fortigi/Fortigi-Generic/_git/$(Build.Repository.Name) refs/tags/v$(buildVersion)
# failOnStderr: true
# displayName: 'Create Tag'
# condition: succeeded()
# enabled: true
# env:
# SYSTEM_ACCESSTOKEN: $(System.AccessToken)
- task: CmdLine@2
inputs:
script: |
echo "Create tag: $(buildVersion)"
git config --global user.email "mark@fortigi.nl"
git config --global user.name "Mark van Eijken"
git tag -a v$(buildVersion) -m "Release version $(buildVersion)"
git push origin refs/tags/v$(buildVersion) 2>stderr.log
type stderr.log
failOnStderr: false
workingDirectory: $(Build.SourcesDirectory)
displayName: 'Create Tag'
condition: succeeded()
enabled: true