diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml new file mode 100644 index 0000000..349473d --- /dev/null +++ b/.github/workflows/ci-cd.yml @@ -0,0 +1,73 @@ +name: CI/CD Pipeline + +on: + push: + branches: [ main ] + tags: + - 'v*.*.*' + pull_request: + branches: [ main ] + +jobs: + test: + name: Run Integration Tests + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET SDK + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 9.0.x + 10.0.x + + - name: Restore dependencies + run: dotnet restore src/IlyaKo.AspNet.SideAuth.slnx + + - name: Build solution + run: dotnet build src/IlyaKo.AspNet.SideAuth.slnx --configuration Release --no-restore + + - name: Run Integration Tests + run: | + dotnet run --project src/IlyaKo.AspNet.SideAuth.IntegrationTests/IlyaKo.AspNet.SideAuth.IntegrationTests.csproj \ + --configuration Release \ + --no-build + + release: + name: Pack & Publish NuGet + needs: test + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET SDK + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10.0.x + + - name: Pack NuGet Package + run: dotnet pack src/IlyaKo.AspNet.SideAuth/IlyaKo.AspNet.SideAuth.csproj --configuration Release --output ./output + + - name: Extract Version from Tag + id: get_version + run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV + + - name: Pack NuGet Package + run: | + dotnet pack src/IlyaKo.AspNet.SideAuth/IlyaKo.AspNet.SideAuth.csproj \ + --configuration Release \ + --output ./output \ + /p:PackageVersion=${{ env.VERSION }} \ + /p:Version=${{ env.VERSION }} + + - name: Push to NuGet.org + run: | + dotnet nuget push ./output/*.nupkg \ + --api-key ${{ secrets.NUGET_API_KEY }} \ + --source https://api.nuget.org/v3/index.json \ + --skip-duplicate diff --git a/src/IlyaKo.AspNet.SideAuth.IntegrationTests/IlyaKo.AspNet.SideAuth.IntegrationTests.csproj b/src/IlyaKo.AspNet.SideAuth.IntegrationTests/IlyaKo.AspNet.SideAuth.IntegrationTests.csproj index 68842fe..e858f5e 100644 --- a/src/IlyaKo.AspNet.SideAuth.IntegrationTests/IlyaKo.AspNet.SideAuth.IntegrationTests.csproj +++ b/src/IlyaKo.AspNet.SideAuth.IntegrationTests/IlyaKo.AspNet.SideAuth.IntegrationTests.csproj @@ -8,6 +8,7 @@ true true $(InterceptorsNamespaces);Microsoft.AspNetCore.OpenApi.Generated + true