1.5.1-rc.1 #27
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |