Build #1185
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 | |
| on: | |
| push: | |
| # branches: [main] | |
| tags: ['*'] | |
| paths-ignore: | |
| - README.md | |
| - '**/README.md' | |
| - LICENSE | |
| - CHANGELOG.md | |
| - docs/** | |
| pull_request: | |
| branches: [main] | |
| paths-ignore: | |
| - README.md | |
| - '**/README.md' | |
| - LICENSE | |
| - CHANGELOG.md | |
| - docs/** | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 1 * * *' # daily at 1am UTC | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write # required for nuget/login@v1 to get a temporary NuGet API key via OIDC | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| # wait for previous runs to complete on main and tags | |
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') }} | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
| GITHUB_REF: ${{ github.ref }} # not discovered by default | |
| jobs: | |
| Build: | |
| runs-on: ubuntu-latest | |
| name: Build | |
| services: | |
| mongo: | |
| image: mongo:latest | |
| ports: ['27017:27017'] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # Required for GitVersion | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@v5 | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v4 | |
| - name: Determine Version | |
| uses: gittools/actions/gitversion/execute@v4 | |
| id: gitversion | |
| - name: Install dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: > | |
| dotnet build | |
| --configuration Release | |
| --no-restore | |
| -p:VersionPrefix=${{ steps.gitversion.outputs.fullSemVer }} | |
| - name: Test | |
| run: dotnet test --configuration Release --no-build | |
| - name: Pack | |
| run: > | |
| dotnet pack | |
| --configuration Release | |
| --no-build | |
| --output ${{ github.workspace }}/drop | |
| -p:PackageVersion=${{ steps.gitversion.outputs.fullSemVer }} | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| path: ${{ github.workspace }}/drop/* | |
| name: drop | |
| retention-days: 1 | |
| - name: Publish to GitHub Packages | |
| if: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags')) }} | |
| run: > | |
| dotnet nuget push "${{ github.workspace }}/drop/*" | |
| --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | |
| --api-key ${{ secrets.GITHUB_TOKEN }} | |
| --skip-duplicate | |
| - name: NuGet login (OIDC → temp API key) | |
| if: ${{ startsWith(github.ref, 'refs/tags') }} | |
| uses: NuGet/login@v1 | |
| id: login | |
| with: | |
| user: 'mburumaxwell' # the user connected via not organization to NuGet.org | |
| - name: Publish to NuGet.org | |
| if: ${{ startsWith(github.ref, 'refs/tags') }} | |
| run: > | |
| dotnet nuget push "${{ github.workspace }}/drop/*" | |
| --source "https://api.nuget.org/v3/index.json" | |
| --api-key ${{ steps.login.outputs.NUGET_API_KEY }} | |
| --skip-duplicate |