-
Notifications
You must be signed in to change notification settings - Fork 120
265 lines (227 loc) · 8.51 KB
/
main.yaml
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
name: "Build Octopus Clients"
# Controls when the action will run.
on:
push:
# Triggers the workflow on pull request events and merges/pushes to master
branches:
- master
- release/*
tags-ignore:
- '**'
pull_request:
types: [opened, synchronize, reopened]
schedule:
# Daily 5am australian/brisbane time
- cron: '0 19 * * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Pass branch and patch number to Nuke OctoVersion
# (for pull_request events we override the /refs/pull/xx/merge branch to the PR's head branch)
env:
OCTOVERSION_CurrentBranch: ${{ github.head_ref || github.ref }}
OCTOVERSION_Patch: ${{ github.run_number }}
AssentNonInteractive: true
jobs:
build:
name: Build Octopus Clients
runs-on: windows-latest
outputs:
octoversion_fullsemver: ${{ steps.build.outputs.octoversion_fullsemver }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # all
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
# Adjustment is done prior to Nuke build as OCTOVERSION information is included in the result package.
- name: Append OCTOVERSION_CurrentBranch with -nightly (for scheduled)
if: github.event_name == 'schedule'
run: echo "OCTOVERSION_CurrentBranch=${{ env.OCTOVERSION_CurrentBranch }}-nightly-$(date +'%Y%m%d%H%M%S')" >> $env:GITHUB_ENV
# Note: Because this step runs on Windows, this will also run all of the tests on Windows
- name: Nuke Build 🏗
id: build
shell: bash
run: ./build.cmd
# Unit test reports
- name: Windows .NET 4.6.2 unit test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .Net 4.6.2 unit test results
path: ./TestResults/Win_net462_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .NET 4.8 unit test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows.Net 4.8 unit test results
path: ./TestResults/Win_net48_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .NET 6.0 unit test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .Net 6.0 unit test results
path: ./TestResults/Win_net6.0_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .NET 8.0 unit test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .Net 8.0 unit test results
path: ./TestResults/Win_net8.0_*.trx
reporter: dotnet-trx
fail-on-error: true
# E2E test reports
- name: Windows .NET 4.6.2 E2E test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .NET 4.6.2 E2E test results
path: ./TestResults/Win-E2E_net462_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .NET 4.8 E2E test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .NET 4.8 E2E test results
path: ./TestResults/Win-E2E_net48_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .NET 6.0 E2E test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .NET 6.0 E2E test results
path: ./TestResults/Win-E2E_net6.0_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .NET 8.0 E2E test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .NET 8.0 E2E test results
path: ./TestResults/Win-E2E_net8.0_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Upload NuGet package artifact
uses: actions/upload-artifact@v3
with:
name: OctoClientsNuget
path: ./artifacts/*.nupkg
- name: Tag release (when not pre-release) 🏷️
id: github-tag
if: ${{ github.event_name != 'schedule' && !contains( steps.build.outputs.octoversion_fullsemver, '-' ) }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.build.outputs.octoversion_fullsemver }}",
sha: context.sha
})
test-linux:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Setup .NET 8
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Run unit tests 🏗
shell: bash
run: dotnet test ./source/Octopus.Client.Tests/Octopus.Client.Tests.csproj --configuration:Release --logger:"trx;LogFilePrefix=Linux" --results-directory ./TestResults
- name: Linux unit test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Linux unit tests results
path: ./TestResults/*.trx
reporter: dotnet-trx
fail-on-error: true
test-macos:
name: Unit test on Mac OS
needs: build
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Setup .NET 8
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Run unit tests 🏗
shell: bash
run: dotnet test ./source/Octopus.Client.Tests/Octopus.Client.Tests.csproj --configuration:Release --logger:"trx;LogFilePrefix=Mac" --results-directory ./TestResults
- name: Mac OS unit test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Mac OS unit test results
path: ./TestResults/*.trx
reporter: dotnet-trx
fail-on-error: true
outcome:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Build and test outcome
needs: [ build, test-linux, test-macos ]
steps:
- if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}
run: exit 1
deploy_nuget:
name: Upload nuget packages to Octopus Deploy
runs-on: ubuntu-latest
permissions:
id-token: write # Required to obtain the ID token from GitHub Actions
actions: read # Required to download artifact
env:
OCTOPUS_SPACE: "Core Platform"
needs: [ build, test-linux, test-macos ]
steps:
- name: Download nuget package artifact
uses: actions/download-artifact@v3
with:
name: OctoClientsNuget
path: ./artifacts/
- name: Login to Octopus Deploy 🐙
uses: OctopusDeploy/login@v1
with:
server: https://deploy.octopus.app
service_account_id: 8b5a7f0f-c2c9-48de-a0f6-74d83669accf
- name: Push to Octopus 🐙
uses: OctopusDeploy/push-package-action@v3
with:
packages: |
./artifacts/Octopus.Client.${{ needs.build.outputs.octoversion_fullsemver }}.nupkg
./artifacts/Octopus.Server.Client.${{ needs.build.outputs.octoversion_fullsemver }}.nupkg
- name: Create Release in Octopus 🐙
uses: OctopusDeploy/create-release-action@v3
with:
project: "Octopus.Client"
packages: |
Octopus.Client:${{ needs.build.outputs.octoversion_fullsemver }}