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
105 changes: 105 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: build-release

on:
workflow_dispatch:
inputs:
# nuget
nuget-push:
description: "nuget-push: true = upload nuget package. false = not upload"
required: false
type: boolean
default: true

jobs:
test-dotnet:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
# test
- run: dotnet test -c Release

create-release:
needs: [test-dotnet]
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

create-nuget-package:
needs: [create-release]
runs-on: ubuntu-latest
timeout-minutes: 10
if: needs.create-release.outputs.new_release_published == 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
# build and pack
- run: dotnet build -c Release -p:Version=${{ needs.create-release.outputs.new_release_version }}
- run: dotnet pack -c Release --no-build -p:Version=${{ needs.create-release.outputs.new_release_version }} -o ./publish
# Store artifacts.
- uses: actions/upload-artifact@v4
with:
name: nuget
path: ./publish/
retention-days: 1

push-nuget-package:
needs: [create-nuget-package]
runs-on: ubuntu-latest
timeout-minutes: 10
if: needs.create-release.outputs.new_release_published == 'true'
env:
NUGET_PATH: |
./*.nupkg
./*.snupkg
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4

# Download(All) Artifacts to current directory
- uses: actions/download-artifact@v4
with:
name: nuget
- name: Show download aritifacts
run: ls -lR
- name: Validate package exists in artifact - NuGet
run: |
while read -r nuget_path; do
if [[ "${nuget_path}" == "" ]]; then continue; fi
# shellcheck disable=SC2086
if ! ls -l ${nuget_path}; then
echo "Specified nuget package not found. path: $nuget_path"
if [[ "${nuget_path}" == *.nupkg ]]; then
echo ".nupkg must be included in the artifact."
exit 1
fi
fi
done <<< "${NUGET_PATH}"

# Upload to NuGet
- name: Upload to NuGet
if: ${{ inputs.nuget-push }}
run: |
while read -r nuget_path; do
if [[ "$nuget_path" == "" ]]; then continue; fi
# shellcheck disable=SC2086
if ! ls -l ${nuget_path} >/dev/null 2>&1;then
echo "skipping nuget push, $nuget_path not found."
continue
fi

dotnet nuget push "${nuget_path}" --skip-duplicate -s https://api.nuget.org/v3/index.json -k "${NUGET_KEY}"
done <<< "${NUGET_PATH}"
env:
NUGET_KEY: ${{ secrets.PS_NUGET_KEY }}
12 changes: 12 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/github"
]
],
"branches": [
"main"
]
}
1 change: 1 addition & 0 deletions sample/AutoQueryApiDemo/AutoQueryApiDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions sample/AutoQueryDemo/AutoQueryDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 6 additions & 1 deletion src/AutoQuery.AspNetCore/AutoQuery.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@
<ItemGroup>
<InternalsVisibleTo Include="AutoQuery.AspNetCore.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100bd24aa80c429bd4917c9458ea0a1ecb348b858c35422054e85391ed1f4c51c118662187ff2ceb0d32ba66769c91f1bbd38f4f06958dde60efbbd6c4e84cfdbf5dd1ab7c3ae567cc506a10635fee409390465d1a987248295314a896da6ba65bc5ea3247a766b096b1ddfcc68f28bbeccb1c095f0d7f4ae007f3415201a597197" />
</ItemGroup>


<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions src/AutoQuery.AspNetCore/AutoQueryServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static class AutoQueryServiceExtensions
/// 向服務集合中添加查詢建構器服務。
/// </summary>
/// <param name="services">服務集合。</param>
/// <param name="assembly">要應用配置的程序集。</param>
/// <returns>更新後的服務集合。</returns>
public static IServiceCollection AddAutoQuery(this IServiceCollection services, Assembly assembly)
{
Expand Down
1 change: 1 addition & 0 deletions src/AutoQuery.AspNetCore/EnableFieldProjectionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private static object FilterResult(object value, HashSet<string> selectedFields,
/// <param name="value">要過濾的物件。</param>
/// <param name="selectedFields">選擇的字段集合。</param>
/// <param name="serializerOptions">JSON 序列化選項。</param>
/// <param name="firstLevelOnly">是否僅過濾第一層屬性。</param>
/// <returns>過濾後的字典。</returns>
private static Dictionary<string, object?> FilterObject(object value, HashSet<string> selectedFields, JsonSerializerOptions serializerOptions, bool firstLevelOnly = false)
{
Expand Down
4 changes: 2 additions & 2 deletions test/AutoQuery.Tests/QueryProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ public class TestQueryOptions : IQueryOptions

public class TestData
{
public string Name { get; set; }
public string Name { get; set; } = null!;
public int Age { get; set; }
public string Address { get; set; }
public string Address { get; set; } = null!;
}

public class UserQueryConfiguration : IFilterQueryConfiguration<TestQueryOptions, TestData>
Expand Down