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
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
charset = utf-8
end_of_line = crlf
insert_final_newline = true

[*.{cs,csproj,props,targets,sln}]
indent_style = space
indent_size = 4

[*.{json,yml,yaml,md}]
indent_style = space
indent_size = 2
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
* text=auto eol=crlf

*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.nupkg binary
*.snupkg binary
16 changes: 0 additions & 16 deletions .github/actions/setup-dotnet/action.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Setup Environment
description: Sets up the .NET SDK used to build and test the repository

inputs:
dotnet-version:
description: One or more .NET SDK channels to install
required: false
default: 10.0.x

runs:
using: composite
steps:
- name: Set up .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: ${{ inputs.dotnet-version }}

- name: Show .NET information
shell: bash
run: dotnet --info
1 change: 1 addition & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Always add XML documents in English.
114 changes: 114 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Publish NuGet Packages

on:
workflow_dispatch:
inputs:
version:
description: Optional package version; defaults to the project version
required: false
type: string
release:
types:
- published

concurrency:
group: publish-nuget
cancel-in-progress: false

env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: true

jobs:
compatibility-test:
permissions:
contents: read
runs-on: windows-latest
timeout-minutes: 30

steps:
- name: Checkout code
uses: actions/checkout@v7
with:
persist-credentials: false

- uses: ./.github/actions/setup-env
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
9.0.x
10.0.x

- name: Restore dependencies
run: dotnet restore Ling.Audit.sln

- name: Build
run: dotnet build Ling.Audit.sln --configuration Release --no-restore -p:ContinuousIntegrationBuild=true

- name: Run tests on their target runtimes
run: dotnet test Ling.Audit.sln --configuration Release --no-build --no-restore --verbosity normal

publish:
needs: compatibility-test
environment: production
# MSBuild imports environment variables as properties. Do not name this PackageVersion:
# release tags conventionally start with "v", which makes restore fail before pack can strip it.
env:
NUGET_DIRECTORY: ${{ github.workspace }}/artifacts/packages
RELEASE_VERSION: ${{ github.event.release.tag_name || inputs.version }}
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
timeout-minutes: 25

steps:
- name: Checkout code
uses: actions/checkout@v7
with:
persist-credentials: false

- uses: ./.github/actions/setup-env

- name: Restore dependencies
run: dotnet restore Ling.Audit.sln

- name: Pack
shell: bash
run: |
version="${RELEASE_VERSION#v}"
for project in \
src/Ling.Audit/Ling.Audit.csproj \
src/Ling.Audit.EntityFrameworkCore/Ling.Audit.EntityFrameworkCore.csproj \
src/Ling.Audit.AspNetCore/Ling.Audit.AspNetCore.csproj
do
arguments=("$project" --configuration Release --no-restore \
--output "$NUGET_DIRECTORY" -p:ContinuousIntegrationBuild=true)
if [ -n "$version" ]; then arguments+=("-p:Version=$version"); fi
dotnet pack "${arguments[@]}"
done

- name: NuGet login (OIDC to temporary API key)
uses: NuGet/login@v1
id: login
with:
user: ${{ secrets.NUGET_USER }}

- name: Publish to NuGet.org
shell: bash
run: |
packages=$(find "$NUGET_DIRECTORY" -maxdepth 1 -name '*.nupkg' ! -name '*.snupkg' -print)
if [ -z "$packages" ]; then
echo "No NuGet package was produced." >&2
exit 1
fi
while IFS= read -r package; do
dotnet nuget push "$package" \
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
done <<< "$packages"
19 changes: 0 additions & 19 deletions .github/workflows/pull-request.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/release.yml

This file was deleted.

114 changes: 114 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Build and Test

on:
workflow_dispatch:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop

concurrency:
group: test-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: true
NUGET_DIRECTORY: ${{ github.workspace }}/artifacts/packages

jobs:
test:
permissions:
contents: read
runs-on: ubuntu-latest
timeout-minutes: 25

steps:
- name: Checkout code
uses: actions/checkout@v7
with:
persist-credentials: false

- uses: ./.github/actions/setup-env

- name: Restore dependencies
run: dotnet restore Ling.Audit.sln

- name: Build
run: dotnet build Ling.Audit.sln --configuration Release --no-restore -p:ContinuousIntegrationBuild=true

- name: Verify NuGet packages can be created
shell: bash
run: |
for project in \
src/Ling.Audit/Ling.Audit.csproj \
src/Ling.Audit.EntityFrameworkCore/Ling.Audit.EntityFrameworkCore.csproj \
src/Ling.Audit.AspNetCore/Ling.Audit.AspNetCore.csproj
do
dotnet pack "$project" --configuration Release --no-build --no-restore \
--output "$NUGET_DIRECTORY" -p:ContinuousIntegrationBuild=true
done

- name: Verify package boundaries
shell: bash
run: |
core=$(find "$NUGET_DIRECTORY" -maxdepth 1 -name 'Ling.Audit.*.nupkg' \
! -name '*.EntityFrameworkCore.*' ! -name '*.AspNetCore.*' ! -name '*.snupkg' -print -quit)
efcore=$(find "$NUGET_DIRECTORY" -maxdepth 1 -name 'Ling.Audit.EntityFrameworkCore.*.nupkg' \
! -name '*.snupkg' -print -quit)
aspnetcore=$(find "$NUGET_DIRECTORY" -maxdepth 1 -name 'Ling.Audit.AspNetCore.*.nupkg' \
! -name '*.snupkg' -print -quit)

test -n "$core"
test -n "$efcore"
test -n "$aspnetcore"

unzip -Z1 "$core" | grep -Fx 'analyzers/dotnet/cs/Ling.Audit.SourceGenerators.dll'
unzip -Z1 "$core" | grep -Fx 'lib/netstandard2.0/Ling.Audit.dll'
unzip -Z1 "$efcore" | grep -Fx 'lib/net6.0/Ling.Audit.EntityFrameworkCore.dll'
unzip -Z1 "$efcore" | grep -Fx 'lib/net9.0/Ling.Audit.EntityFrameworkCore.dll'
unzip -Z1 "$aspnetcore" | grep -Fx 'lib/net6.0/Ling.Audit.AspNetCore.dll'
unzip -Z1 "$aspnetcore" | grep -Fx 'lib/net9.0/Ling.Audit.AspNetCore.dll'

- name: Verify package consumption
run: |
dotnet restore tests/Ling.Audit.PackageConsumer/Ling.Audit.PackageConsumer.csproj \
--configfile tests/Ling.Audit.PackageConsumer/NuGet.config
dotnet build tests/Ling.Audit.PackageConsumer/Ling.Audit.PackageConsumer.csproj \
--configuration Release --no-restore

compatibility-test:
permissions:
contents: read
runs-on: windows-latest
timeout-minutes: 30

steps:
- name: Checkout code
uses: actions/checkout@v7
with:
persist-credentials: false

- uses: ./.github/actions/setup-env
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
9.0.x
10.0.x

- name: Restore dependencies
run: dotnet restore Ling.Audit.sln

- name: Build
run: dotnet build Ling.Audit.sln --configuration Release --no-restore -p:ContinuousIntegrationBuild=true

- name: Run tests on their target runtimes
run: dotnet test Ling.Audit.sln --configuration Release --no-build --no-restore --verbosity normal
Loading