Repository navigation
Refine EF Fluent API analyzer boundaries #304
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: Action to build and publish the project as a nuget package to github package registry | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - Sources/** | |
| - .github/workflows/publish-release.yml | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| Version: ${{ steps.gitversion.outputs.MajorMinorPatch }} | |
| CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 #fetch-depth is needed for GitVersion | |
| #Install and calculate the new version with GitVersion | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/[email protected] | |
| with: | |
| versionSpec: 6.x #gittools v4.7.x requires GitVersion >=6.2.0 <7.0.0 | |
| - name: Determine Version | |
| uses: gittools/actions/gitversion/[email protected] | |
| id: gitversion # step id used as reference for output values | |
| - name: Display GitVersion outputs | |
| run: | | |
| echo "Version: ${{ steps.gitversion.outputs.MajorMinorPatch }}" | |
| echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}" | |
| #Build/pack the project | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v6 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Build and Pack NuGet package | |
| run: | | |
| cd Sources | |
| dotnet build --configuration Release | |
| dotnet pack --configuration Release --output nupkg -p:Version='${{ steps.gitversion.outputs.MajorMinorPatch }}' | |
| - name: Upload NuGet package to GitHub | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: nupkg | |
| path: Sources/nupkg | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.ref == 'refs/heads/main' # only run job if on the master branch | |
| permissions: | |
| id-token: write # required for NuGet Trusted Publishing (OIDC) | |
| contents: read | |
| steps: | |
| #Push NuGet package to GitHub packages | |
| - name: Download nuget package artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: nupkg | |
| - name: Prep packages | |
| run: dotnet nuget add source --username bvdcode --password ${{ secrets.DEPLOY_GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/bvdcode/index.json" | |
| - name: Push package to GitHub packages | |
| if: needs.build.outputs.CommitsSinceVersionSource > 0 #Only release if there has been a commit/version change | |
| run: dotnet nuget push *.nupkg --skip-duplicate --api-key ${{ secrets.DEPLOY_GITHUB_TOKEN }} --source "github" | |
| #Trusted Publishing: exchange the GitHub OIDC token for a short-lived nuget.org API key (valid ~1 hour) | |
| - name: NuGet login (OIDC → temp API key) | |
| if: needs.build.outputs.CommitsSinceVersionSource > 0 | |
| uses: NuGet/login@v1 | |
| id: nuget-login | |
| with: | |
| user: bvd # nuget.org profile name that owns the trusted publishing policy | |
| - name: Push package to nuget.org | |
| if: needs.build.outputs.CommitsSinceVersionSource > 0 | |
| run: dotnet nuget push *.nupkg --skip-duplicate --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | |
| - name: Create Release | |
| if: needs.build.outputs.CommitsSinceVersionSource > 0 #Only release if there has been a commit/version change | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: ${{ needs.build.outputs.Version }} | |
| name: Release ${{ needs.build.outputs.Version }} | |
| artifacts: "*.nupkg,*.snupkg" #download-artifact extracts into the workspace root, not into a nupkg/ folder | |
| token: ${{ secrets.DEPLOY_GITHUB_TOKEN }} |