[new dtypes, NEP50] fully supported Half/Complex/SByte, np.* alias overhaul, NumPy 2.x type alias alignment #149
This file contains hidden or 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: Build and Release | |
| on: | |
| push: | |
| branches: [ "master", "main" ] | |
| tags: [ "v*" ] | |
| pull_request: | |
| branches: [ "master", "main" ] | |
| workflow_dispatch: | |
| permissions: write-all | |
| env: | |
| # Suppress noisy build warnings that clutter CI annotations. | |
| # Uses %3B (URL-encoded semicolon) because MSBuild CLI treats raw ; and , as property separators. | |
| # XML doc warnings (CS15xx, CS17xx): ~7,200 of ~8,700 total — malformed/missing doc comments | |
| # CS8981: 'np' only contains lowercase chars — intentional for NumPy API compat | |
| # NU5048: PackageIconUrl deprecated — cosmetic NuGet warning | |
| DOTNET_NOWARN: CS1570%3BCS1571%3BCS1572%3BCS1573%3BCS1574%3BCS1587%3BCS1591%3BCS1711%3BCS1734%3BCS8981%3BNU5048 | |
| jobs: | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ windows-latest, ubuntu-latest, macos-latest ] | |
| runs-on: ${{ matrix.os }} | |
| # Ubuntu has intermittent OOM issues - allow failure while investigating | |
| continue-on-error: ${{ matrix.os == 'ubuntu-latest' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 10.0.x | |
| dotnet-quality: 'preview' | |
| - name: Build | |
| run: dotnet build test/NumSharp.UnitTest/NumSharp.UnitTest.csproj --configuration Release -p:NoWarn=${{ env.DOTNET_NOWARN }} | |
| # Test filtering: | |
| # - OpenBugs: excluded (known-failing bug reproductions) | |
| # - HighMemory: excluded (requires 8GB+ RAM, too much for CI runners) | |
| # - WindowsOnly: excluded on non-Windows runners | |
| - name: Test (net8.0) | |
| shell: bash | |
| timeout-minutes: 10 | |
| run: | | |
| echo "Starting test run (net8.0)..." | |
| echo "dotnet version: $(dotnet --version)" | |
| echo "Available memory: $(free -h 2>/dev/null || echo 'N/A')" | |
| FILTER="TestCategory!=OpenBugs&TestCategory!=HighMemory" | |
| if [[ "$RUNNER_OS" != "Windows" ]]; then | |
| FILTER="$FILTER&TestCategory!=WindowsOnly" | |
| fi | |
| dotnet test test/NumSharp.UnitTest/NumSharp.UnitTest.csproj \ | |
| --configuration Release --no-build --framework net8.0 \ | |
| --filter "$FILTER" --logger "trx" | |
| - name: Test (net10.0) | |
| shell: bash | |
| timeout-minutes: 10 | |
| run: | | |
| echo "Starting test run (net10.0)..." | |
| echo "dotnet version: $(dotnet --version)" | |
| echo "Available memory: $(free -h 2>/dev/null || echo 'N/A')" | |
| FILTER="TestCategory!=OpenBugs&TestCategory!=HighMemory" | |
| if [[ "$RUNNER_OS" != "Windows" ]]; then | |
| FILTER="$FILTER&TestCategory!=WindowsOnly" | |
| fi | |
| dotnet test test/NumSharp.UnitTest/NumSharp.UnitTest.csproj \ | |
| --configuration Release --no-build --framework net10.0 \ | |
| --filter "$FILTER" --logger "trx" | |
| - name: Upload Test Results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results-${{ matrix.os }} | |
| path: ${{ github.workspace }}/**/TestResults/**/*.trx | |
| retention-days: 5 | |
| validate-release: | |
| needs: test | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| outputs: | |
| is_valid: ${{ steps.check.outputs.is_valid }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Verify tag is on master branch | |
| id: check | |
| run: | | |
| TAG_COMMIT=$(git rev-parse HEAD) | |
| VERSION="${GITHUB_REF#refs/tags/v}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # Check if the tagged commit is reachable from origin/master | |
| if git merge-base --is-ancestor "$TAG_COMMIT" origin/master; then | |
| echo "Tag v$VERSION is on master branch" | |
| echo "is_valid=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "::error::Tag v$VERSION is NOT on master branch. Releases must be tagged from master." | |
| echo "is_valid=false" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| build-nuget: | |
| needs: validate-release | |
| if: needs.validate-release.outputs.is_valid == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 10.0.x | |
| dotnet-quality: 'preview' | |
| - name: Get version info | |
| id: version | |
| shell: bash | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/v}" | |
| ASSEMBLY_VERSION="${VERSION%%-*}" | |
| COMMIT_SHA="${GITHUB_SHA:0:7}" | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "ASSEMBLY_VERSION=$ASSEMBLY_VERSION" >> $GITHUB_OUTPUT | |
| echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_OUTPUT | |
| echo "Building version $VERSION (assembly: $ASSEMBLY_VERSION) +$COMMIT_SHA" | |
| - name: Build | |
| run: | | |
| dotnet build src/NumSharp.Core/NumSharp.Core.csproj \ | |
| --configuration Release \ | |
| -p:NoWarn=${{ env.DOTNET_NOWARN }} \ | |
| -p:Version=${{ steps.version.outputs.VERSION }} \ | |
| -p:AssemblyVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:FileVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:PackageVersion=${{ steps.version.outputs.VERSION }} \ | |
| -p:SourceRevisionId=${{ steps.version.outputs.COMMIT_SHA }} | |
| dotnet build src/NumSharp.Bitmap/NumSharp.Bitmap.csproj \ | |
| --configuration Release \ | |
| -p:NoWarn=${{ env.DOTNET_NOWARN }} \ | |
| -p:Version=${{ steps.version.outputs.VERSION }} \ | |
| -p:AssemblyVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:FileVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:PackageVersion=${{ steps.version.outputs.VERSION }} \ | |
| -p:SourceRevisionId=${{ steps.version.outputs.COMMIT_SHA }} | |
| - name: Pack | |
| run: | | |
| mkdir -p artifacts/nuget | |
| dotnet pack src/NumSharp.Core/NumSharp.Core.csproj \ | |
| --configuration Release \ | |
| --no-build \ | |
| --output artifacts/nuget \ | |
| -p:NoWarn=${{ env.DOTNET_NOWARN }} \ | |
| -p:Version=${{ steps.version.outputs.VERSION }} \ | |
| -p:AssemblyVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:FileVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:PackageVersion=${{ steps.version.outputs.VERSION }} | |
| dotnet pack src/NumSharp.Bitmap/NumSharp.Bitmap.csproj \ | |
| --configuration Release \ | |
| --no-build \ | |
| --output artifacts/nuget \ | |
| -p:NoWarn=${{ env.DOTNET_NOWARN }} \ | |
| -p:Version=${{ steps.version.outputs.VERSION }} \ | |
| -p:AssemblyVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:FileVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:PackageVersion=${{ steps.version.outputs.VERSION }} | |
| echo "Packages built:" | |
| ls -la artifacts/nuget/ | |
| - name: Upload NuGet Packages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: artifacts/nuget/*.nupkg | |
| retention-days: 5 | |
| create-release: | |
| needs: [validate-release, build-nuget] | |
| if: needs.validate-release.outputs.is_valid == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract version | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Download NuGet Packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: artifacts | |
| - name: Generate checksums | |
| run: | | |
| cd artifacts | |
| for f in *.nupkg; do | |
| sha256sum "$f" | cut -d' ' -f1 > "${f}.sha256" | |
| echo "${f}: $(cat ${f}.sha256)" | |
| done | |
| - name: Check if prerelease | |
| id: prerelease | |
| run: | | |
| if [[ "${{ steps.version.outputs.VERSION }}" == *"-"* ]]; then | |
| echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| artifacts/*.nupkg | |
| artifacts/*.sha256 | |
| draft: false | |
| prerelease: ${{ steps.prerelease.outputs.IS_PRERELEASE }} | |
| generate_release_notes: true | |
| body: | | |
| ## NumSharp v${{ steps.version.outputs.VERSION }} | |
| ### Install via NuGet | |
| ``` | |
| dotnet add package NumSharp --version ${{ steps.version.outputs.VERSION }} | |
| dotnet add package NumSharp.Bitmap --version ${{ steps.version.outputs.VERSION }} | |
| ``` | |
| ### Packages | |
| | Package | NuGet | | |
| |---------|-------| | |
| | NumSharp | [](https://www.nuget.org/packages/NumSharp/${{ steps.version.outputs.VERSION }}) | | |
| | NumSharp.Bitmap | [](https://www.nuget.org/packages/NumSharp.Bitmap/${{ steps.version.outputs.VERSION }}) | | |
| publish-nuget: | |
| needs: [validate-release, build-nuget] | |
| if: needs.validate-release.outputs.is_valid == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download NuGet Packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: artifacts | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Push to NuGet | |
| run: | | |
| for package in artifacts/*.nupkg; do | |
| echo "Pushing $package..." | |
| dotnet nuget push "$package" \ | |
| --api-key ${{ secrets.NUGETAPIKEY }} \ | |
| --source https://api.nuget.org/v3/index.json \ | |
| --skip-duplicate | |
| done |