diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index ca8b1c2..533d07c 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -8,9 +8,6 @@ on: paths-ignore: - '**.md' -permissions: - contents: write - jobs: build: runs-on: ${{ matrix.os }} @@ -22,7 +19,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v6 with: - dotnet-version: | + dotnet-version: | 10.0.x - name: Check formatting run: dotnet format --verify-no-changes @@ -30,6 +27,8 @@ jobs: run: dotnet restore - name: Build run: dotnet build --configuration Release --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal --configuration Release - name: Publish SkiaSharpCompare.Cli (Linux) if: runner.os == 'Linux' @@ -55,67 +54,79 @@ jobs: path: ./artifacts/cli retention-days: 7 - - name: Test - run: dotnet test --no-build --verbosity normal --configuration Release + - name: Upload NuGet package + if: runner.os == 'Linux' + uses: actions/upload-artifact@v7 + with: + name: nuget-package + path: ./SkiaSharpCompare/bin/Release/*.*nupkg + if-no-files-found: error + retention-days: 7 deployRelease: if: startsWith(github.ref, 'refs/heads/release') - runs-on: ubuntu-latest needs: build + runs-on: ubuntu-latest + permissions: + contents: write # gh release create + id-token: write # NuGet Trusted Publishing (OIDC) steps: - - uses: actions/checkout@v7 - name: Setup .NET uses: actions/setup-dotnet@v6 with: - dotnet-version: | + dotnet-version: | 10.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --configuration Release --no-restore + - name: Download NuGet package + uses: actions/download-artifact@v8 + with: + name: nuget-package + path: ./nuget - name: Download CLI artifacts uses: actions/download-artifact@v8 with: - path: ./artifacts_download + pattern: cli-artifacts-* + path: ./artifacts_download + - name: NuGet login (Trusted Publishing) + uses: NuGet/login@v1 + id: nugetLogin + with: + user: ${{ secrets.NUGET_USER }} - name: NugetPush - env: - NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_TOKEN }} - if: env.NUGET_TOKEN_EXISTS != '' run: | - dotnet nuget push ./SkiaSharpCompare/bin/Release/*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TOKEN}} --source https://api.nuget.org/v3/index.json + dotnet nuget push ./nuget/*.nupkg --skip-duplicate --api-key ${{ steps.nugetLogin.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json - name: Github release shell: bash env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: env.GITHUB_TOKEN != '' + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - # Attach all downloaded CLI artifacts regardless of OS - zip -r cli-artifacts.zip ./artifacts_download - gh release create ${{env.CURRENT_VERSION}} ./SkiaSharpCompare/bin/Release/*.*nupkg cli-artifacts.zip --generate-notes + # Attach all downloaded CLI artifacts regardless of OS + zip -r cli-artifacts.zip ./artifacts_download + gh release create ${{ env.CURRENT_VERSION }} ./nuget/*.*nupkg cli-artifacts.zip --repo ${{ github.repository }} --target ${{ github.sha }} --generate-notes deployTest: if: ${{ github.ref == 'refs/heads/main' }} - runs-on: ubuntu-latest needs: build + runs-on: ubuntu-latest + permissions: + id-token: write # NuGet Trusted Publishing (OIDC) steps: - - uses: actions/checkout@v7 - name: Setup .NET uses: actions/setup-dotnet@v6 with: - dotnet-version: | + dotnet-version: | 10.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --configuration Release --no-restore - - name: Download CLI artifacts + - name: Download NuGet package uses: actions/download-artifact@v8 with: - path: ./artifacts_download + name: nuget-package + path: ./nuget + - name: NuGet login (Trusted Publishing) + uses: NuGet/login@v1 + id: nugetLogin + with: + user: ${{ secrets.NUGET_USER }} + token-service-url: https://int.nugettest.org/api/v2/token + audience: https://int.nugettest.org - name: NugetPush - env: - NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_TEST_TOKEN }} - if: env.NUGET_TOKEN_EXISTS != '' run: | - ls ./SkiaSharpCompare/bin/Release - dotnet nuget push ./SkiaSharpCompare/bin/Release/*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TEST_TOKEN}} --source https://apiint.nugettest.org/v3/index.json \ No newline at end of file + dotnet nuget push ./nuget/*.nupkg --skip-duplicate --api-key ${{ steps.nugetLogin.outputs.NUGET_API_KEY }} --source https://apiint.nugettest.org/v3/index.json diff --git a/SkiaSharpCompare/SkiaSharpCompare.csproj b/SkiaSharpCompare/SkiaSharpCompare.csproj index 9ca3b59..442c290 100644 --- a/SkiaSharpCompare/SkiaSharpCompare.csproj +++ b/SkiaSharpCompare/SkiaSharpCompare.csproj @@ -45,8 +45,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive