Skip to content

Commit 4300819

Browse files
authored
Merge pull request #51 from PTCInc/46-chore-version-strategy-and-workflow-for-versioning-syncservice
chore(version): strategy and workflow for versioning
2 parents f839d03 + 4e4724c commit 4300819

5 files changed

Lines changed: 210 additions & 49 deletions

File tree

.github/nuget-release-drafter.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# name-template: 'Kepware.Api SDK v$RESOLVED_VERSION'
2+
tag-template: 'Kepware.Api_v$RESOLVED_VERSION'
3+
tag-prefix: 'Kepware.Api_'
4+
commitish: refs/heads/main
5+
version-resolver:
6+
major:
7+
labels:
8+
- 'major'
9+
minor:
10+
labels:
11+
- 'minor'
12+
patch:
13+
labels:
14+
- 'patch'
15+
default: patch
16+
categories:
17+
- title: '🚀 Features'
18+
labels:
19+
- 'feature'
20+
- 'enhancement'
21+
- title: '🐛 Bug Fixes'
22+
labels:
23+
- 'fix'
24+
- 'bugfix'
25+
- 'bug'
26+
- title: '🧰 Maintenance'
27+
label: 'chore'
28+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
29+
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
30+
template: |
31+
## Changes
32+
33+
$CHANGES
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
name-template: 'v$RESOLVED_VERSION'
2-
tag-template: 'v$RESOLVED_VERSION'
1+
# name-template: 'v$RESOLVED_VERSION'
2+
tag-template: 'SyncService_v$RESOLVED_VERSION'
3+
tag-prefix: 'SyncService_'
34
commitish: refs/heads/main
45
version-resolver:
56
major:

.github/workflows/docker-build-and-push.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
name: Container Image
22

33
on:
4+
workflow_dispatch:
5+
workflow_run:
6+
branches: [ "main" ]
7+
workflows: ["Sync Service Build and Release"]
8+
types:
9+
- completed
410
push:
511
branches:
612
- main
713
paths:
8-
- 'Kepware.Api/**'
14+
# - 'Kepware.Api/**'
915
- 'KepwareSync.Service/**'
10-
- '.github/workflows/docker-build-and-push.yml'
16+
# - '.github/workflows/docker-build-and-push.yml'
1117
- '!**/*.md' # Exclude markdown files
1218

1319
jobs:
@@ -24,6 +30,7 @@ jobs:
2430
- uses: dotnet/nbgv@master
2531
id: nbgv
2632
with:
33+
path: ./KepwareSync.Service
2734
setAllVars: true
2835

2936
- name: Set up QEMU
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: SDK Build and Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ "main" ]
7+
paths:
8+
- 'Kepware.Api/**'
9+
# - 'Kepware.Api.Sample/**'
10+
# - 'KepwareSync.Service/**'
11+
# - '.github/workflows/nuget-test-and-build.yml'
12+
- '!**/*.md' # Exclude markdown files
13+
pull_request:
14+
branches: [ "main" ]
15+
paths:
16+
- 'Kepware.Api/**'
17+
# - 'Kepware.Api.Sample/**'
18+
# - 'KepwareSync.Service/**'
19+
# - '.github/workflows/nuget-test-and-build.yml'
20+
- '!*.md' # Exclude markdown files
21+
22+
jobs:
23+
draft-release:
24+
# Draft the release notes
25+
runs-on: ubuntu-latest
26+
env:
27+
PRODUCT: Kepware.Api SDK
28+
outputs:
29+
tag_name: ${{ steps.drafter.outputs.tag_name }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
34+
- uses: dotnet/nbgv@master
35+
id: nbgv
36+
with:
37+
path: ./Kepware.Api
38+
setAllVars: true
39+
- name: Use Release Drafter
40+
if: ${{ github.event_name != 'pull_request'}}
41+
id: drafter
42+
uses: release-drafter/release-drafter@v6.1.0
43+
with:
44+
config-name: nuget-release-drafter.yml
45+
version: ${{ steps.nbgv.outputs.SemVer2 }}
46+
name: ${{ env.PRODUCT }} v${{ steps.nbgv.outputs.SemVer2 }}
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
build:
50+
# Build and test on both Windows and Ubuntu
51+
strategy:
52+
matrix:
53+
platform: [windows, ubuntu]
54+
runs-on: ${{ matrix.platform }}-latest
55+
permissions:
56+
contents: write
57+
pull-requests: write
58+
packages: write
59+
actions: read
60+
checks: write
61+
needs: draft-release
62+
env:
63+
tag_name: ${{ needs.draft-release.outputs.tag_name }}
64+
steps:
65+
- uses: actions/checkout@v4
66+
with:
67+
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
68+
- name: Setup .NET
69+
uses: actions/setup-dotnet@v4
70+
with:
71+
dotnet-version: 9.0.x
72+
- name: Restore dependencies
73+
run: dotnet restore
74+
- name: Build
75+
run: dotnet build --no-restore --configuration release
76+
- name: Test
77+
run: dotnet test Kepware.Api.Test/Kepware.Api.Test.csproj --no-build --verbosity normal --configuration Release --logger "trx;LogFileName=${{ matrix.platform }}-test-results.trx"
78+
- name: Publish Test Report (${{ matrix.platform }})
79+
if: ${{ github.event_name == 'pull_request' }}
80+
uses: dorny/test-reporter@v1
81+
with:
82+
name: .NET 9 Test Report (${{ matrix.platform }})
83+
path: "**/TestResults/**/*.trx"
84+
reporter: dotnet-trx
85+
- name: store NuGet package
86+
if: ${{ github.event_name != 'pull_request' && matrix.platform == 'ubuntu' }}
87+
uses: actions/upload-artifact@v5
88+
with:
89+
name: nuget-package-${{ matrix.platform }}
90+
path: ./Kepware.Api/bin/Release/*.nupkg
91+
publish:
92+
# Publish the NuGet package and create release assets
93+
runs-on: ubuntu-latest
94+
needs: [ build, draft-release ]
95+
env:
96+
tag_name: ${{ needs.draft-release.outputs.tag_name }}
97+
steps:
98+
- uses: actions/checkout@v4
99+
with:
100+
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
101+
- name: Download NuGet package
102+
uses: actions/download-artifact@v6
103+
with:
104+
name: nuget-package-ubuntu
105+
- name: Push to GitHub Packages
106+
if: ${{ github.event_name != 'pull_request' }}
107+
run: |
108+
dotnet nuget push *.nupkg \
109+
--api-key ${{ secrets.GITHUB_TOKEN }} \
110+
--skip-duplicate \
111+
--source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
112+
- name: Create and Upload Release Asset (Linux)
113+
if: ${{ github.event_name != 'pull_request' }}
114+
run: |
115+
# Upload the NuGet package
116+
gh release upload ${{ env.tag_name }} *.nupkg --clobber
117+
env:
118+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,53 @@
1-
name: .NET
1+
name: Sync Service Build and Release
22

33
on:
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

2224
jobs:
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

Comments
 (0)