diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2001eb55..7068ec64a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,6 +81,7 @@ jobs: strategy: matrix: os: ${{ fromJson(needs.setup-os-matrix.outputs.os) }} + library: [ILGPU, ILGPU.Algorithms] fail-fast: false runs-on: ${{ matrix.os }} steps: @@ -92,96 +93,113 @@ jobs: dotnet-version: 3.1.407 - name: Pin .NET Core SDK run: dotnet new globaljson --sdk-version 3.1.407 - # WORKAROUND: Reset NuGet sources to default to avoid restore issues - # on Windows runners where the Visual Studio offline source seems to - # cause random issues. - - name: Reset NuGet sources - if: runner.os == 'Windows' - run: dotnet new nugetconfig - name: Release Build run: dotnet build --configuration=Release -p:TreatWarningsAsErrors=true Src - name: CPU Tests if: matrix.os != 'cuda' - run: dotnet test --logger GitHubActions --configuration=Release ./Src/ILGPU.Tests.CPU + run: dotnet test --logger GitHubActions --no-build --configuration=Release Src/${{ matrix.library }}.Tests.CPU - name: CUDA Tests if: matrix.os == 'cuda' - run: dotnet test --logger GitHubActions --configuration=Release ./Src/ILGPU.Tests.Cuda - - name: Set up NuGet - if: runner.os == 'Windows' - uses: nuget/setup-nuget@v1 + run: dotnet test --logger GitHubActions --no-build --configuration=Release Src/${{ matrix.library }}.Tests.Cuda + + package: + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup .NET Core SDK + uses: actions/setup-dotnet@v1 with: - nuget-version: '5.x' - - name: Create NuGet package - if: runner.os == 'Windows' + dotnet-version: 3.1.407 + - name: Pin .NET Core SDK + run: dotnet new globaljson --sdk-version 3.1.407 + - name: Check version + id: version run: | + $xpath = "/Project/PropertyGroup/VersionPrefix/text()" + $main_version = (Select-Xml -path Src/ILGPU/ILGPU.csproj -XPath $xpath).Node.Value + $algo_version = (Select-Xml -path Src/ILGPU.Algorithms/ILGPU.Algorithms.csproj -XPath $xpath).Node.Value + if (-not ($main_version -eq $algo_version)) { + echo "::error ::There is a mismatch between the project version of ILGPU ($main_version) and ILGPU.Algorithms ($algo_version)" + exit 1 + } + if ("${{ github.ref }}" -like "refs/tags/v*") { $tag = "${{ github.ref }}".SubString(11) - $version = (Select-Xml -path Src/ILGPU/ILGPU.csproj -XPath "/Project/PropertyGroup/VersionPrefix/text()").node.Value - if (-not ($tag -eq $version)) { - echo "::error ::There is a mismatch between the project version ($version) and the tag ($tag)" + if (-not ($tag -eq $main_version)) { + echo "::error ::There is a mismatch between the project version ($main_version) and the tag ($tag)" exit 1 } - } else { + } + + echo "::set-output name=version::$main_version" + + - name: Create NuGet packages + id: package + run: | + $version = "${{ steps.version.outputs.version }}" + + if (-not ("${{ github.ref }}" -like "refs/tags/v*")) { # WORKAROUND: Add letter prefix to ensure that MSBuild treats # the suffix as a string. e.g. '0313071' will fail as an invalid # version string, but 'G0313071' will succeeded. It looks like # the parser does not like numbers with a leading zero. $suffix = 'g' + $(git rev-parse --short HEAD) $params = "--version-suffix", $suffix + $version = "$version-$suffix" } + dotnet pack --configuration=Release @params Src - - name: Fix NuGet Symbols Package - if: runner.os == 'Windows' + + echo "::set-output name=version::$version" + + - name: Fix NuGet Symbols Packages run: | - # WORKAROUND: The Symbols package should only contain Portable - # PDBs (no Windows PDBs allowed). Transfer ILGPU.pdb from Symbols - # package to Main NuGet package. Can be removed after updating + # WORKAROUND: The Symbols packages should only contain Portable + # PDBs (no Windows PDBs allowed). Transfer net47 pdb from Symbols + # packages to Main NuGet packages. Can be removed after updating # ILGPU from net47 to net472. - # Get path to the Main and Symbols NuGet packages - $releaseDir = '.\Bin\Release' - $mainPkgPath = - Get-ChildItem -Path $releaseDir -Filter ILGPU.*.nupkg ` - | Select-Object -First 1 -ExpandProperty Fullname - $symbolsPkgPath = - Get-ChildItem -Path $releaseDir -Filter ILGPU.*.snupkg ` - | Select-Object -First 1 -ExpandProperty Fullname - - # Transfer ILGPU.pdb from the Symbols to Main NuGet package - Add-Type -AssemblyName System.IO.Compression.FileSystem - $pdbEntryPath = 'lib/net47/ILGPU.pdb' - - $mainPkgZip = [System.IO.Compression.ZipFile]::Open( - $mainPkgPath, - 'Update') - [System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile( + ForEach ($library in "ILGPU", "ILGPU.Algorithms") { + # Get path to the Main and Symbols NuGet packages + $releaseDir = './Bin/Release' + $mainPkgPath = Join-Path $releaseDir "$library.${{ steps.package.outputs.version }}.nupkg" + $symbolsPkgPath = Join-Path $releaseDir "$library.${{ steps.package.outputs.version }}.snupkg" + + # Transfer net47 pdb from the Symbols to Main NuGet package + Add-Type -AssemblyName System.IO.Compression.FileSystem + $pdbEntryPath = "lib/net47/$library.pdb" + + $mainPkgZip = [System.IO.Compression.ZipFile]::Open( + $mainPkgPath, + 'Update') + [System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile( $mainPkgZip, - "$releaseDir\net47\ILGPU.pdb", + "$releaseDir/net47/$library.pdb", $pdbEntryPath); - $mainPkgZip.Dispose() + $mainPkgZip.Dispose() - $symbolsPkgZip = [System.IO.Compression.ZipFile]::Open( - $symbolsPkgPath, - 'Update') - $symbolsPkgZip.GetEntry($pdbEntryPath).Delete(); - $symbolsPkgZip.Dispose() + $symbolsPkgZip = [System.IO.Compression.ZipFile]::Open( + $symbolsPkgPath, + 'Update') + $symbolsPkgZip.GetEntry($pdbEntryPath).Delete(); + $symbolsPkgZip.Dispose() + } - - name: Upload NuGet package artifact - if: runner.os == 'Windows' + - name: Upload NuGet package artifacts uses: actions/upload-artifact@v2 with: - name: nuget-package - path: ./Bin/Release/ILGPU.*.*nupkg + name: nuget-packages + path: ./Bin/Release/ILGPU*.${{ steps.package.outputs.version }}.*nupkg - publish-nuget: + publish: if: startsWith(github.ref, 'refs/tags/v') - needs: [check-style, build-and-test] - runs-on: windows-latest + needs: [check-style, build-and-test, package] + runs-on: ubuntu-latest steps: - name: Download NuGet package artifact uses: actions/download-artifact@v2 with: - name: nuget-package + name: nuget-packages - name: Publish to NuGet - shell: bash - run: dotnet nuget push ILGPU.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json + run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json diff --git a/Src/.config/dotnet-tools.json b/Src/.config/dotnet-tools.json deleted file mode 100644 index e02c7e0d8..000000000 --- a/Src/.config/dotnet-tools.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": 1, - "isRoot": true, - "tools": { - "dotnet-t4-fix": { - "version": "2.3.0-preview-0000-gb1ee03d9bc", - "commands": [ - "t4" - ] - } - } -}