1- # This workflow will build a .NET project
2- # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3-
4- name : .NET
1+ name : release-please
52
63on :
74 push :
8- branches : [ "main" ]
9- pull_request :
10- branches : [ "main" ]
11- workflow_dispatch :
5+ branches : [ main ]
6+
7+ permissions :
8+ contents : write # required for tags + releases
9+ pull-requests : write # required for release PRs
1210
1311jobs :
14- build-test-publish :
12+ release-please :
13+ outputs :
14+ release_created : ${{ steps.release.outputs.release_created }}
15+ tag_name : ${{ steps.release.outputs.tag_name }}
16+ version : ${{ steps.release.outputs.version }}
1517 runs-on : ubuntu-latest
1618 steps :
17- - uses : actions/checkout@v4
18- - name : Setup .NET
19- uses : actions/setup-dotnet@v4
19+ - name : Run release-please
20+ id : release
21+ uses : googleapis/release-please-action@v4
22+ with :
23+ token : ${{ secrets.GITHUB_TOKEN }}
24+ manifest-file : .release-please-manifest.json
25+ config-file : release-please-config.json
26+
27+ publish :
28+ needs :
29+ - release-please
30+ if : needs.release-please.outputs.release_created
31+ runs-on : ubuntu-latest
32+ steps :
33+ - name : Checkout
34+ uses : actions/checkout@v6
2035 with :
21- dotnet-version : 9.0.x
36+ fetch-depth : 0
2237
2338 - uses : actions/cache@v4
2439 with :
2540 path : ~/.nuget/packages
26- key : ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
41+ key : ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', 'Directory.Packages.props', 'nuget.config' ) }}
2742 restore-keys : |
2843 ${{ runner.os }}-nuget
2944
45+ - name : Setup .NET
46+ uses : actions/setup-dotnet@v5
47+
3048 - name : Set up JDK 17
3149 uses : actions/setup-java@v3
3250 with :
@@ -38,32 +56,18 @@ jobs:
3856 run : |
3957 dotnet workload install android
4058
41- - name : Check format
42- run : |
43- dotnet tool restore
44- dotnet csharpier check .
45- - name : Restore dependencies
46- run : dotnet restore /p:EnableWindowsTargeting=true
59+ - name : Restore
60+ run : dotnet restore /p:EnableWindowsTargeting=true
4761 - name : Build
48- run : dotnet build --no-restore -- configuration Release /p:EnableWindowsTargeting=true
62+ run : dotnet build --configuration Release --no-restore /p:EnableWindowsTargeting=true
4963 - name : Test
50- run : dotnet test --no-build --configuration Release
51-
52- - if : github.event_name == 'push' && github.ref == 'refs/heads/main'
53- name : Get release version
54- id : semantic
55- uses : cycjimmy/semantic-release-action@v4
56- with :
57- dry_run : true
58- env :
59- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
64+ run : dotnet test --configuration Release --no-build --no-restore
6065
61- - if : github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.semantic.outputs.new_release_published == 'true'
62- name : Pack and push to nuget.org
66+ - name : Pack and push to nuget.org
6367 run : |
6468 for file_name in ./src/**/*.csproj; do
65- dotnet pack $file_name --configuration Release --artifacts-path build/noncommercial /p:PackageLicenseFile=LICENSE.md /p:Version=${{ steps.semantic .outputs.new_release_version }}
66- dotnet pack $file_name --configuration Release --artifacts-path build/commercial /p:PackageLicenseFile=LICENSE-COMMERCIAL.md /p:Version=${{ steps.semantic .outputs.new_release_version }}
69+ dotnet pack $file_name --configuration Release --artifacts-path build/noncommercial /p:PackageLicenseFile=LICENSE.md /p:Version=${{ needs.release-please .outputs.version }}
70+ dotnet pack $file_name --configuration Release --artifacts-path build/commercial /p:PackageLicenseFile=LICENSE-COMMERCIAL.md /p:Version=${{ needs.release-please .outputs.version }}
6771 done
6872 for pkg_name in ./build/noncommercial/package**/*.nupkg; do
6973 dotnet nuget push $pkg_name --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
7579 env :
7680 AZURE_ARTIFACTS_FEED_URL : https://pkgs.dev.azure.com/rosslight-engineering/darp.ble/_packaging/darp.ble.subscription/nuget/v3/index.json
7781
78- - if : github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.semantic.outputs.new_release_published == 'true'
79- name : Semantic Release
80- id : release
81- uses : cycjimmy/semantic-release-action@v4
82- with :
83- extra_plugins : |
84- @semantic-release/commit-analyzer
85- @semantic-release/release-notes-generator
86- @semantic-release/github
82+ - name : Attach .nupkg to GitHub Release
8783 env :
88- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
84+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
85+ run : |
86+ gh release upload "${{ needs.release-please.outputs.tag_name }}" ./build/noncommercial/package**/*.nupkg \
87+ --repo "${{ github.repository }}"
0 commit comments