Add files via upload #38
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: .NET Build, Test and Publish | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| permissions: | |
| contents: write | |
| packages: write | |
| env: | |
| SOLUTION_FILE: ValueMapper/ValueMapper.sln | |
| PROJECT_FILE: ValueMapper/ValueMapper/ValueMapper.csproj | |
| PACKAGE_OUTPUT_DIRECTORY: ${{ github.workspace }}/output | |
| jobs: | |
| build-and-pack: | |
| name: Build and Package | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v3 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: List directory for debugging | |
| run: | | |
| pwd | |
| ls -R ValueMapper/ | |
| - name: Restore dependencies | |
| run: dotnet restore "${{ env.SOLUTION_FILE }}" | |
| - name: Build | |
| run: dotnet build "${{ env.SOLUTION_FILE }}" --configuration Release --no-restore | |
| - name: Create output directory | |
| run: mkdir -p "${{ env.PACKAGE_OUTPUT_DIRECTORY }}" | |
| - name: Pack | |
| run: dotnet pack "${{ env.PROJECT_FILE }}" --configuration Release --output "${{ env.PACKAGE_OUTPUT_DIRECTORY }}" | |
| - name: Upload package artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-package | |
| path: ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg | |
| if-no-files-found: error | |
| publish: | |
| name: Publish to NuGet | |
| needs: build-and-pack | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Download package artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget-package | |
| path: ${{ env.PACKAGE_OUTPUT_DIRECTORY }} | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v3 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Push to NuGet.org | |
| run: | | |
| # Push directly to NuGet.org using the API key | |
| dotnet nuget push "${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate |