-
Notifications
You must be signed in to change notification settings - Fork 3
83 lines (73 loc) · 2.95 KB
/
ci.yml
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
name: Build and Publish NuGet Package
on:
push:
branches:
- master
paths-ignore:
- "README.md"
- "LICENSE"
- "docs/**"
- ".github/workflows/jobs-example.yml"
jobs:
# Based on the example from https://how.wtf/run-workflow-step-or-job-based-on-file-changes-github-actions.html
changes:
runs-on: ubuntu-latest
outputs:
version-changed: ${{ steps.changes.outputs.changed }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
changed:
- "Directory.Build.props"
build-and-test:
runs-on: ubuntu-latest
outputs:
nuget-package-path: ${{ steps.publish.outputs.NUGET_PACKAGE_PATH }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.401
- name: Restore NuGet packages
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
# - name: Test (this will run for several minutes)
# run: dotnet test --configuration Release --no-restore --no-build --verbosity normal
- name: Create NuGet package
id: publish
run: |
dotnet pack --configuration Release --no-build --no-restore
NUPKG_PATH=$(find . -name '*.nupkg' -type f -execdir readlink -f {} \;)
echo "NuGet package path: $NUPKG_PATH"
echo "NUGET_PACKAGE_PATH=$(find . -name '*.nupkg' -print -quit)"
echo "NUGET_PACKAGE_PATH=$(find . -name '*.nupkg' -print -quit)" >> "$GITHUB_OUTPUT"
- name: print env variable
id: print-env
env:
NUGET_PACKAGE_PATH: ${{ steps.publish.outputs.NUGET_PACKAGE_PATH }}
run: |
echo "NUGET_PACKAGE_PATH=$NUGET_PACKAGE_PATH"
deploy:
needs:
- changes
- build-and-test
runs-on: ubuntu-latest
if: ${{ needs.changes.outputs.version-changed == 'true' }}
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && github.event.head_commit.modified || contains('Directory.Build.props') }}
steps:
- name: Publish NuGet package
env:
NUGET_PACKAGE_PATH: ${{ needs.build-and-test.outputs.nuget-package-path }}
run: |
echo "NuGet package path: $NUGET_PACKAGE_PATH"
echo "NUGET_PACKAGE_PATH=$(find . -name '*.nupkg' -print -quit)"
dotnet nuget push $NUGET_PACKAGE_PATH --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
# run: |
# echo "NuGet package path: $NUGET_PACKAGE_PATH"
# echo "Placeholder for publishing NuGet package"