-
Notifications
You must be signed in to change notification settings - Fork 1
205 lines (179 loc) · 7.1 KB
/
pipeline.yaml
File metadata and controls
205 lines (179 loc) · 7.1 KB
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
name: Pipeline
on:
push:
branches:
- '**' # Matches all branches
pull_request:
branches:
- '**' # Matches all branches
workflow_dispatch:
inputs:
force_build:
description: "Forces a build even if no changes are detected"
required: true
default: "false"
force_release:
description: "Forces a release even if no changes are detected"
required: true
default: "false"
concurrency:
group: pipeline-${{ github.ref_name }}
cancel-in-progress: true
jobs:
discovery:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
pathsFilter_src: ${{ steps.pathsFilter.outputs.src }}
gitVersion_SemVer: ${{ steps.gitversion.outputs.GitVersion_SemVer }}
gitVersion_AssemblySemFileVer: ${{ steps.gitversion.outputs.GitVersion_AssemblySemFileVer }}
build: ${{ steps.evaluate_build.outputs.result }}
build_push: ${{ steps.evaluate_build_push.outputs.result }}
build_configuration: ${{ steps.evaluate_build_configuration.outputs.result }}
release: ${{ steps.evaluate_release.outputs.result }}
steps:
- name: checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: tools - dotnet - install
uses: actions/setup-dotnet@v5
with:
dotnet-version: "10.x"
- name: tools - gitversion - install
uses: gittools/actions/gitversion/setup@v4.5.0
with:
versionSpec: "6.x"
preferLatestVersion: true
- name: gitversion - execute
id: gitversion
uses: gittools/actions/gitversion/execute@v4.5.0
with:
configFilePath: GitVersion.yaml
- name: tools - detect changes
id: pathsFilter
uses: dorny/paths-filter@v4
with:
base: ${{ github.ref }}
filters: |
src:
- '*.sln'
- '*.slnx'
- '*.props'
- 'src/**'
build:
- '*.sln'
- '*.slnx'
- '*.props'
- 'src/**'
- 'tests/**'
- 'playground/**'
- name: evaluate - build
id: evaluate_build
env:
RESULT: ${{ steps.pathsFilter.outputs.build == 'true' || github.event.inputs.force_build == 'true' || github.event.inputs.force_release == 'true' }}
run: echo "result=$RESULT" >> $GITHUB_OUTPUT
- name: evaluate - build_push
id: evaluate_build_push
env:
RESULT: ${{ github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' && (steps.pathsFilter.outputs.src == 'true' || github.event.inputs.force_build == 'true') }}
run: echo "result=$RESULT" >> $GITHUB_OUTPUT
- name: evaluate - build_configuration
id: evaluate_build_configuration
env:
RESULT: ${{ github.ref == 'refs/heads/main' && 'Release' || 'Debug' }}
run: echo "result=$RESULT" >> $GITHUB_OUTPUT
- name: evaluate - release
id: evaluate_release
env:
RESULT: ${{ github.ref == 'refs/heads/main' || github.event.inputs.force_release == 'true' }}
run: echo "result=$RESULT" >> $GITHUB_OUTPUT
build:
name: build
if: ${{ needs.discovery.outputs.build == 'true' }}
needs: [discovery]
runs-on: ubuntu-latest
env:
build: ${{ needs.discovery.outputs.build }}
build_push: ${{ needs.discovery.outputs.build_push }}
build_configuration: ${{ needs.discovery.outputs.build_configuration }}
gitVersion_SemVer: ${{ needs.discovery.outputs.gitVersion_SemVer }}
gitVersion_AssemblySemFileVer: ${{ needs.discovery.outputs.gitVersion_AssemblySemFileVer }}
steps:
- name: checkout
uses: actions/checkout@v6
- name: tools - dotnet - install
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.x'
- name: tools - dotnet - install
uses: actions/setup-dotnet@v5
with:
dotnet-version: "10.x"
- name: dotnet - restore
run: dotnet restore
- name: dotnet - build
run: dotnet build --no-restore --configuration ${{ env.build_configuration }} /p:Version=${{ env.gitVersion_SemVer }} /p:AssemblyVersion=${{env.gitVersion_AssemblySemFileVer}} /p:NuGetVersion=${{env.gitVersion_SemVer}}
- name: dotnet - test
run: dotnet test --no-build --configuration ${{ env.build_configuration }} --verbosity normal
- name: tests - report
uses: dorny/test-reporter@v3
if: ${{ github.event.pull_request.head.repo.fork == false }}
with:
name: Test Results
path: .artifacts/TestResults/*.trx
reporter: dotnet-trx
fail-on-empty: "false"
- name: artifacts - nuget - gather
run: |
mkdir -p .artifacts/nuget
find . -name "*.nupkg" -exec cp {} .artifacts/nuget/ \;
- name: artifacts - nuget - upload
uses: actions/upload-artifact@v7
with:
name: artifacts-nuget
path: .artifacts/nuget/*.nupkg
- name: dotnet nuget push - GitHub
if: ${{ env.build_push == 'true' }}
run: |
dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/emberstack/index.json"
for pkg in .artifacts/nuget/*.nupkg; do
dotnet nuget push "$pkg" --source "github" --api-key ${{ secrets.ES_GITHUB_PAT }} --skip-duplicate
done
release:
name: release
if: ${{ needs.discovery.outputs.release == 'true' && github.ref == 'refs/heads/main' }}
needs: [discovery, build]
runs-on: ubuntu-latest
env:
gitVersion_SemVer: ${{ needs.discovery.outputs.gitVersion_SemVer }}
gitVersion_AssemblySemFileVer: ${{ needs.discovery.outputs.gitVersion_AssemblySemFileVer }}
steps:
- name: artifacts - nuget - download
uses: actions/download-artifact@v8
with:
name: artifacts-nuget
path: .artifacts/nuget
- name: dotnet nuget push - GitHub
run: |
dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/emberstack/index.json"
for pkg in .artifacts/nuget/*.nupkg; do
dotnet nuget push "$pkg" --source "github" --api-key ${{ secrets.ES_GITHUB_PAT }} --skip-duplicate
done
- name: dotnet nuget push - NuGet
if: github.ref == 'refs/heads/main'
run: |
for pkg in .artifacts/nuget/*.nupkg; do
dotnet nuget push "$pkg" --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.ES_NUGET_APIKEY }} --skip-duplicate
done
- name: github - release - create
uses: softprops/action-gh-release@v3
with:
repository: ${{ github.repository }}
name: v${{ env.gitVersion_SemVer }}
tag_name: v${{ env.gitVersion_SemVer }}
body: The release process is automated.
generate_release_notes: true
token: ${{ secrets.ES_GITHUB_PAT }}