-
Notifications
You must be signed in to change notification settings - Fork 2
74 lines (60 loc) · 2.27 KB
/
dotnet-sdk-publish.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
name: Test and Publish to NuGet
on:
release:
types: [published]
jobs:
test-dotnet-sdk:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- name: Restore dependencies
working-directory: ./src/permit
run: dotnet restore
- name: Insert Token to tests file by secret API key
run: |
sed -i 's/private string testToken = "";/private string testToken = "${{ secrets.PERMIT_API_KEY }}";/' ./tests/PermitTests/PermitClientTests.cs
cat ./tests/PermitTests/PermitClientTests.cs
- name: Install Docker
uses: docker-practice/actions-setup-docker@master
- name: Run local PDP
env:
PDP_API_KEY: ${{ secrets.PERMIT_API_KEY }}
PERMIT_API_KEY: ${{ secrets.PERMIT_API_KEY }}
PDP_DEBUG: true
run: docker run -d -p 7766:7000 permitio/pdp-v2:latest
- name: Run Tests
working-directory: ./tests/PermitTests
run: dotnet test
# Job for building and publishing the NuGet package
build-and-publish:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: test-dotnet-sdk # Ensures the build runs only if the test job passes
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- name: Restore dependencies
working-directory: ./src/permit
run: dotnet restore
- name: Update VersionPrefix in .csproj
run: |
sed -i 's/<VersionPrefix>.*<\/VersionPrefix>/<VersionPrefix>${{ github.event.release.tag_name }}<\/VersionPrefix>/g' ./src/permit/PermitSDK.csproj
cat ./src/permit/PermitSDK.csproj
- name: Pack project
working-directory: ./src/permit
run: dotnet pack --configuration Release
- name: Push package to NuGet
working-directory: ./src/permit
run: dotnet nuget push bin/Release/Permit.${{ github.event.release.tag_name }}.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json