v0.3.0: Add new math functions, GitHub Actions CI/CD, and .NET 10.0 s… #1
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: NuGet Publish | |
| on: | |
| push: | |
| paths: | |
| - 'src/Directory.Build.props' | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
| DOTNET_CLI_TELEMETRY_OPTOUT: true | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET SDKs | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 9.0.x | |
| 10.0.x | |
| - name: Extract version from Directory.Build.props | |
| id: version | |
| run: | | |
| VERSION=$(grep -oP '(?<=<Version>)[^<]+' src/Directory.Build.props) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Extracted version: $VERSION" | |
| - name: Check if version already exists on NuGet | |
| id: check | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| PACKAGE_EXISTS=$(dotnet nuget search FunctionX --source https://api.nuget.org/v3/index.json --exact-match 2>/dev/null | grep -c "$VERSION" || true) | |
| if [ "$PACKAGE_EXISTS" -gt 0 ]; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| echo "Version $VERSION already exists on NuGet" | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| echo "Version $VERSION does not exist on NuGet" | |
| fi | |
| - name: Restore dependencies | |
| if: steps.check.outputs.exists != 'true' | |
| working-directory: src | |
| run: dotnet restore | |
| - name: Build | |
| if: steps.check.outputs.exists != 'true' | |
| working-directory: src | |
| run: dotnet build --configuration Release --no-restore | |
| - name: Run tests | |
| if: steps.check.outputs.exists != 'true' | |
| working-directory: src | |
| run: dotnet test --configuration Release --no-build --verbosity normal | |
| - name: Pack NuGet package | |
| if: steps.check.outputs.exists != 'true' | |
| working-directory: src/FunctionX | |
| run: dotnet pack --configuration Release --no-build --output ./nupkg | |
| - name: Push to NuGet | |
| if: steps.check.outputs.exists != 'true' | |
| working-directory: src/FunctionX | |
| run: | | |
| dotnet nuget push ./nupkg/*.nupkg \ | |
| --api-key ${{ secrets.NUGET_API_KEY }} \ | |
| --source https://api.nuget.org/v3/index.json \ | |
| --skip-duplicate | |
| - name: Create GitHub Release | |
| if: steps.check.outputs.exists != 'true' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| name: Release v${{ steps.version.outputs.version }} | |
| body: | | |
| ## FunctionX v${{ steps.version.outputs.version }} | |
| ### Installation | |
| ```bash | |
| dotnet add package FunctionX --version ${{ steps.version.outputs.version }} | |
| ``` | |
| ### NuGet Package | |
| https://www.nuget.org/packages/FunctionX/${{ steps.version.outputs.version }} | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Summary | |
| run: | | |
| if [ "${{ steps.check.outputs.exists }}" == "true" ]; then | |
| echo "### ⏭️ Skipped - Version ${{ steps.version.outputs.version }} already exists" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "### ✅ Published FunctionX v${{ steps.version.outputs.version }} to NuGet" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "📦 [NuGet Package](https://www.nuget.org/packages/FunctionX/${{ steps.version.outputs.version }})" >> $GITHUB_STEP_SUMMARY | |
| fi |