-
Notifications
You must be signed in to change notification settings - Fork 2
169 lines (159 loc) · 5.32 KB
/
csharp.yml
File metadata and controls
169 lines (159 loc) · 5.32 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
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: Publish NuGet package to GitHub Package Registry
run: |
dotnet build -c Release
dotnet pack -c Release --include-symbols
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
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: Read project information
run: |
export REPOSITORY_NAME=$(basename ${{ github.repository }})
wget "$SCRIPTS_BASE_URL/read_csharp_package_info.sh"
bash ./read_csharp_package_info.sh
- name: Publish NuGet package
run: |
export REPOSITORY_NAME=$(basename ${{ github.repository }})
wget "$SCRIPTS_BASE_URL/push-csharp-nuget.sh"
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: Read project information
if: ${{ github.event_name == 'push' }}
run: |
export REPOSITORY_NAME=$(basename ${{ github.repository }})
wget "$SCRIPTS_BASE_URL/read_csharp_package_info.sh"
bash ./read_csharp_package_info.sh
- name: Publish release
run: |
export REPOSITORY_NAME=$(basename ${{ github.repository }})
wget "$SCRIPTS_BASE_URL/publish-release.sh"
chmod +x ./publish-release.sh
wget "$SCRIPTS_BASE_URL/publish-csharp-release.sh"
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: Generate PDF with code
run: |
export REPOSITORY_NAME=$(basename ${{ github.repository }})
wget "$SCRIPTS_BASE_URL/format-csharp-files.py"
wget "$SCRIPTS_BASE_URL/format-csharp-document.sh"
wget "$SCRIPTS_BASE_URL/generate-csharp-pdf.sh"
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: Publish documentation to gh-pages branch
run: |
export REPOSITORY_NAME=$(basename ${{ github.repository }})
wget "$SCRIPTS_BASE_URL/docfx.json"
wget "$SCRIPTS_BASE_URL/filter.yml"
wget "$SCRIPTS_BASE_URL/toc.yml"
wget "$SCRIPTS_BASE_URL/publish-csharp-docs.sh"
bash ./publish-csharp-docs.sh