-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
201 lines (179 loc) · 6.69 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
schedules:
- cron: "0 0 * * *"
always: true
displayName: Daily midnight build
branches:
include:
- master
- production
trigger:
branches:
include:
- master
- production
paths:
include:
- src/*
- test/*
- k8s/*
- azure-pipelines.yml
# pr:
# branches:
# include:
# - "*"
pool:
vmImage: "ubuntu-latest"
variables:
- group: simplic-deployment
- group: simplic-deployment-docker
- group: simplic-deployment-dev02
- name: buildConfiguration
value: "Release"
- name: dotNetVersion
value: "6.0.x"
- name: DOCKER_BUILDKIT
value: 1
- name: CurrentVersion
value: "0.0.0.0"
- name: ImageTag
value: unset
- name: MainCSProjPath
value: "./src/Simplic.OxS.SDK"
resources:
repositories:
- repository: infrastructure
type: github
name: simplic/build-infrastructure
endpoint: simplic-bot
stages:
- stage: Build
displayName: Build image
condition: ne(variables['Build.RequestedFor'], 'simplic-bot')
jobs:
- job: Build
displayName: Build
pool:
vmImage: "ubuntu-latest"
steps:
- checkout: self
persistCredentials: true
fetchDepth: 1000
- task: Bash@3
displayName: "Write username"
inputs:
targetType: "inline"
script: |
sudo echo "$(Build.RequestedFor)"
- task: UseDotNet@2
inputs:
version: $(dotNetVersion)
includePreviewVersions: true
#- script: |
# wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5_amd64.deb
# sudo dpkg -i libssl1.0.0_1.0.2n-1ubuntu5_amd64.deb
# displayName: "Install necessary packages"
- script: |
COMMIT_MSG=$(git log -1 --pretty=%s)
if [[ $COMMIT_MSG == *"[skip gen]"* ]]; then
echo "* Last commit is marked with [skip gen] *"
echo "--> Skipping generation"
elif [[ $COMMIT_MSG == *"[force gen]"* ]]; then
echo "* Last commit is marked with [force gen] *"
echo "--> Forcing complete generation"
python ./generate.py --force
else
python ./generate.py
fi
displayName: "Generate projects"
condition: ne(variables['Build.Reason'], 'PullRequest')
- task: DotNetCoreCLI@2
displayName: "Restore solution"
inputs:
command: "restore"
projects: "**/*.sln"
feedsToUse: "select"
vstsFeed: "f7087ef5-bf6f-48b2-8b8b-5e513f4a7a9e"
# Increase version number by changes and pr tags
- ${{ if not(eq(variables['Build.Reason'], 'PullRequest')) }}:
- template: version-number-update-token-template.yml@infrastructure
parameters:
connection_string: $(connection_string)
git_user: $(git_user)
git_token: $(git_token)
branch_name: ${{ replace(variables['Build.SourceBranch'], 'refs/heads/', '') }}
# - script: |
# ls
# #set -e
# git config --global user.name "$(git_user)"
# #git checkout master
# git add docs/
# git add src/
# #git reset build-infrastructure/
# # merge if necessary
# #git config pull.rebase false || true
# #git pull origin master
# git commit -m "Generate Projects [skip ci]"
# git push https://$(git_token)@github.com/simplic/simplic-oxs-sdk.git HEAD:master
# displayName: "Push generated projects"
# condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- task: DotNetCoreCLI@2
displayName: "Build solution"
inputs:
command: "build"
projects: "**/*.sln"
arguments: "--configuration $(buildConfiguration)"
- task: DotNetCoreCLI@2
displayName: "Execute and publish tests"
inputs:
command: "test"
projects: "**/*.sln"
- task: DotNetCoreCLI@2
displayName: "Create nuget packages"
inputs:
command: "pack"
packagesToPack: "**/*.sln"
configuration: "$(buildConfiguration)"
nobuild: true
versioningScheme: "off"
packDirectory: "$(Build.ArtifactStagingDirectory)"
- task: NuGetCommand@2
displayName: "Publish nuget packages"
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
command: "push"
packagesToPush: "$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg"
nuGetFeedType: "internal"
publishVstsFeed: "f7087ef5-bf6f-48b2-8b8b-5e513f4a7a9e"
allowPackageConflicts: true
# Write security file for restoring nuget packages. This file will be mounted as
# secure file when building the docker container
- task: Bash@3
displayName: "Write security (pat) file"
inputs:
targetType: "inline"
script: |
sudo echo "$(nuget_pwd)" > pat
# Extract version number form the actual service and write it to the file
# with the name `current_version`
- task: PythonScript@0
displayName: "Write file version"
condition: ne(variables['Build.Reason'], 'PullRequest')
inputs:
scriptSource: "filePath"
scriptPath: "./build-infrastructure/get-csproj-version.py"
arguments: '--proj "$(MainCSProjPath)"'
# Read current_version file and write its content to the pipeline variable `CurrentVersion`
- task: PowerShell@2
displayName: Write current version number
condition: ne(variables['Build.Reason'], 'PullRequest')
inputs:
targetType: "inline"
script: |
Write-Host "##vso[task.setvariable variable=CurrentVersion]$(Get-Content -Path ./current_version)"
- task: PowerShell@2
displayName: Write image tag to output
name: DetermineResult
inputs:
targetType: "inline"
script: |
Write-Host "##vso[task.setvariable variable=ImageTag;isOutput=true]$(CurrentVersion)-$(Build.BuildId)"