Skip to content

splited ci

splited ci #24

name: Test and Publish to NuGet
on: push
# release:
# types: [published]
jobs:
# Job for running tests
test:
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 # 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: Build project
working-directory: ./src/permit
run: dotnet build --configuration Release
- 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