Optimize string concatenation for better performance #42
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 Publish NuGet Package | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| DOTNET_VERSION: '8.0.x' | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build solution | |
| run: dotnet build --configuration Release --no-restore | |
| - name: Run tests | |
| run: dotnet test --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage" | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results | |
| path: "**/TestResults/**/*.xml" | |
| publish-nuget: | |
| needs: build-and-test | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Generate version number | |
| id: version | |
| run: | | |
| # Get the commit count and short SHA for versioning | |
| COMMIT_COUNT=$(git rev-list --count HEAD) | |
| SHORT_SHA=$(git rev-parse --short HEAD) | |
| VERSION="1.0.$COMMIT_COUNT" | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Generated version: $VERSION" | |
| - name: Build release | |
| run: dotnet build --configuration Release --no-restore -p:Version=${{ steps.version.outputs.VERSION }} -p:PackageVersion=${{ steps.version.outputs.PACKAGE_VERSION }} | |
| - name: Create NuGet package | |
| run: dotnet pack --configuration Release --no-build -p:PackageVersion=${{ steps.version.outputs.PACKAGE_VERSION }} --output ./packages | |
| - name: List generated packages | |
| run: ls -la ./packages/ | |
| - name: Publish to NuGet.org | |
| run: dotnet nuget push "./packages/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
| - name: Upload NuGet packages as artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: ./packages/*.nupkg |