|
| 1 | +# Publishes beta-versions only |
| 2 | +name: Publish Package |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Check .NET 8 |
| 12 | + id: check-dotnet8 |
| 13 | + run: | |
| 14 | + DOTNET8_VERSION=$(dotnet --version) |
| 15 | + if [[ "$DOTNET8_VERSION" =~ ^8\.0\.[0-9]+$ ]]; then |
| 16 | + echo "dotnet8_installed=true" >> $GITHUB_ENV |
| 17 | + else |
| 18 | + echo "dotnet8_installed=false" >> $GITHUB_ENV |
| 19 | + fi |
| 20 | + - name: Setup .NET 8 |
| 21 | + if: env.dotnet8_installed == 'false' |
| 22 | + uses: actions/setup-dotnet@v4 |
| 23 | + with: |
| 24 | + dotnet-version: 8.0.x |
| 25 | + dotnet-quality: 'ga' |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + - name: Restore |
| 29 | + run: dotnet restore ./Ocelot.Administration.IdentityServer4.sln -p:TargetFramework=net8.0 |
| 30 | + - name: Build |
| 31 | + run: dotnet build --no-restore ./Ocelot.Administration.IdentityServer4.sln --framework net8.0 |
| 32 | + - name: Unit tests |
| 33 | + run: dotnet test --no-restore --no-build ./unit/Ocelot.Administration.IdentityServer4.UnitTests.csproj --collect:"XPlat Code Coverage" --framework net8.0 |
| 34 | + - name: Acceptance tests |
| 35 | + run: dotnet test --no-restore --no-build ./acceptance/Ocelot.Administration.IdentityServer4.AcceptanceTests.csproj --framework net8.0 |
| 36 | + - name: Find coverage file # https://reportgenerator.io/ |
| 37 | + id: coverage |
| 38 | + run: | |
| 39 | + echo "GITHUB REF is ${{ github.ref }}" |
| 40 | + echo "GITHUB REF NAME is ${{ github.ref_name }}" |
| 41 | + echo "GITHUB SHA is ${{ github.sha }}" |
| 42 | + coverage_1st_folder=$(ls -d ./unit/TestResults/*/ | head -1) |
| 43 | + echo "Detected first folder : $coverage_1st_folder" |
| 44 | + coverage_file="${coverage_1st_folder%/}/coverage.cobertura.xml" |
| 45 | + echo "Detecting coverage file... -> $coverage_file" |
| 46 | + if [ -f "$coverage_file" ]; then |
| 47 | + echo "Coverage file exists." |
| 48 | + echo "FILE_EXISTS=true" >> $GITHUB_OUTPUT |
| 49 | + echo "COVERAGE_FILE=$coverage_file" >> $GITHUB_OUTPUT |
| 50 | + else |
| 51 | + echo "Coverage file DOES NOT exist!" |
| 52 | + echo "FILE_EXISTS=false" >> $GITHUB_OUTPUT |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | + # dotnet tool restore |
| 56 | + # dotnet tool run reportgenerator -reports:$coverage_file -targetdir:coveragereport |
| 57 | + - name: Generate coverage report (HTML) |
| 58 | + if: steps.coverage.outputs.FILE_EXISTS == 'true' |
| 59 | + uses: danielpalme/ReportGenerator-GitHub-Action@5.4.7 # Docs: https://github.com/marketplace/actions/reportgenerator |
| 60 | + with: |
| 61 | + reports: ${{ steps.coverage.outputs.COVERAGE_FILE }} |
| 62 | + targetdir: coveragereport |
| 63 | + reporttypes: Html |
| 64 | + - name: Generate coverage report (Markdown) |
| 65 | + if: steps.coverage.outputs.FILE_EXISTS == 'true' |
| 66 | + uses: danielpalme/ReportGenerator-GitHub-Action@5.4.7 # Docs: https://github.com/marketplace/actions/reportgenerator |
| 67 | + with: |
| 68 | + reports: ${{ steps.coverage.outputs.COVERAGE_FILE }} |
| 69 | + targetdir: coveragereport-md |
| 70 | + reporttypes: MarkdownSummaryGithub |
| 71 | + - name: List report files |
| 72 | + run: | |
| 73 | + find coveragereport -type f -print |
| 74 | + find coveragereport-md -type f -print |
| 75 | +
|
| 76 | + # build2: |
| 77 | + # runs-on: ubuntu-latest |
| 78 | + # permissions: |
| 79 | + # packages: write |
| 80 | + # contents: read |
| 81 | + # steps: |
| 82 | + # - name: Checkout repository |
| 83 | + # uses: actions/checkout@v4 |
| 84 | + |
| 85 | + # - name: Setup .NET |
| 86 | + # uses: actions/setup-dotnet@v4 |
| 87 | + # with: |
| 88 | + # dotnet-version: | |
| 89 | + # 8.0.x |
| 90 | + # 9.0.x |
| 91 | + |
| 92 | + # - name: .NET Info |
| 93 | + # run: dotnet --info |
| 94 | + |
| 95 | + # - name: Restore dependencies |
| 96 | + # run: dotnet restore ./Ocelot.Administration.IdentityServer4.sln |
| 97 | + |
| 98 | + # - name: Build project |
| 99 | + # run: dotnet build ./src/Ocelot.Testing.csproj --configuration Release --no-restore |
| 100 | + |
| 101 | + # - name: Pack project |
| 102 | + # run: dotnet pack ./src/Ocelot.Testing.csproj --configuration Release --output ./packages |
| 103 | + |
| 104 | + # - name: Publish to GitHub Packages |
| 105 | + # run: dotnet nuget push ./packages/*.nupkg --source "https://nuget.pkg.github.com/ThreeMammals/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate |
| 106 | + |
| 107 | + # - name: Publish to NuGet |
| 108 | + # run: dotnet nuget push ./packages/*.nupkg --source "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NUGET_API_KEY_2025 }} --skip-duplicate |
0 commit comments