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
27 changes: 27 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
github-actions:
patterns:
- '*'

- package-ecosystem: nuget
directory: /
schedule:
interval: weekly
groups:
test-dependencies:
patterns:
- 'Microsoft.Testing.*'
- 'xunit*'
- 'coverlet.*'
- 'Moq'
- 'Shouldly'
- 'AwesomeAssertions'
mediator:
patterns:
- 'Mediator.*'
83 changes: 69 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,88 @@
name: Build and Test

on:
on:
workflow_dispatch:
workflow_call:
push:
branches:
- main
paths:
- 'src/**'
- 'tests/**'
- 'Directory.*.props'
- '*.slnx'
- 'global.json'
- 'nuget.config'
- '.github/workflows/**'
pull_request:
branches:
- main
paths:
- 'src/**'
- 'tests/**'
- 'Directory.*.props'
- '*.slnx'
- 'global.json'
- 'nuget.config'
- '.github/workflows/**'

permissions:
contents: read

concurrency:
# When called from publish.yml, github.workflow is the caller's name, so releases don't cancel CI runs.
group: ${{ github.workflow }}-ci-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
SOLUTION_FILE: NimblePros.SharedKernel.slnx

PACK_OUTPUT: artifacts/package/release
TEST_RESULTS: artifacts/test-results
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup dotnet
uses: actions/setup-dotnet@v6
with:
dotnet-version: 11.0.x
- name: Build
run: dotnet build "${{ env.SOLUTION_FILE }}" --configuration Release
- name: Test
run: dotnet test "${{ env.SOLUTION_FILE }}" --configuration Release --no-build --no-restore

- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup dotnet
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 11.0.x
cache: true
cache-dependency-path: '**/packages.lock.json'

- name: Restore
run: dotnet restore "${{ env.SOLUTION_FILE }}" --locked-mode

- name: Build
run: dotnet build "${{ env.SOLUTION_FILE }}" --configuration Release --no-restore

- name: Test
run: >
dotnet test "${{ env.SOLUTION_FILE }}" --configuration Release --no-build --no-restore
--report-xunit-trx
--coverlet --coverlet-output-format cobertura
--results-directory "${{ env.TEST_RESULTS }}"

- name: Pack
run: dotnet pack "${{ env.SOLUTION_FILE }}" --configuration Release --no-build --no-restore --output "${{ env.PACK_OUTPUT }}"

- name: Upload test results and coverage
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: test-results
path: ${{ env.TEST_RESULTS }}
if-no-files-found: warn

- name: Upload package
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: nuget-package
path: ${{ env.PACK_OUTPUT }}/*.*nupkg
if-no-files-found: error
54 changes: 27 additions & 27 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,47 @@ on:
release:
types: [published]

env:
SOLUTION_FILE: NimblePros.SharedKernel.slnx
PACK_OUTPUT: artifacts/package/release
permissions:
contents: read

concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: false

jobs:
build:
ci:
uses: ./.github/workflows/ci.yml

publish:
needs: ci
# Only push packages for release tags; a manual run on a branch just builds and tests.
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
id-token: write # required for NuGet trusted publishing (OIDC)

steps:
- name: Checkout
uses: actions/checkout@v7

- name: Setup dotnet
uses: actions/setup-dotnet@v6
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 11.0.x

- name: Build
run: dotnet build "${{ env.SOLUTION_FILE }}" --configuration Release

- name: Test
run: dotnet test "${{ env.SOLUTION_FILE }}" --configuration Release --no-build --no-restore

- name: Pack
run: dotnet pack "${{ env.SOLUTION_FILE }}" --configuration Release --no-build --no-restore --output "${{ env.PACK_OUTPUT }}"
- name: Download package
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: nuget-package
path: packages

- name: NuGet login (OIDC -> temp API key)
uses: NuGet/login@v1
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
id: login
with:
user: ${{ secrets.NUGET_USER }}

- name: Push to NuGet
if: startsWith(github.ref, 'refs/tags/') # only push if building a tag
shell: pwsh
run: |
Get-ChildItem "${{ env.PACK_OUTPUT }}" -Filter *.nupkg | ForEach-Object {
dotnet nuget push $_.FullName `
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}" `
--source https://api.nuget.org/v3/index.json
}
run: >
dotnet nuget push "packages/*.nupkg"
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}"
--source https://api.nuget.org/v3/index.json
--skip-duplicate
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<TargetFramework>net11.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
</Project>
25 changes: 25 additions & 0 deletions src/NimblePros.SharedKernel/packages.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"version": 2,
"dependencies": {
"net11.0": {
"Ardalis.GuardClauses": {
"type": "Direct",
"requested": "[6.0.0, )",
"resolved": "6.0.0",
"contentHash": "VPCr46YYHjcnunQpixMP/LDH56s85oTvu+wJ4zXu4JNYOm76VD0veDX3gneMV8w1XPnwJWUHrWJXrhaPAJM6QA=="
},
"Ardalis.Specification": {
"type": "Direct",
"requested": "[10.0.0, )",
"resolved": "10.0.0",
"contentHash": "gzIybrs66DqZPMYwumDHCh3ELPmt77CMOoOma9oPkUaBxtKJfvJtfet4kx4WL9JaVUDDZK3IYq673TPLcU+/FA=="
},
"Mediator.Abstractions": {
"type": "Direct",
"requested": "[3.0.2, )",
"resolved": "3.0.2",
"contentHash": "TytjnyN8gLObZBxkM7HHPFJF3LHtk6Y8mHW56ONuXRuVEK6Fmed3f0z79H9TpmoZQP2zQAIS4/0O9R2w0v02qw=="
}
}
}
}
Loading