11name : build and test
22
3- on : [push, pull_request]
3+ on :
4+ push :
5+ branches :
6+ - main
7+ - ' version/**'
8+ pull_request :
9+ branches :
10+ - main
11+ workflow_dispatch :
412
513env :
6- DOTNET_VERSION : ' 6 .0.x' # The .NET SDK version to use
14+ DOTNET_VERSION : ' 8 .0.x' # The .NET SDK version to use
715
816jobs :
917 build-and-test :
10- name : build-and-test-${{matrix.os}}
11- runs-on : ${{matrix.os}}
18+ name : build-and-test-${{ matrix.os }}
19+ runs-on : ${{ matrix.os }}
1220 strategy :
1321 matrix :
1422 os : [windows-latest, ubuntu-latest, macos-latest]
1523
1624 steps :
17- - uses : actions/checkout@v3
18- - name : Setup .NET Core
25+ - name : Checkout
26+ uses : actions/checkout@v3
27+ with :
28+ fetch-depth : 0
29+
30+ - name : Setup .NET Core App
1931 uses : actions/setup-dotnet@v3
2032 with :
21- dotnet-version : ${{env.DOTNET_VERSION}}
33+ dotnet-version : ${{ env.DOTNET_VERSION }}
34+ dotnet-quality : ' preview'
2235
2336 - name : Install dependencies
24- run : dotnet restore -p:FullTargets=False
25-
37+ run : dotnet restore -p:FullTargets=false
38+
2639 - name : Build
27- run : dotnet build --no-restore -p:FullTargets=False
28-
40+ run : dotnet build --no-restore -p:FullTargets=false
41+
2942 - name : Test
30- run : dotnet test --no-restore -p:FullTargets=False
43+ run : dotnet test --no-restore -p:FullTargets=false
3144
32- build-and-publish :
33- name : build-and-publish
34- runs-on : ubuntu-latest
45+ pack-and-upload :
46+ name : pack-and-publish
3547 needs : build-and-test
36- if : github.ref == 'refs/heads/main'
37- permissions :
38- contents : read
39- packages : write
48+ runs-on : ubuntu-latest
4049
4150 steps :
42- - uses : actions/checkout@v3
43- - name : Setup .NET Core
44- uses : actions/setup-dotnet@v3
45- with :
46- dotnet-version : ${{env.DOTNET_VERSION}}
47-
48- - name : Install dependencies
49- run : dotnet restore -p:FullTargets=True
50-
51- - name : Build
52- run : dotnet build --no-restore -c Release -p:FullTargets=True
53-
54- - name : Pack
55- run : dotnet pack -c Release --no-build
56-
57- - name : Publish
58- run : dotnet nuget push ./AdvancedSharpAdbClient/bin/Release/*.nupkg --source "github" --skip-duplicate --api-key ${{ secrets.NUGET_KEY }}
51+ - name : Checkout
52+ uses : actions/checkout@v3
53+ with :
54+ fetch-depth : 0
5955
60- - name : Get version
61- id : get_version
62- shell : pwsh
63- run : |
64- $version=(Select-Xml -Path ./Directory.Build.props -XPath 'Project/PropertyGroup/VersionPrefix').Node.InnerText
65- echo "version=$version" >> $env:GITHUB_OUTPUT
56+ - name : Setup .NET Core App
57+ uses : actions/setup-dotnet@v3
58+ with :
59+ dotnet-version : ${{ env.DOTNET_VERSION }}
60+ dotnet-quality : ' preview'
6661
67- - name : Upload
68- uses : actions/upload-artifact@v3
69- with :
70- name : v${{ steps.get_version.outputs.version }}
71- path : ./AdvancedSharpAdbClient/bin/Release/
62+ - name : Install dependencies
63+ run : dotnet restore -p:FullTargets=true
64+
65+ - name : Pack
66+ run : dotnet pack --no-restore --version-suffix build.${{ github.run_number }}.${{ github.run_attempt }} -o "nugets" -p:FullTargets=true
67+
68+ - name : Publish
69+ if : ${{ github.event_name == 'push' && github.ref_name == 'main' }}
70+ run : dotnet nuget push ./nugets/*nupkg --source "github" --skip-duplicate --api-key ${{ secrets.NUGET_KEY }}
71+
72+ - name : Upload
73+ uses : actions/upload-artifact@v3
74+ with :
75+ name : Nuget Package
76+ path : nugets/**
0 commit comments