Skip to content

Update

Update #63

Workflow file for this run

name: SDK Build and Release
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- 'Kepware.Api/**'
- 'Kepware.Api.Sample/**'
# - 'KepwareSync.Service/**'
- '.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
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: ./Kepware.Api
setAllVars: true
- name: Use Release Drafter
if: ${{ github.event_name != 'pull_request' && matrix.platform == 'ubuntu' }}
id: drafter
uses: release-drafter/release-drafter@v6
with:
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 --no-restore --configuration release
- name: Test
run: dotnet test Kepware.Api.Test/Kepware.Api.Test.csproj --no-build --verbosity normal --configuration Release --logger "trx;LogFileName=${{ matrix.platform }}-test-results.trx"
- name: Publish Test Report (${{ matrix.platform }})
if: ${{ github.event_name == 'pull_request' }}
uses: dorny/test-reporter@v1
with:
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: Push to GitHub Packages
if: ${{ github.event_name != 'pull_request' && matrix.platform == 'ubuntu' }}
run: |
dotnet nuget push ./Kepware.Api/bin/Release/*.nupkg \
--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: |
# Upload the NuGet package
gh release upload ${{ steps.drafter.outputs.tag_name }} ./Kepware.Api/bin/Release/*.nupkg --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}