-
Notifications
You must be signed in to change notification settings - Fork 2
143 lines (136 loc) · 4.93 KB
/
nuget-test-and-build.yml
File metadata and controls
143 lines (136 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: SDK Build and Release
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- 'Kepware.Api/**'
# - 'Kepware.Api.Sample/**'
# - 'KepwareSync.Service/**'
# - '.github/workflows/nuget-test-and-build.yml'
- '!**/*.md' # Exclude markdown files
pull_request:
branches: [ "main" ]
paths:
- 'Kepware.Api/**'
# - 'Kepware.Api.Sample/**'
# - 'KepwareSync.Service/**'
# - '.github/workflows/nuget-test-and-build.yml'
- '!**/*.md' # Exclude markdown files
jobs:
draft-release:
# Draft the release notes
runs-on: ubuntu-latest
env:
PRODUCT: Kepware.Api SDK
outputs:
tag_name: ${{ steps.drafter.outputs.tag_name }}
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'}}
id: drafter
uses: release-drafter/release-drafter@v6.1.0
with:
config-name: nuget-release-drafter.yml
version: ${{ steps.nbgv.outputs.SemVer2 }}
name: ${{ env.PRODUCT }} v${{ steps.nbgv.outputs.SemVer2 }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
# Build and test on both Windows and Ubuntu
strategy:
matrix:
platform: [windows, ubuntu]
runs-on: ${{ matrix.platform }}-latest
permissions:
contents: write
pull-requests: write
packages: write
actions: read
checks: write
needs: draft-release
env:
tag_name: ${{ needs.draft-release.outputs.tag_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration release
- name: Show current directory (debug)
run: |
echo "Current directory: $(pwd)"
- name: Show repo files (debug)
run: |
echo "Repo root: $(pwd)"
ls -la
echo "List _data:"
ls -la Kepware.Api.Test/_data || true
echo "List _data/projectLoadSerializeData:"
ls -la Kepware.Api.Test/_data/projectLoadSerializeData || true
- name: Build test project (debug)
run: dotnet build Kepware.Api.Test/Kepware.Api.Test.csproj -c Release
- name: Show build output (debug)
run: ls -la Kepware.Api.Test/bin/Release || true
- name: Show TFM outputs (debug)
run: ls -la Kepware.Api.Test/bin/Release/* || true
- name: Show test _data (debug)
run: ls -la Kepware.Api.Test/bin/Release/net8.0/_data || true
- name: Show test _data/projectLoadSerializeData (debug)
run: ls -la Kepware.Api.Test/bin/Release/net8.0/_data/projectLoadSerializeData || true
- name: Test
run: dotnet test Kepware.Api.Test/Kepware.Api.Test.csproj --no-build --verbosity normal --configuration Release --logger "trx;LogFilePrefix=${{ matrix.platform }}-test-results"
- name: Publish Test Reports (${{ matrix.platform }})
if: ${{ github.event_name == 'pull_request' }}
uses: dorny/test-reporter@v1
with:
name: .NET Test Reports (${{ matrix.platform }})
path: "**/TestResults/**/*.trx"
reporter: dotnet-trx
- name: store NuGet package
if: ${{ github.event_name != 'pull_request' && matrix.platform == 'ubuntu' }}
uses: actions/upload-artifact@v5
with:
name: nuget-package-${{ matrix.platform }}
path: ./Kepware.Api/bin/Release/*.nupkg
publish:
# Publish the NuGet package and create release assets
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
needs: [ build, draft-release ]
env:
tag_name: ${{ needs.draft-release.outputs.tag_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: Download NuGet package
uses: actions/download-artifact@v6
with:
name: nuget-package-ubuntu
- name: Push to GitHub Packages
if: ${{ github.event_name != 'pull_request' }}
run: |
dotnet nuget push *.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' }}
run: |
# Upload the NuGet package
gh release upload ${{ env.tag_name }} *.nupkg --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}