diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index df05732..56fb2b5 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,5 +1,6 @@ -name-template: 'v$RESOLVED_VERSION' +name-template: 'Kepware.Api SDK v$RESOLVED_VERSION' tag-template: 'v$RESOLVED_VERSION' +tag-prefix: 'Kepware.Api/' commitish: refs/heads/main version-resolver: major: diff --git a/.github/syncservice-release-drafter.yml b/.github/syncservice-release-drafter.yml new file mode 100644 index 0000000..9b19806 --- /dev/null +++ b/.github/syncservice-release-drafter.yml @@ -0,0 +1,33 @@ +name-template: 'Kepware SyncService v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' +tag-prefix: 'SyncService/' +commitish: refs/heads/main +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: patch +categories: + - title: '🚀 Features' + labels: + - 'feature' + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: '🧰 Maintenance' + label: 'chore' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +template: | + ## Changes + + $CHANGES diff --git a/.github/workflows/docfx-build-and-push.yml b/.github/workflows/docfx-build-and-push.yml index 37724e2..9148c73 100644 --- a/.github/workflows/docfx-build-and-push.yml +++ b/.github/workflows/docfx-build-and-push.yml @@ -5,22 +5,13 @@ name: Docfx Builder and Publisher for Web Pages on: workflow_dispatch: push: - branches: [ "main" ] + branches: [ "test" ] paths: - 'Kepware.Api/**' - 'Kepware.Api.Sample/**' - 'KepwareSync.Service/**' - 'docs/docfx/**' - '.github/workflows/dotnet.yml' - # - '!**/*.md' Exclude markdown files - # pull_request: - # branches: [ "main" ] - # paths: - # - 'Kepware.Api/**' - # - 'Kepware.Api.Sample/**' - # - 'KepwareSync.Service/**' - # - '.github/workflows/dotnet.yml' - # - '!*.md' # Exclude markdown files # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: diff --git a/.github/workflows/docker-build-and-push.yml b/.github/workflows/docker-build-and-push.yml index 4a3a8c0..8d53771 100644 --- a/.github/workflows/docker-build-and-push.yml +++ b/.github/workflows/docker-build-and-push.yml @@ -1,11 +1,12 @@ name: Container Image on: + workflow_dispatch: push: branches: - main paths: - - 'Kepware.Api/**' + # - 'Kepware.Api/**' - 'KepwareSync.Service/**' - '.github/workflows/docker-build-and-push.yml' - '!**/*.md' # Exclude markdown files diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 79887d6..45e1fc1 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -1,13 +1,13 @@ -name: .NET +name: SDK Build and Release on: - + workflow_dispatch: push: branches: [ "main" ] paths: - 'Kepware.Api/**' - 'Kepware.Api.Sample/**' - - 'KepwareSync.Service/**' + # - 'KepwareSync.Service/**' - '.github/workflows/dotnet.yml' - '!**/*.md' # Exclude markdown files pull_request: @@ -15,7 +15,7 @@ on: paths: - 'Kepware.Api/**' - 'Kepware.Api.Sample/**' - - 'KepwareSync.Service/**' + # - 'KepwareSync.Service/**' - '.github/workflows/dotnet.yml' - '!*.md' # Exclude markdown files @@ -38,6 +38,7 @@ jobs: - uses: dotnet/nbgv@master id: nbgv with: + path: ./Kepware.Api setAllVars: true - name: Use Release Drafter if: ${{ github.event_name != 'pull_request' && matrix.platform == 'ubuntu' }} @@ -64,8 +65,8 @@ jobs: name: .NET 9 Test Report (${{ matrix.platform }}) path: "**/TestResults/**/*.trx" reporter: dotnet-trx - - name: dotnet publish - run: dotnet publish KepwareSync.Service/Kepware.SyncService.csproj --configuration release -o publish /p:UseAppHost=true + # - name: dotnet publish + # run: dotnet publish KepwareSync.Service/Kepware.SyncService.csproj --configuration release -o publish /p:UseAppHost=true - name: Push to GitHub Packages if: ${{ github.event_name != 'pull_request' && matrix.platform == 'ubuntu' }} @@ -74,26 +75,10 @@ jobs: --api-key ${{ secrets.GITHUB_TOKEN }} \ --skip-duplicate \ --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" - - name: Create and Upload Release Asset (Linux) if: ${{ github.event_name != 'pull_request' && matrix.platform == 'ubuntu' }} run: | - # Create the ZIP file with only the required files - zip -j Kepware.SyncService-linux-x64.zip \ - $(find . -path '**/publish/Kepware.SyncService') \ - $(find . -path '**/publish/Kepware.SyncService.dbg') \ - $(find . -path '**/publish/appsettings.json') - # Upload the ZIP file - gh release upload v${{ steps.nbgv.outputs.SemVer2 }} Kepware.SyncService-linux-x64.zip --clobber - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create and Upload Release Asset (Windows) - if: ${{ github.event_name != 'pull_request' && matrix.platform == 'windows' }} - run: | - # Create the ZIP file with only the required files - Compress-Archive -Path @(".\publish\Kepware.SyncService.exe",".\publish\Kepware.SyncService.pdb", ".\publish\appsettings.json") -DestinationPath Kepware.SyncService-win-x64.zip - # Upload the ZIP file - gh release upload v${{ steps.nbgv.outputs.SemVer2 }} Kepware.SyncService-win-x64.zip --clobber + # Upload the NuGet package + gh release upload ${{ steps.drafter.outputs.tag_name }} ./Kepware.Api/bin/Release/*.nupkg --clobber env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/syncservice.yml b/.github/workflows/syncservice.yml new file mode 100644 index 0000000..6bf2c9c --- /dev/null +++ b/.github/workflows/syncservice.yml @@ -0,0 +1,79 @@ +name: Sync Service Build and Release + +on: + workflow_dispatch: + push: + branches: [ "main" ] + paths: + - 'KepwareSync.Service/**' + - '.github/workflows/syncservice.yml' + - '!**/*.md' # Exclude markdown files + pull_request: + branches: [ "main" ] + paths: + - 'KepwareSync.Service/**' + - '.github/workflows/syncservice.yml' + - '!**/*.md' # Exclude markdown files + +jobs: + build: + strategy: + matrix: + platform: [windows, ubuntu] + runs-on: ${{ matrix.platform }}-latest + permissions: + contents: write + pull-requests: write + packages: write + actions: read + checks: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # avoid shallow clone so nbgv can do its work. + - uses: dotnet/nbgv@master + id: nbgv + with: + path: ./KepwareSync.Service + setAllVars: true + - name: Use Release Drafter + if: ${{ github.event_name != 'pull_request'}} + id: drafter + uses: release-drafter/release-drafter@v6 + with: + config-name: syncservice-release-drafter.yml + version: ${{ steps.nbgv.outputs.SemVer2 }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build ./KepwareSync.Service/Kepware.SyncService.csproj --no-restore --configuration release + - name: dotnet publish + run: dotnet publish ./KepwareSync.Service/Kepware.SyncService.csproj --configuration release -o publish /p:UseAppHost=true + - name: Create and Upload Release Asset (Linux) + if: ${{ github.event_name != 'pull_request' && matrix.platform == 'ubuntu' }} + run: | + # Create the ZIP file with only the required files + zip -j Kepware.SyncService-linux-x64.zip \ + $(find . -path '**/publish/Kepware.SyncService') \ + $(find . -path '**/publish/Kepware.SyncService.dbg') \ + $(find . -path '**/publish/appsettings.json') + # Upload the ZIP file + gh release upload ${{ steps.drafter.outputs.tag_name }} Kepware.SyncService-linux-x64.zip --clobber + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create and Upload Release Asset (Windows) + if: ${{ github.event_name != 'pull_request' && matrix.platform == 'windows' }} + run: | + # Create the ZIP file with only the required files + Compress-Archive -Path @(".\publish\Kepware.SyncService.exe",".\publish\Kepware.SyncService.pdb", ".\publish\appsettings.json") -DestinationPath Kepware.SyncService-win-x64.zip + # Upload the ZIP file + gh release upload ${{ steps.drafter.outputs.tag_name }} Kepware.SyncService-win-x64.zip --clobber + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Kepware.Api/KepwareApiClient.cs b/Kepware.Api/KepwareApiClient.cs index 2c8d91a..19dad39 100644 --- a/Kepware.Api/KepwareApiClient.cs +++ b/Kepware.Api/KepwareApiClient.cs @@ -93,6 +93,8 @@ public partial class KepwareApiClient : IKepwareDefaultValueProvider public KepwareApiClient(KepwareApiClientOptions options, ILoggerFactory loggerFactory, HttpClient httpClient) : this(UNKNOWN, options, loggerFactory, httpClient) { + m_logger.LogInformation("Created KepwareApiClient instance with name {ClientName} at {BaseAddress}", ClientName, m_httpClient.BaseAddress); + m_logger.LogInformation("KepwareApiClient instance created successfully."); } internal KepwareApiClient(string name, KepwareApiClientOptions options, ILoggerFactory loggerFactory, HttpClient httpClient) diff --git a/version.json b/Kepware.Api/version.json similarity index 93% rename from version.json rename to Kepware.Api/version.json index e795754..a635fc5 100644 --- a/version.json +++ b/Kepware.Api/version.json @@ -1,6 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", "version": "1.0-beta", + "pathFilters": ["."], "publicReleaseRefSpec": [ "^refs/heads/main$", "^refs/heads/v\\d+(?:\\.\\d+)?$" diff --git a/KepwareSync.Service/Program.cs b/KepwareSync.Service/Program.cs index c98829f..26b407b 100644 --- a/KepwareSync.Service/Program.cs +++ b/KepwareSync.Service/Program.cs @@ -21,10 +21,10 @@ static Task Main(string[] args) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables(); - + var configuration = cfgBuilder.Build(); builder.Configuration.AddConfiguration(configuration); - + Console.WriteLine("Dumb stuff"); var app = new AppRunner(builder); // Binder diff --git a/KepwareSync.Service/version.json b/KepwareSync.Service/version.json new file mode 100644 index 0000000..a635fc5 --- /dev/null +++ b/KepwareSync.Service/version.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", + "version": "1.0-beta", + "pathFilters": ["."], + "publicReleaseRefSpec": [ + "^refs/heads/main$", + "^refs/heads/v\\d+(?:\\.\\d+)?$" + ], + "cloudBuild": { + "buildNumber": { + "enabled": true + } + }, + "release": { + "tagName": "v{version}" + } +} \ No newline at end of file