1- name : .NET
1+ name : Sync Service Build and Release
22
33on :
4-
4+ workflow_dispatch :
5+ workflow_run :
6+ branches : [ "main" ]
7+ workflows : ["SDK Build and Release"]
8+ types :
9+ - completed
10+
511 push :
612 branches : [ "main" ]
713 paths :
8- - ' Kepware.Api/**'
9- - ' Kepware.Api.Sample/**'
1014 - ' KepwareSync.Service/**'
11- - ' .github/workflows/dotnet .yml'
15+ # - '.github/workflows/syncservice-build .yml'
1216 - ' !**/*.md' # Exclude markdown files
1317 pull_request :
1418 branches : [ "main" ]
1519 paths :
16- - ' Kepware.Api/**'
17- - ' Kepware.Api.Sample/**'
1820 - ' KepwareSync.Service/**'
19- - ' .github/workflows/dotnet .yml'
20- - ' !*.md' # Exclude markdown files
21+ # - '.github/workflows/syncservice-build .yml'
22+ - ' !**/* .md' # Exclude markdown files
2123
2224jobs :
25+ draft-release :
26+ runs-on : ubuntu-latest
27+ env :
28+ PRODUCT : Kepware Sync Service
29+ outputs :
30+ tag_name : ${{ steps.drafter.outputs.tag_name }}
31+ version : ${{ steps.nbgv.outputs.SemVer2 }}
32+ steps :
33+ - uses : actions/checkout@v4
34+ with :
35+ fetch-depth : 0 # avoid shallow clone so nbgv can do its work.
36+ - uses : dotnet/nbgv@master
37+ id : nbgv
38+ with :
39+ path : ./KepwareSync.Service
40+ setAllVars : true
41+ - name : Use Release Drafter
42+ if : ${{ github.event_name != 'pull_request'}}
43+ id : drafter
44+ uses : release-drafter/release-drafter@v6.1.0
45+ with :
46+ config-name : syncservice-release-drafter.yml
47+ version : ${{ steps.nbgv.outputs.SemVer2 }}
48+ name : ${{ env.PRODUCT }} v${{ steps.nbgv.outputs.SemVer2 }}
49+ env :
50+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2351 build :
2452 strategy :
2553 matrix :
@@ -31,69 +59,43 @@ jobs:
3159 packages : write
3260 actions : read
3361 checks : write
62+ needs : draft-release
63+ env :
64+ tag_name : ${{ needs.draft-release.outputs.tag_name }}
65+ version : ${{ needs.draft-release.outputs.version }}
3466 steps :
3567 - uses : actions/checkout@v4
3668 with :
3769 fetch-depth : 0 # avoid shallow clone so nbgv can do its work.
38- - uses : dotnet/nbgv@master
39- id : nbgv
40- with :
41- setAllVars : true
42- - name : Use Release Drafter
43- if : ${{ github.event_name != 'pull_request' && matrix.platform == 'ubuntu' }}
44- id : drafter
45- uses : release-drafter/release-drafter@v6
46- with :
47- version : ${{ steps.nbgv.outputs.SemVer2 }}
48- env :
49- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5070 - name : Setup .NET
5171 uses : actions/setup-dotnet@v4
5272 with :
5373 dotnet-version : 9.0.x
5474 - name : Restore dependencies
5575 run : dotnet restore
5676 - name : Build
57- run : dotnet build --no-restore --configuration release
58- - name : Test
59- run : dotnet test Kepware.Api.Test/Kepware.Api.Test.csproj --no-build --verbosity normal --configuration Release --logger "trx;LogFileName=${{ matrix.platform }}-test-results.trx"
60- - name : Publish Test Report (${{ matrix.platform }})
61- if : ${{ github.event_name == 'pull_request' }}
62- uses : dorny/test-reporter@v1
63- with :
64- name : .NET 9 Test Report (${{ matrix.platform }})
65- path : " **/TestResults/**/*.trx"
66- reporter : dotnet-trx
77+ run : dotnet build ./KepwareSync.Service/Kepware.SyncService.csproj --no-restore --configuration release
6778 - name : dotnet publish
68- run : dotnet publish KepwareSync.Service/Kepware.SyncService.csproj --configuration release -o publish /p:UseAppHost=true
69-
70- - name : Push to GitHub Packages
71- if : ${{ github.event_name != 'pull_request' && matrix.platform == 'ubuntu' }}
72- run : |
73- dotnet nuget push ./Kepware.Api/bin/Release/*.nupkg \
74- --api-key ${{ secrets.GITHUB_TOKEN }} \
75- --skip-duplicate \
76- --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
77-
79+ run : dotnet publish ./KepwareSync.Service/Kepware.SyncService.csproj --configuration release -o publish /p:UseAppHost=true
7880 - name : Create and Upload Release Asset (Linux)
7981 if : ${{ github.event_name != 'pull_request' && matrix.platform == 'ubuntu' }}
8082 run : |
8183 # Create the ZIP file with only the required files
82- zip -j Kepware.SyncService-linux-x64.zip \
84+ zip -j Kepware.SyncService-${{ env.version }}- linux-x64.zip \
8385 $(find . -path '**/publish/Kepware.SyncService') \
8486 $(find . -path '**/publish/Kepware.SyncService.dbg') \
8587 $(find . -path '**/publish/appsettings.json')
8688 # Upload the ZIP file
87- gh release upload v ${{ steps.nbgv.outputs.SemVer2 }} Kepware.SyncService-linux-x64.zip --clobber
89+ gh release upload ${{env.tag_name }} Kepware.SyncService-${{ env.version }} -linux-x64.zip --clobber
8890 env :
8991 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
9092
9193 - name : Create and Upload Release Asset (Windows)
9294 if : ${{ github.event_name != 'pull_request' && matrix.platform == 'windows' }}
9395 run : |
9496 # Create the ZIP file with only the required files
95- Compress-Archive -Path @(".\publish\Kepware.SyncService.exe",".\publish\Kepware.SyncService.pdb", ".\publish\appsettings.json") -DestinationPath Kepware.SyncService-win-x64.zip
97+ Compress-Archive -Path @(".\publish\Kepware.SyncService.exe",".\publish\Kepware.SyncService.pdb", ".\publish\appsettings.json") -DestinationPath Kepware.SyncService-${{ env.version }}- win-x64.zip
9698 # Upload the ZIP file
97- gh release upload v ${{ steps.nbgv.outputs.SemVer2 }} Kepware.SyncService-win-x64.zip --clobber
99+ gh release upload ${{env.tag_name }} Kepware.SyncService-${{ env.version }} -win-x64.zip --clobber
98100 env :
99101 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments