-
Notifications
You must be signed in to change notification settings - Fork 2
186 lines (176 loc) · 6.36 KB
/
csharp.yml
File metadata and controls
186 lines (176 loc) · 6.36 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
name: csharp
on:
push:
branches: main
paths:
- 'csharp/**'
- '.github/workflows/csharp.yml'
env:
NUGETTOKEN: ${{ secrets.NUGET_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCRIPTS_BASE_URL: https://raw.githubusercontent.com/linksplatform/Scripts/main/MultiProjectRepository
defaults:
run:
working-directory: csharp
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- uses: actions/checkout@v1
with:
submodules: true
- name: Test
run: |
dotnet test -c Release -f net8
pushNuGetPackageToGitHubPackageRegistry:
needs: test
runs-on: ubuntu-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- uses: actions/checkout@v1
with:
submodules: true
- name: Build project
run: dotnet build -c Release
- name: Pack project
run: dotnet pack -c Release
- name: Add GitHub NuGet source
run: dotnet nuget add source https://nuget.pkg.github.com/linksplatform/index.json --name GitHub --username linksplatform --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text
- name: Push NuGet package to GitHub Package Registry
run: dotnet nuget push **/*.nupkg --source GitHub --skip-duplicate
pusnToNuget:
runs-on: ubuntu-latest
needs: test
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- uses: actions/checkout@v1
with:
submodules: true
- name: Set repository name
run: export REPOSITORY_NAME=$(basename ${{ github.repository }})
- name: Download project information script
run: wget "$SCRIPTS_BASE_URL/read_csharp_package_info.sh"
- name: Read project information
run: bash ./read_csharp_package_info.sh
- name: Set repository name for publishing
run: export REPOSITORY_NAME=$(basename ${{ github.repository }})
- name: Download NuGet publishing script
run: wget "$SCRIPTS_BASE_URL/push-csharp-nuget.sh"
- name: Publish NuGet package
run: bash ./push-csharp-nuget.sh
publiseRelease:
runs-on: ubuntu-latest
needs: test
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- uses: actions/checkout@v1
with:
submodules: true
- name: Set repository name for release
if: ${{ github.event_name == 'push' }}
run: export REPOSITORY_NAME=$(basename ${{ github.repository }})
- name: Download project information script for release
if: ${{ github.event_name == 'push' }}
run: wget "$SCRIPTS_BASE_URL/read_csharp_package_info.sh"
- name: Read project information
if: ${{ github.event_name == 'push' }}
run: bash ./read_csharp_package_info.sh
- name: Set repository name for release publishing
run: export REPOSITORY_NAME=$(basename ${{ github.repository }})
- name: Download release script
run: wget "$SCRIPTS_BASE_URL/publish-release.sh"
- name: Make release script executable
run: chmod +x ./publish-release.sh
- name: Download C# release script
run: wget "$SCRIPTS_BASE_URL/publish-csharp-release.sh"
- name: Publish release
run: bash ./publish-csharp-release.sh
findChangedCsFiles:
runs-on: ubuntu-latest
needs: test
outputs:
isCsFilesChanged: ${{ steps.setIsCsFilesChangedOutput.outputs.isCsFilesChanged }}
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get changed files using defaults
id: changed-files
uses: tj-actions/changed-files@v46
- name: Set output isCsFilesChanged
id: setIsCsFilesChangedOutput
run: |
isCsFilesChanged='false'
echo "Changed files: ${{ steps.changed-files.outputs.all_changed_files }}"
for changedFile in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ $changedFile == *.cs ]]
then
echo "isCsFilesChanged='true'"
isCsFilesChanged='true'
fi
done
echo "::set-output name=isCsFilesChanged::${isCsFilesChanged}"
echo "isCsFilesChanged: ${isCsFilesChanged}"
generatePdfWithCode:
runs-on: ubuntu-latest
needs: [findChangedCsFiles]
if: ${{ needs.findChangedCsFiles.outputs.isCsFilesChanged == 'true' }}
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- uses: actions/checkout@v1
with:
submodules: true
- name: Set repository name for PDF generation
run: export REPOSITORY_NAME=$(basename ${{ github.repository }})
- name: Download Python formatting script
run: wget "$SCRIPTS_BASE_URL/format-csharp-files.py"
- name: Download document formatting script
run: wget "$SCRIPTS_BASE_URL/format-csharp-document.sh"
- name: Download PDF generation script
run: wget "$SCRIPTS_BASE_URL/generate-csharp-pdf.sh"
- name: Generate PDF with code
run: bash ./generate-csharp-pdf.sh
publishDocumentation:
runs-on: ubuntu-latest
needs: [findChangedCsFiles]
if: ${{ needs.findChangedCsFiles.outputs.isCsFilesChanged == 'true' }}
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- uses: actions/checkout@v1
with:
submodules: true
- name: Set repository name for documentation
run: export REPOSITORY_NAME=$(basename ${{ github.repository }})
- name: Download DocFX configuration
run: wget "$SCRIPTS_BASE_URL/docfx.json"
- name: Download filter configuration
run: wget "$SCRIPTS_BASE_URL/filter.yml"
- name: Download table of contents configuration
run: wget "$SCRIPTS_BASE_URL/toc.yml"
- name: Download documentation publishing script
run: wget "$SCRIPTS_BASE_URL/publish-csharp-docs.sh"
- name: Publish documentation to gh-pages branch
run: bash ./publish-csharp-docs.sh