1- name : Auto GitHub Release from csproj
1+ name : Build, Test and Publish
22
33on :
44 push :
@@ -10,33 +10,36 @@ permissions:
1010 contents : write
1111
1212jobs :
13- release :
13+ build-test-publish :
1414 runs-on : ubuntu-latest
1515
1616 steps :
1717 - name : Checkout code
18- uses : actions/checkout@v2
18+ uses : actions/checkout@v4
1919 with :
2020 fetch-depth : 0
2121
2222 - name : Setup .NET
23- uses : actions/setup-dotnet@v3
23+ uses : actions/setup-dotnet@v4
2424 with :
25- dotnet-version : ' 9 .0.x'
25+ dotnet-version : ' 10 .0.x'
2626
2727 - name : Restore dependencies
2828 run : dotnet restore
2929
30- - name : Build
30+ - name : Build all projects
3131 run : dotnet build --configuration Release --no-restore
3232
33- - name : Pack
34- run : dotnet pack --configuration Release --no-build --output ./nuget
33+ - name : Run tests
34+ run : dotnet test Telegram.Bot.UI.Tests/Telegram.Bot.UI.Tests.csproj --configuration Release --no-build --verbosity normal
35+
36+ - name : Pack library only (exclude Tests and Demo)
37+ run : dotnet pack Telegram.Bot.UI/Telegram.Bot.UI.csproj --configuration Release --no-build --output ./nuget
3538
3639 - name : Get current version from csproj
3740 id : get_version
3841 run : |
39- ver=$(grep -oPm1 "(?<=<Version>)[^<]+" * .csproj)
42+ ver=$(grep -oPm1 "(?<=<Version>)[^<]+" Telegram.Bot.UI/Telegram.Bot.UI .csproj)
4043 echo "version=$ver" >> $GITHUB_OUTPUT
4144
4245 - name : Check if tag exists
@@ -53,12 +56,15 @@ jobs:
5356 run : |
5457 git tag "v${{ steps.get_version.outputs.version }}"
5558 git push origin "v${{ steps.get_version.outputs.version }}"
56- gh release create "v${{ steps.get_version.outputs.version }}" --title "Release ${{ steps.get_version.outputs.version }}" --generate-notes
59+ gh release create "v${{ steps.get_version.outputs.version }}" \
60+ --title "Release ${{ steps.get_version.outputs.version }}" \
61+ --generate-notes \
62+ ./nuget/*.nupkg
5763 env :
5864 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5965
6066 - name : Publish to NuGet
6167 if : steps.tag_check.outputs.exists == 'false'
68+ run : dotnet nuget push ./nuget/*.nupkg -k $NUGET_API_TOKEN -s https://api.nuget.org/v3/index.json --skip-duplicate
6269 env :
6370 NUGET_API_TOKEN : ${{ secrets.NUGET_API_TOKEN }}
64- run : dotnet nuget push ./nuget/*.nupkg -k $NUGET_API_TOKEN -s https://api.nuget.org/v3/index.json
0 commit comments