-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (124 loc) · 4.23 KB
/
library.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
name: "Library"
on:
push:
branches:
- "main"
paths:
- "*/**.cs"
- "*/**.csproj"
- ".editorconfig"
- "*.props"
- "global.json"
- "nuget.config"
- "*.sln"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
pull_request:
paths:
- "*/**.cs"
- "*/**.csproj"
- ".editorconfig"
- "*.props"
- "global.json"
- "nuget.config"
- "*.sln"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
env:
RELEASE_NAME: "${{ github.ref_name }}"
NUGET_OUTPUT_DIRECTORY: "./artifacts/package/release"
jobs:
builder:
name: "Builder"
runs-on: "${{ vars.DEFAULT_UBUNTU }}"
env:
IS_PUSH_EVENT_TO_MAIN_BRANCH: "${{ github.event_name == 'push' && contains(github.ref, 'refs/heads/main') }}"
IS_RELEASE: "${{ startsWith(github.ref, 'refs/tags/v') && github.actor == github.repository_owner }}"
BUILD_CONFIGURATION: "Release"
steps:
- name: "Set up repository with all history"
uses: "actions/checkout@v4.1.6"
with:
fetch-depth: 0
- name: "Set up .NET SDK"
uses: "actions/setup-dotnet@v4.0.0"
- name: "Restore dependencies"
run: "dotnet restore"
- name: "Get all changed files"
id: "csharp-files"
uses: "tj-actions/changed-files@v44.5.2"
with:
files: "**/*.cs"
- name: "Run formatter for all changed files"
if: "${{ steps.csharp-files.outputs.any_changed == vars.POSITIVE }}"
run: |
dotnet format \
--include ${{ steps.csharp-files.outputs.all_changed_files }} \
--no-restore \
--verify-no-changes
- name: "Build artifacts"
run: |
dotnet build \
--no-restore \
--configuration '${{ env.BUILD_CONFIGURATION }}'
- name: "Run tests"
run: |
dotnet test \
--no-build \
--configuration '${{ env.BUILD_CONFIGURATION }}' \
-property:'CollectCoverage=${{ env.IS_PUSH_EVENT_TO_MAIN_BRANCH }}'
- name: "Upload coverage results"
if: "${{ env.IS_PUSH_EVENT_TO_MAIN_BRANCH == vars.POSITIVE }}"
uses: "codecov/codecov-action@v4.4.1"
with:
directory: "./artifacts/coverage"
files: "*.xml"
fail_ci_if_error: true
token: "${{ secrets.CODECOV_TOKEN }}"
- name: "Build packages"
if: "${{ env.IS_RELEASE == vars.POSITIVE }}"
run: |
dotnet pack \
--no-build \
--configuration '${{ env.BUILD_CONFIGURATION }}' \
-property:"PackageVersion=${GITHUB_REF_NAME#v}" \
-property:'PackageReleaseNotes=Please see ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}'
- name: "Upload artifacts"
uses: "actions/upload-artifact@v4.3.3"
if: "${{ env.IS_RELEASE == vars.POSITIVE }}"
with:
name: "${{ env.RELEASE_NAME }}"
path: |
${{ env.NUGET_OUTPUT_DIRECTORY }}
global.json
nuget.config
publisher:
name: "Publisher"
needs: "builder"
if: "${{ startsWith(github.ref, 'refs/tags/v') && github.actor == github.repository_owner }}"
runs-on: "${{ vars.DEFAULT_UBUNTU }}"
env:
NUGET_SEARCH_PATTERN: "*.nupkg"
steps:
- name: "Download artifacts"
uses: "actions/download-artifact@v4.1.7"
with:
name: "${{ env.RELEASE_NAME }}"
- name: "Set up .NET SDK"
uses: "actions/setup-dotnet@v4.0.0"
- name: "Publish packages"
run: |
dotnet nuget push '${{ env.NUGET_OUTPUT_DIRECTORY }}${{ env.NUGET_SEARCH_PATTERN }}' \
--source 'nuget' \
--api-key '${{ secrets.NUGET_TOKEN }}' \
--skip-duplicate
dotnet nuget push '${{ env.NUGET_OUTPUT_DIRECTORY }}${{ env.NUGET_SEARCH_PATTERN }}' \
--source 'https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json' \
--api-key '${{ secrets.GITHUB_TOKEN }}' \
--skip-duplicate
- name: "Publish release"
uses: "softprops/action-gh-release@v2.0.5"
with:
generate_release_notes: true
files: "${{ env.NUGET_OUTPUT_DIRECTORY }}/*"