Skip to content
Closed
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
108 changes: 7 additions & 101 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,110 +1,16 @@
name: CI
name: verify

on:
push:
branches-ignore:
- dependabot/*
pull_request:
workflow_dispatch:
inputs:
is_stable_build:
description: Use a version number indicating this is a stable release
required: true
default: "false"
release:
description: Create a release
required: true
default: "false"

env:
IS_STABLE_BUILD: ${{ github.event.inputs.is_stable_build }}

jobs:
build:
if: "!contains(github.event.head_commit.message, 'ci skip') || github.event_name == 'workflow_dispatch'"
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]

runs-on: ${{ matrix.os }}

# Windows builds are failing 100% of the time on code that works just fine on Linux
# and works 90% of the time on the macOS build agents GitHub uses and works 100% of the time on my
# my laptop. Life is short. I'm not spending more time trying to figure out why the code that used
# to work create on .NET 5 became flaky on newer versions of .NET but only on some platforms.
continue-on-error: ${{ matrix.os != 'ubuntu-latest' }}

outputs:
package_version: ${{ steps.build_script.outputs.package_version }}

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8
- name: Run build script
id: build_script
run: ./build.ps1 -ci
- uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
name: packages
path: artifacts/
if-no-files-found: error
- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: unittests-${{ matrix.os }}
fail_ci_if_error: true
release:
if: "github.event.inputs.release"
needs: build
test:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
packages: write
env:
PACKAGE_VERSION: ${{ needs.build.outputs.package_version }}
steps:
- run: echo "Releasing ${{ env.PACKAGE_VERSION }}"
- uses: actions/download-artifact@v4
with:
name: packages
path: packages
- name: Configure GitHub NuGet registry
run: dotnet nuget add source --name github --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
- name: Push to GitHub package registry
run: dotnet nuget push packages/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source github --skip-duplicate
- name: Login to NuGet.org
id: nuget-login
uses: nuget/login@v1
- uses: actions/checkout@v7
- uses: actions/setup-dotnet@v6
with:
user: natemcmaster
- name: Push to NuGet.org
run: dotnet nuget push packages/*.nupkg --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Create GitHub release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ env.PACKAGE_VERSION }}
tag_name: v${{ env.PACKAGE_VERSION }}
body: |
## Notes

## How to get this update
Packages have been posted to these feeds:

#### NuGet.org
https://nuget.org/packages/McMaster.NETCore.Plugins/${{ env.PACKAGE_VERSION }}
https://nuget.org/packages/McMaster.NETCore.Plugins.Mvc/${{ env.PACKAGE_VERSION }}

#### GitHub Package Registry
https://github.com/natemcmaster?tab=packages&repo_name=DotNetCorePlugins

draft: true
prerelease: ${{ env.IS_STABLE_BUILD == 'false' }} # Example: v3.1.0-beta
files: packages/*
dotnet-version: '10.0.x'
- name: 跑断言
run: dotnet test test/Hosihikari.Tests/Hosihikari.McMaster.NETCore.Plugins.Tests.csproj -c Release --nologo
56 changes: 56 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: publish

on:
push:
tags: ['v*']
workflow_dispatch:

jobs:
nuget:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # 换 OIDC 令牌(Trusted Publishing)

steps:
- uses: actions/checkout@v7

- uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'

# 标签与包版本漂了就在构建前停下。
- name: 版本一致
if: startsWith(github.ref, 'refs/tags/')
shell: pwsh
run: |
$tag = '${{ github.ref_name }}' -replace '^v', ''
$version = dotnet msbuild src/Plugins/McMaster.NETCore.Plugins.csproj -getProperty:PackageVersion
if ($version -ne $tag) { throw "PackageVersion 是 $version,标签是 $tag" }

# 版本号的事实源是 csproj 里的 <PackageVersion>,标签只是触发器。
- name: 打包
run: dotnet pack src/Plugins/McMaster.NETCore.Plugins.csproj -c Release -o out

# 用 OIDC 令牌换一把临时 API key —— 仓库里不存任何长期密钥。
# 换来的 key 只有一小时有效期、且一个令牌只能换一把,所以这一步紧贴推送。
- name: 换临时 API key
uses: NuGet/login@v1
id: login
with:
# nuget.org 的用户名(profile name),不是邮箱。
user: ${{ secrets.NUGET_USER }}

- name: 推送
run: >
dotnet nuget push out/*.nupkg
--api-key ${{ steps.login.outputs.NUGET_API_KEY }}
--source https://api.nuget.org/v3/index.json
--skip-duplicate

- name: 推送符号
run: >
dotnet nuget push out/*.snupkg
--api-key ${{ steps.login.outputs.NUGET_API_KEY }}
--source https://api.nuget.org/v3/index.json
--skip-duplicate
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
- uses: actions/stale@v11
with:
debug-only: ${{ github.event.inputs.debug-only == 'true' }}
days-before-stale: 365
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
bin/
obj/
.build/
.vs/
artifacts/
.idea/
Expand Down
7 changes: 5 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## Project Overview

DotNetCorePlugins is a .NET library for dynamically loading .NET assemblies as plugins with fine-grained control over assembly isolation and type sharing. Version 2.0+ targets .NET 8.0.
DotNetCorePlugins is a .NET library for dynamically loading .NET assemblies as plugins with fine-grained control over assembly isolation and type sharing. This is the Hosihikari fork (see [FORK.md](FORK.md)); it targets .NET 10.

## Build Commands

Expand All @@ -18,7 +18,7 @@ pwsh ./build.ps1 -ci
# Individual commands
dotnet format # Code formatting
dotnet build # Build all projects
dotnet test test/Plugins.Tests # Run tests
dotnet test test/Hosihikari.Tests -c Release # RID probe tests
dotnet pack -o artifacts/ # Create NuGet packages
```

Expand Down Expand Up @@ -48,6 +48,9 @@ Include `[ci skip]` in a commit message to skip CI builds.

- `test/Plugins.Tests/`: xUnit tests
- `test/TestProjects/`: 30+ test assemblies for various plugin scenarios
- `test/Hosihikari.Tests/`: the RID-specific native probe

Upstream `samples/` is not carried in this fork.

## Code Conventions

Expand Down
Loading