Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 24 additions & 44 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
name: Build

on:
push:
branches: [ 'master', 'release/**' ]
workflow_dispatch:
pull_request:
push:
branches: [ 'master', 'release/**' ]
release:
types: [published]
Expand Down Expand Up @@ -51,17 +51,15 @@ jobs:
- name: Git checkout
uses: actions/checkout@v5
- name: Restore tools
run: |
dotnet tool restore
run: dotnet tool restore
- name: Restore packages
run: |
dotnet restore
run: dotnet restore
- name: Calculate version suffix
shell: pwsh
run: |
if ($env:GITHUB_REF_TYPE -eq 'tag') {
# Get the version prefix/suffix from the git tag. For example: 'v1.0.0-preview1-final' => '1.0.0' and 'preview1-final'
$segments = $env:GITHUB_REF_NAME -split "-"
$segments = $env:GITHUB_REF_NAME -split '-'
$versionPrefix = $segments[0].TrimStart('v')
$versionSuffix = $segments.Length -eq 1 ? '' : $segments[1..$($segments.Length - 1)] -join '-'

Expand All @@ -87,26 +85,21 @@ jobs:
Write-Output "Using version suffix: $versionSuffix"
Write-Output "PACKAGE_VERSION_SUFFIX=$versionSuffix" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Build
shell: pwsh
run: |
dotnet build --no-restore --configuration Release /p:VersionSuffix=$env:PACKAGE_VERSION_SUFFIX
run: dotnet build --no-restore --configuration Release /p:VersionSuffix=${{ env.PACKAGE_VERSION_SUFFIX }}
- name: Test
run: |
dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true"
run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true"
- name: Upload coverage to codecov.io
if: matrix.os == 'ubuntu-latest'
if: ${{ matrix.os == 'ubuntu-latest' }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
verbose: true
- name: Generate packages
shell: pwsh
run: |
dotnet pack --no-build --configuration Release --output $env:GITHUB_WORKSPACE/artifacts/packages /p:VersionSuffix=$env:PACKAGE_VERSION_SUFFIX
run: dotnet pack --no-build --configuration Release --output ${{ github.workspace }}/artifacts/packages /p:VersionSuffix=${{ env.PACKAGE_VERSION_SUFFIX }}
- name: Upload packages to artifacts
if: matrix.os == 'ubuntu-latest'
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v4
with:
name: packages
Expand All @@ -133,8 +126,7 @@ jobs:
- name: Git checkout
uses: actions/checkout@v5
- name: Restore tools
run: |
dotnet tool restore
run: dotnet tool restore
- name: InspectCode
shell: pwsh
run: |
Expand Down Expand Up @@ -163,7 +155,7 @@ jobs:
}

if ($failed) {
Write-Error "One or more projects failed code inspection."
Write-Error 'One or more projects failed code inspection.'
}
}

Expand All @@ -190,13 +182,11 @@ jobs:
with:
fetch-depth: 2
- name: Restore tools
run: |
dotnet tool restore
run: dotnet tool restore
- name: Restore packages
run: |
dotnet restore
run: dotnet restore
- name: CleanupCode (on PR diff)
if: github.event_name == 'pull_request'
if: ${{ github.event_name == 'pull_request' }}
shell: pwsh
run: |
# Not using the environment variables for SHAs, because they may be outdated. This may happen on force-push after the build is queued, but before it starts.
Expand All @@ -207,10 +197,10 @@ jobs:
Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request."
dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff
- name: CleanupCode (on branch)
if: github.event_name == 'push' || github.event_name == 'release'
if: ${{ github.event_name == 'push' || github.event_name == 'release' }}
shell: pwsh
run: |
Write-Output "Running code cleanup on all files."
Write-Output 'Running code cleanup on all files.'
dotnet regitlint -s JsonApiDotNetCore.MongoDb.sln --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN --fail-on-diff --print-diff

publish:
Expand All @@ -227,25 +217,15 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Publish to GitHub Packages
if: github.event_name == 'push' || github.event_name == 'release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh
if: ${{ github.event_name == 'push' || github.event_name == 'release' }}
run: |
dotnet nuget add source --username 'json-api-dotnet' --password "$env:GITHUB_TOKEN" --store-password-in-clear-text --name 'github' 'https://nuget.pkg.github.com/json-api-dotnet/index.json'
dotnet nuget push "$env:GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env:GITHUB_TOKEN" --source 'github'
dotnet nuget add source --username 'json-api-dotnet' --password '${{ secrets.GITHUB_TOKEN }}' --store-password-in-clear-text --name 'github' 'https://nuget.pkg.github.com/json-api-dotnet/index.json'
dotnet nuget push '${{ github.workspace }}/packages/*.nupkg' --api-key '${{ secrets.GITHUB_TOKEN }}' --source 'github'
- name: Publish to feedz.io
if: github.event_name == 'push' || github.event_name == 'release'
env:
FEEDZ_IO_API_KEY: ${{ secrets.FEEDZ_IO_API_KEY }}
shell: pwsh
if: ${{ github.event_name == 'push' || github.event_name == 'release' }}
run: |
dotnet nuget add source --name 'feedz-io' 'https://f.feedz.io/json-api-dotnet/jsonapidotnetcore/nuget/index.json'
dotnet nuget push "$env:GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env:FEEDZ_IO_API_KEY" --source 'feedz-io'
dotnet nuget push '${{ github.workspace }}/packages/*.nupkg' --api-key '${{ secrets.FEEDZ_IO_API_KEY }}' --source 'feedz-io'
- name: Publish to NuGet
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v')
env:
NUGET_ORG_API_KEY: ${{ secrets.NUGET_ORG_API_KEY }}
shell: pwsh
run: |
dotnet nuget push "$env:GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env:NUGET_ORG_API_KEY" --source 'nuget.org'
if: ${{ github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') }}
run: dotnet nuget push '${{ github.workspace }}/packages/*.nupkg' --api-key '${{ secrets.NUGET_ORG_API_KEY }}' --source 'nuget.org' --skip-duplicate
5 changes: 2 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: "CodeQL"

on:
push:
branches: [ 'master', 'release/**' ]
workflow_dispatch:
pull_request:
# The branches below must be a subset of the branches above
push:
branches: [ 'master', 'release/**' ]
schedule:
- cron: '0 0 * * 5'
Expand Down
Loading