66 pull_request :
77 branches : [ main, master, develop ]
88
9+ env :
10+ DOTNET_VERSION : ' 10.0.x'
11+ BUILD_CONFIGURATION : Release
12+ ARTIFACT_RETENTION_DAYS : 30
13+ RELEASE_ARTIFACT_RETENTION_DAYS : 90
14+
915jobs :
16+ # Debug/Analysis Build - Quick validation on all PRs and commits
17+ debug-build :
18+ runs-on : ubuntu-latest
19+ if : github.event_name == 'pull_request' || github.ref != 'refs/heads/main'
20+
21+ steps :
22+ - name : Checkout repository
23+ uses : actions/checkout@v4
24+
25+ - name : Setup .NET
26+ uses : actions/setup-dotnet@v4
27+ with :
28+ dotnet-version : ${{ env.DOTNET_VERSION }}
29+
30+ - name : Restore dependencies
31+ run : dotnet restore
32+
33+ - name : Build project (Debug)
34+ run : dotnet build --no-restore --configuration Debug
35+
36+ - name : Run unit tests (Debug)
37+ run : dotnet test --no-build --configuration Debug --verbosity normal
38+
39+ # Production Release Build - Full testing and validation
1040 build-and-test :
1141 runs-on : ubuntu-latest
42+ if : github.event_name == 'push'
1243
1344 strategy :
1445 matrix :
@@ -26,11 +57,11 @@ jobs:
2657 - name : Restore dependencies
2758 run : dotnet restore
2859
29- - name : Build project
30- run : dotnet build --no-restore --configuration Release
60+ - name : Build project (Release)
61+ run : dotnet build --no-restore --configuration ${{ env.BUILD_CONFIGURATION }}
3162
3263 - name : Run unit tests with coverage
33- run : dotnet test --no-build --configuration Release --verbosity normal --collect:"XPlat Code Coverage" --results-directory:./coverage
64+ run : dotnet test --no-build --configuration ${{ env.BUILD_CONFIGURATION }} --verbosity normal --collect:"XPlat Code Coverage" --results-directory:./coverage
3465
3566 - name : Upload coverage reports (Codecov)
3667 uses : codecov/codecov-action@v4
@@ -46,10 +77,11 @@ jobs:
4677 name : deep-learning-protocol-binaries-${{ matrix.dotnet-version }}
4778 path : |
4879 **/bin/Release/
49- retention-days : 30
80+ retention-days : ${{ env.ARTIFACT_RETENTION_DAYS }}
5081
5182 code-quality :
5283 runs-on : ubuntu-latest
84+ if : github.event_name == 'push'
5385
5486 steps :
5587 - name : Checkout repository
@@ -58,14 +90,15 @@ jobs:
5890 - name : Setup .NET
5991 uses : actions/setup-dotnet@v4
6092 with :
61- dotnet-version : ' 10.0.x '
93+ dotnet-version : ${{ env.DOTNET_VERSION }}
6294
6395 - name : Restore dependencies
6496 run : dotnet restore
6597
6698 - name : Check code style (optional)
6799 run : dotnet build --no-restore /p:EnforceCodeStyleInBuild=true || true
68100
101+ # Release Build Job - Creates optimized binaries for distribution
69102 publish-release :
70103 needs : build-and-test
71104 runs-on : ubuntu-latest
@@ -78,15 +111,51 @@ jobs:
78111 - name : Setup .NET
79112 uses : actions/setup-dotnet@v4
80113 with :
81- dotnet-version : ' 10.0.x '
114+ dotnet-version : ${{ env.DOTNET_VERSION }}
82115
83- - name : Publish release build
84- run : dotnet publish DeepLearningProtocol/DeepLearningProtocol.csproj -c Release -o ./release-build
116+ - name : Restore dependencies
117+ run : dotnet restore
118+
119+ - name : Build Release configuration
120+ run : dotnet build --no-restore --configuration ${{ env.BUILD_CONFIGURATION }}
121+
122+ - name : Publish self-contained release (Linux x64)
123+ run : dotnet publish DeepLearningProtocol/DeepLearningProtocol.csproj -c ${{ env.BUILD_CONFIGURATION }} -r linux-x64 -o ./release-build/linux-x64 --self-contained
124+
125+ - name : Publish self-contained release (Windows x64)
126+ run : dotnet publish DeepLearningProtocol/DeepLearningProtocol.csproj -c ${{ env.BUILD_CONFIGURATION }} -r win-x64 -o ./release-build/win-x64 --self-contained
127+
128+ - name : Publish self-contained release (macOS x64)
129+ run : dotnet publish DeepLearningProtocol/DeepLearningProtocol.csproj -c ${{ env.BUILD_CONFIGURATION }} -r osx-x64 -o ./release-build/osx-x64 --self-contained
130+
131+ - name : Publish framework-dependent release
132+ run : dotnet publish DeepLearningProtocol/DeepLearningProtocol.csproj -c ${{ env.BUILD_CONFIGURATION }} -o ./release-build/framework-dependent
133+
134+ - name : Create release archive (Linux)
135+ run : tar -czf release-build/deeplearning-protocol-linux-x64.tar.gz -C release-build linux-x64
136+
137+ - name : Create release archive (Windows)
138+ run : cd release-build/win-x64 && zip -r ../deeplearning-protocol-win-x64.zip . && cd ../..
139+
140+ - name : Create release archive (macOS)
141+ run : tar -czf release-build/deeplearning-protocol-osx-x64.tar.gz -C release-build osx-x64
142+
143+ - name : Create release archive (Framework-dependent)
144+ run : tar -czf release-build/deeplearning-protocol-framework-dependent.tar.gz -C release-build framework-dependent
145+
146+ - name : Upload multi-platform release artifacts
147+ uses : actions/upload-artifact@v4
148+ with :
149+ name : deeplearning-protocol-release-multiplatform
150+ path : |
151+ release-build/deeplearning-protocol-*.tar.gz
152+ release-build/deeplearning-protocol-*.zip
153+ retention-days : ${{ env.RELEASE_ARTIFACT_RETENTION_DAYS }}
85154
86- - name : Upload release artifact
155+ - name : Upload binaries artifact
87156 uses : actions/upload-artifact@v4
88157 with :
89- name : deeplearning-protocol-release
90- path : ./ release-build
91- retention-days : 90
158+ name : deeplearning-protocol-release-binaries
159+ path : release-build/
160+ retention-days : ${{ env.RELEASE_ARTIFACT_RETENTION_DAYS }}
92161
0 commit comments