-
Notifications
You must be signed in to change notification settings - Fork 5
158 lines (154 loc) · 5.05 KB
/
cicd.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
name: CI/CD
on:
pull_request:
paths:
- 'src/**'
- 'GitVersion.yml'
- '.github/workflows/cicd.yml'
- '.github/actions/materialize-signing-key/**'
types: [opened, synchronize, reopened]
push:
branches:
- 'master'
paths:
- 'src/**'
- 'GitVersion.yml'
- '.github/workflows/cicd.yml'
- '.github/actions/materialize-signing-key/**'
workflow_dispatch:
inputs:
buildAutoMoq:
description: 'Build AutoMoq'
required: true
type: boolean
default: true
buildAutoNSubstitute:
description: 'Build AutoNSubstitute'
required: true
type: boolean
default: true
buildAutoFakeItEasy:
description: 'Build AutoFakeItEasy'
required: true
type: boolean
default: true
environment:
description: 'Environment'
type: environment
required: true
default: prod
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
Configuration: Release
Namespace: Objectivity.AutoFixture.XUnit2
CoverageDirectory: ${{ github.workspace }}\src\opencover
defaults:
run:
shell: pwsh
jobs:
init:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.MATRIX }}
Version: ${{ steps.gitversion.outputs.MajorMinorPatch }}
steps:
- name: 🎰 prepare strategy matrix
id: set-matrix
run: |
$allModules = @{
AutoMoq=if ('${{inputs.buildAutoMoq}}') { $${{inputs.buildAutoMoq}} } else { $true };
AutoNSubstitute=if ('${{inputs.buildAutoNSubstitute}}') { $${{inputs.buildAutoNSubstitute}} } else { $true };
AutoFakeItEasy=if ('${{inputs.buildAutoFakeItEasy}}') { $${{inputs.buildAutoFakeItEasy}} } else { $true }
}
$matrix = @{
package_module = @(Foreach ($module in ($allModules.GetEnumerator() | Where-Object { $_.Value })) {$module.Name})
}
if ($matrix.package_module.count -gt 0) { $matrix.package_module = @("Core") + $matrix.package_module }
"MATRIX=$($matrix | ConvertTo-JSON -Compress)" >> $env:GITHUB_OUTPUT
- name: 📥 checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 🗜️ install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
- name: 🎱 determine version
id: gitversion
uses: gittools/actions/gitversion/execute@v0
with:
useConfigFile: true
build:
needs: init
runs-on: windows-latest # We are using windows instead of ubuntu becaus it provides support for net472 & net48.
timeout-minutes: 15
env:
Version: ${{ needs.init.outputs.Version }}
strategy:
matrix: ${{ fromJSON(needs.init.outputs.matrix) }}
steps:
- name: 📥 checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 🖊️ materialize signing key
id: signing-key
uses: ./.github/actions/materialize-signing-key
with:
signing-key-value: ${{ secrets.SIGNING_KEY }}
- name: 🏗️ build
run: dotnet build ./src/${{ env.Namespace }}.${{ matrix.package_module }}.sln
env:
CI: true
StrongNameKey: ${{ secrets.SIGNING_KEY }}
StrongNameKeyPath: ${{ steps.signing-key.outputs.file-path }}
- name: 🧪 test
uses: ./.github/actions/test-module
with:
module-name: ${{ matrix.package_module }}
module-namespace: ${{ env.Namespace }}
codecov-token: ${{ secrets.CODECOV_TOKEN }}
- name: 📦 pack
if: ${{ startsWith(matrix.package_module, 'Auto' ) }}
run: dotnet pack ./src/${{ env.Namespace }}.${{ matrix.package_module }} --no-restore
env:
CI: true
StrongNameKey: ${{ secrets.SIGNING_KEY }}
StrongNameKeyPath: ${{ steps.signing-key.outputs.file-path }}
- name: 🔼 upload packages
if: ${{ startsWith(matrix.package_module, 'Auto' ) }}
uses: actions/upload-artifact@v3
with:
name: packages
path: |
./src/**/*.nupkg
./src/**/*.snupkg
publish:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [build]
environment: ${{ inputs.environment }}
if: ${{ inputs.environment != null }}
steps:
- name: 🔽 download packages
uses: actions/download-artifact@v3
with:
name: packages
- name: 📤 push
run: dotnet nuget push **/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source "nuget.org" --skip-duplicate
add-tags:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [publish, init]
# Allow tagging only on the master branch
if: ${{ github.ref_name == 'master' }}
steps:
- name: 📥 checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 🏷️ tag version
run: |
git tag "${{ needs.init.outputs.Version }}"
git push origin "${{ needs.init.outputs.Version }}"