1- name : Build, Test & Publish
1+ name : Build & Publish
22
33on :
44 push :
1616env :
1717 CONFIGURATION : Release
1818 PROJECT_PATH : src/PrintZPL.Host/PrintZPL.Host.csproj
19- TEST_PROJECT_PATH : tests/PrintZPL.Tests/PrintZPL.Tests.csproj
2019 FRAMEWORK : net8.0
2120
2221jobs :
23- test :
22+ build :
2423 runs-on : ubuntu-latest
25- name : Test & Code Quality
24+ name : Build & Validate
2625
2726 steps :
2827 - name : Checkout repository
2928 uses : actions/checkout@v4
3029
31- - name : Setup .NET 8 & 9
30+ - name : Setup .NET 8
3231 uses : actions/setup-dotnet@v4
3332 with :
34- dotnet-version : |
35- 8.0.x
36- 9.0.x
33+ dotnet-version : ' 8.0.x'
3734
3835 - name : Cache NuGet packages
3936 uses : actions/cache@v4
@@ -48,49 +45,96 @@ jobs:
4845 - name : Build solution
4946 run : dotnet build --configuration ${{ env.CONFIGURATION }} --no-restore
5047
51- - name : Run tests
52- run : dotnet test --configuration ${{ env.CONFIGURATION }} --no-build --verbosity normal --collect:"XPlat Code Coverage"
48+ - name : Check for vulnerable packages
49+ run : dotnet list package --vulnerable --include-transitive
5350
54- - name : Upload test results
55- uses : actions/upload-artifact@v4
56- if : always()
51+ - name : Check for deprecated packages
52+ run : dotnet list package --deprecated
53+
54+ publish :
55+ runs-on : ubuntu-latest
56+ needs : [build]
57+ if : success()
58+ strategy :
59+ fail-fast : false
60+ matrix :
61+ runtime :
62+ - win-x64
63+ - linux-x64
64+ - osx-x64
65+
66+ steps :
67+ - name : Checkout repository
68+ uses : actions/checkout@v4
69+
70+ - name : Setup .NET 8
71+ uses : actions/setup-dotnet@v4
72+ with :
73+ dotnet-version : ' 8.0.x'
74+
75+ - name : Cache NuGet packages
76+ uses : actions/cache@v4
5777 with :
58- name : test-results
59- path : |
60- **/TestResults/**/*.xml
61- **/TestResults/**/*.trx
62- **/TestResults/**/*.coverage
78+ path : ~/.nuget/packages
79+ key : ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
80+ restore-keys : ${{ runner.os }}-nuget-
81+
82+ - name : Restore dependencies
83+ run : dotnet restore "${{ env.PROJECT_PATH }}"
84+
85+ - name : Publish single-file executable (${{ matrix.runtime }})
86+ run : |
87+ dotnet publish "${{ env.PROJECT_PATH }}" \
88+ -c ${{ env.CONFIGURATION }} \
89+ -r ${{ matrix.runtime }} \
90+ --self-contained true \
91+ /p:PublishSingleFile=true \
92+ /p:PublishTrimmed=true \
93+ /p:TrimMode=Link \
94+ /p:EnableCompressionInSingleFile=true
95+
96+ - name : Test published executable (${{ matrix.runtime }})
97+ run : |
98+ PUBLISH_DIR="src/PrintZPL.Host/bin/${{ env.CONFIGURATION }}/${{ env.FRAMEWORK }}/${{ matrix.runtime }}/publish"
99+ if [[ "${{ matrix.runtime }}" == "win-x64" ]]; then
100+ echo "Skipping Windows executable test on Linux runner"
101+ else
102+ chmod +x "$PUBLISH_DIR/PrintZPL.Host"
103+ timeout 10s "$PUBLISH_DIR/PrintZPL.Host" --console || true
104+ fi
63105
64- - name : Generate code coverage report
106+ - name : Zip published output (${{ matrix.runtime }})
65107 run : |
66- dotnet tool install -g dotnet-reportgenerator-globaltool
67- reportgenerator -reports:"**/coverage.cobertura.xml" -targetdir:"coverage" -reporttypes:Html
68- if : always()
108+ PUBLISH_DIR="src/PrintZPL.Host/bin/${{ env.CONFIGURATION }}/${{ env.FRAMEWORK }}/${{ matrix.runtime }}/publish"
109+ ZIP_NAME="PrintZPL-${{ matrix.runtime }}.zip"
110+ cd "$PUBLISH_DIR"
111+ zip -r "${{ github.workspace }}/$ZIP_NAME" .
69112
70- - name : Upload coverage reports
113+ - name : Upload artifact for ${{ matrix.runtime }}
71114 uses : actions/upload-artifact@v4
72- if : always()
73115 with :
74- name : coverage-report
75- path : coverage/
116+ name : PrintZPL-${{ matrix.runtime }}
117+ path : PrintZPL-${{ matrix.runtime }}.zip
76118
77- security :
119+ release :
78120 runs-on : ubuntu-latest
79- name : Security & Vulnerability Check
121+ needs : publish
122+ if : startsWith(github.ref, 'refs/tags/v')
80123
81124 steps :
82- - name : Checkout repository
83- uses : actions/checkout@v4
84-
85- - name : Setup .NET 8 & 9
86- uses : actions/setup-dotnet@v4
125+ - name : Download all artifacts
126+ uses : actions/download-artifact@v4
87127 with :
88- dotnet-version : |
89- 8.0.x
90- 9.0.x
91-
92- - name : Restore dependencies
93- run : dotnet restore
128+ pattern : PrintZPL-*
129+ merge-multiple : true
94130
95- - name : Check for vulnerable packages
96- run : dotnet list package --vulner
131+ - name : Create GitHub Release
132+ uses : softprops/action-gh-release@v1
133+ with :
134+ files : |
135+ PrintZPL-*.zip
136+ generate_release_notes : true
137+ draft : false
138+ prerelease : false
139+ env :
140+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments