Build and Publish Nuget #45
Workflow file for this run
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 | |
| on: | |
| workflow_dispatch: # <-- allows manual trigger | |
| push: | |
| branches: | |
| - release/* | |
| tags: | |
| - 'v*' | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| id-token: write # enable GitHub OIDC token issuance for this job | |
| strategy: | |
| matrix: | |
| dotnet-version: [8.x, 9.x] # test all supported versions | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET SDK and runtime | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ matrix.dotnet-version }} | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --configuration Release --no-restore | |
| - name: Run Tests with coverage | |
| run: dotnet test --configuration Release --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=./coverage/ | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| slug: NavneetHegde/OpenCode | |
| # ======================== | |
| # SBOM Generation Step | |
| # ======================== | |
| - name: Install CycloneDX .NET Tool | |
| run: | | |
| dotnet new tool-manifest | |
| dotnet tool install CycloneDX | |
| - name: Generate SBOM | |
| run: | | |
| dotnet tool run dotnet-CycloneDX OpenCode/OpenCode.csproj -o sbom -f json | |
| - name: Upload SBOM | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sbom | |
| path: sbom/bom.json | |
| - name: Pack | |
| if: matrix.dotnet-version == '9.x' | |
| run: dotnet pack --configuration Release --no-build --output ./nupkg | |
| - name: Done | |
| run: echo "Package published successfully!" |