1- name : Run and Publish NUnit Tests
1+ name : Publish
22
33on :
4- workflow_dispatch :
5- pull_request :
6- branches : main
7- push :
8- branches : main
4+ workflow_dispatch :
95
106jobs :
11-
12- run-tests :
7+ release :
8+ name : Release
139 strategy :
1410 matrix :
15- os :
16- - ' windows-latest'
11+ kind : ['linux', 'windows', 'macOS']
12+ include :
13+ - kind : linux
14+ os : ubuntu-latest
15+ target : linux-x64
16+ - kind : windows
17+ os : windows-latest
18+ target : win-x64
19+ - kind : macOS
20+ os : macos-latest
21+ target : osx-x64
1722 runs-on : ${{ matrix.os }}
1823 steps :
19-
2024 - name : Checkout
21- uses : actions/checkout@v3
22-
23- - name : Setup .NET
25+ uses : actions/checkout@v1
26+
27+ - name : Setup dotnet
2428 uses : actions/setup-dotnet@v1
2529 with :
26- dotnet-version : ' 6.0.x'
27-
28- - name : Install dependencies
29- run : dotnet restore
30+ dotnet-version : ' 6.0.x'
3031
3132 - name : Build
32- run : dotnet build --configuration Release --no-restore
33-
34- - name : Test
35- run : dotnet test --no-restore --verbosity normal
36-
37- - name : dotnet publish
38- run : dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
39-
40- - name : Upload artifact
41- uses : actions/upload-artifact@v2
42- with :
43- name : .net-app
44- path : ${{env.DOTNET_ROOT}}/myapp
45-
46- - name : Publish Test Results
47- uses : EnricoMi/publish-unit-test-result-action/composite@v2
48- id : test-results
49- if : always()
50- with :
51- trx_files : " test-results/**/*.trx"
52-
53- - name : Set badge color
5433 shell : bash
5534 run : |
56- case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in
57- success)
58- echo "BADGE_COLOR=31c653" >> $GITHUB_ENV
59- ;;
60- failure)
61- echo "BADGE_COLOR=800000" >> $GITHUB_ENV
62- ;;
63- neutral)
64- echo "BADGE_COLOR=696969" >> $GITHUB_ENV
65- ;;
66- esac
67-
68- - name : Create Awesome Badge
69- uses : schneegans/dynamic-badges-action@v1.4.0
35+ tag=$(git describe --tags --abbrev=0)
36+ release_name="App-$tag-${{ matrix.target }}"
37+
38+ # Build everything
39+ dotnet publish src/App/App.csproj --framework net6.0 --runtime "${{ matrix.target }}" -c Release -o "$release_name"
40+
41+ # Pack files
42+ if [ "${{ matrix.target }}" == "win-x64" ]; then
43+ # Pack to zip for Windows
44+ 7z a -tzip "${release_name}.zip" "./${release_name}/*"
45+ else
46+ tar czvf "${release_name}.tar.gz" "$release_name"
47+ fi
48+
49+ # Delete output directory
50+ rm -r "$release_name"
51+
52+ - name : Publish
53+ uses : softprops/action-gh-release@v1
7054 with :
71- auth : ${{ secrets.GIST_SECRET }}
72- gistID : 4c1497eb43ee225c377c964b2e447a89
73- filename : test.json
74- label : Tests
75- message : ' ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests }} tests, ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.runs }} runs: ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}'
76- color : ${{ env.BADGE_COLOR }}
55+ files : " App*"
56+ env :
57+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments