Skip to content

Commit 100ade5

Browse files
committed
feat: enable NuGet publishing and update docs with feature switches
Enable ENABLE_NUGET and document all 5 CI feature switches (ENABLE_NUGET, NUGET_USE_OIDC, ENABLE_INSTALLERS, ENABLE_ANDROID, ENABLE_IOS) across README, CONTRIBUTING, and VitePress docs (EN/ZH). Add init script references to getting-started guides. Made-with: Cursor
1 parent d864e4c commit 100ade5

9 files changed

Lines changed: 103 additions & 26 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ env:
3939
DOTNET_CLI_TELEMETRY_OPTOUT: true
4040
NUKE_TELEMETRY_OPTOUT: true
4141
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
42-
ENABLE_NUGET: 'false'
42+
ENABLE_NUGET: 'true'
4343
NUGET_USE_OIDC: 'false'
4444
ENABLE_INSTALLERS: 'true'
4545
ENABLE_ANDROID: 'false'

CONTRIBUTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ Common targets:
3131
| `./build.sh Format` | Verify code formatting |
3232
| `./build.sh Pack` | Create NuGet packages |
3333
| `./build.sh ShowVersion` | Display current version |
34+
| `./build.sh Benchmark` | Run BenchmarkDotNet benchmarks (requires `benchmarks/` projects) |
35+
| `./build.sh MutationTest` | Run Stryker.NET mutation testing |
36+
37+
## CI Feature Switches
38+
39+
The CI pipeline behavior is controlled by boolean switches in `.github/workflows/ci.yml` under `env:`:
40+
41+
| Switch | Default | Purpose |
42+
|--------|---------|---------|
43+
| `ENABLE_NUGET` | `true` | NuGet package generation and publishing |
44+
| `NUGET_USE_OIDC` | `false` | `false` = API key, `true` = Trusted Publishing (OIDC) |
45+
| `ENABLE_INSTALLERS` | `true` | Platform installer zips (Publish + PackageApp) |
46+
| `ENABLE_ANDROID` | `false` | Android workload in build matrix |
47+
| `ENABLE_IOS` | `false` | iOS workload in build matrix |
3448

3549
## Development Workflow
3650

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,33 @@ Product Code (src/) + Tests (tests/)
7676

7777
## Quick Start
7878

79-
1. Create your repository from this template:
79+
1. Create your repository from this template:
8080
[Use this template](https://github.com/AGIBuild/dotnet.CI.template/generate)
81-
2. Configure `release` environment in GitHub (`Settings` -> `Environments`)
82-
3. Optional: add `NUGET_API_KEY`
83-
4. Push to `main` and approve release deployment in Actions
81+
2. Run the init wizard to rename everything:
8482

8583
```bash
86-
git push origin main
84+
./init.sh # interactive (Linux/macOS)
85+
./init.ps1 # interactive (Windows)
8786
```
8887

88+
3. Configure `release` environment in GitHub (`Settings` -> `Environments`)
89+
4. Add `NUGET_API_KEY` secret (if `ENABLE_NUGET` is `true`)
90+
5. Review [Feature Switches](#feature-switches), then push to `main`
91+
92+
## Feature Switches
93+
94+
All switches live in `.github/workflows/ci.yml` under the top-level `env:` block.
95+
96+
| Switch | Default | Purpose |
97+
|---|---|---|
98+
| `ENABLE_NUGET` | `true` | NuGet package generation and publishing |
99+
| `NUGET_USE_OIDC` | `false` | `false` = API key, `true` = Trusted Publishing (OIDC) |
100+
| `ENABLE_INSTALLERS` | `true` | Platform installer zips (Publish + PackageApp) |
101+
| `ENABLE_ANDROID` | `false` | Android workload in build matrix |
102+
| `ENABLE_IOS` | `false` | iOS workload in build matrix |
103+
104+
When `ENABLE_NUGET` is `true`, either `NUGET_API_KEY` secret or OIDC trust policy must be configured; otherwise the release will fail with a clear error.
105+
89106
## Key Commands
90107

91108
```bash
@@ -94,6 +111,8 @@ git push origin main
94111
./build.sh UpdateVersion --VersionPrefix 1.0.0 # set exact version
95112
./build.sh Test # build + test
96113
./build.sh Pack # build + test + pack
114+
./build.sh Benchmark # run benchmarks (benchmarks/ projects)
115+
./build.sh MutationTest # run Stryker.NET mutation testing
97116
```
98117

99118
## Documentation

docs/contributing/ci-cd.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ For a quick release walkthrough, see: [Releasing](releasing.md).
5454

5555
### `release`
5656
- Requires `release` environment approval (single approval gate)
57-
- Downloads NuGet packages, verifies release manifest SHA256 integrity
58-
- Pushes NuGet packages to nuget.org (skipped if `NUGET_API_KEY` is not configured)
57+
- If `ENABLE_NUGET` is `true`: downloads NuGet packages, verifies release manifest SHA256 integrity, pushes to nuget.org via API key or OIDC (controlled by `NUGET_USE_OIDC`)
58+
- If `ENABLE_INSTALLERS` is `true`: downloads platform installer zips
5959
- Generates SBOM (SPDX format, `anchore/sbom-action`)
60-
- Creates Artifact Attestation (`actions/attest-build-provenance`, signs build provenance for NuGet packages and installer zips)
60+
- Creates Artifact Attestation for all available artifacts (NuGet packages and/or installer zips)
6161
- Creates a git tag and pushes to remote
62-
- Creates a GitHub Release with platform installer zips + SBOM file attached
62+
- Creates a GitHub Release with available assets (installer zips and/or SBOM)
6363

6464
### `build-docs`
6565
- Runs on every push/PR, in parallel with `build-and-test` (pre-check)
@@ -87,8 +87,24 @@ The repository includes built-in VitePress documentation support. To enable docu
8787
- Expected documentation URL: `https://<owner>.github.io/<repo>/`
8888
- The `Resolve Version` summary displays this URL for quick access
8989

90+
### Feature Switches
91+
92+
All switches live in `ci.yml` under the top-level `env:` block. Change their values to `'true'` or `'false'` to enable or disable pipeline features.
93+
94+
| Switch | Default | Purpose |
95+
|--------|---------|---------|
96+
| `ENABLE_NUGET` | `true` | NuGet package generation (Pack) and publishing to nuget.org |
97+
| `NUGET_USE_OIDC` | `false` | `false` = push via `NUGET_API_KEY` secret; `true` = push via OIDC Trusted Publishing |
98+
| `ENABLE_INSTALLERS` | `true` | Platform installer zips (Publish + PackageApp) |
99+
| `ENABLE_ANDROID` | `false` | Include Android workload in the build matrix |
100+
| `ENABLE_IOS` | `false` | Include iOS workload in the build matrix |
101+
102+
When `ENABLE_NUGET` is `true`:
103+
- If `NUGET_USE_OIDC` is `false`, the `NUGET_API_KEY` secret must be configured; otherwise the release fails with an explicit error.
104+
- If `NUGET_USE_OIDC` is `true`, a Trusted Publishing trust policy must be configured on nuget.org for the repository.
105+
90106
### Secrets
91-
- `NUGET_API_KEY`: NuGet.org API key (configure at the repo or `release` environment level)
107+
- `NUGET_API_KEY`: NuGet.org API key (required when `ENABLE_NUGET` is `true` and `NUGET_USE_OIDC` is `false`)
92108

93109
---
94110

docs/contributing/releasing.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Goal: **Complete a standard Release quickly**.
99

1010
- You have write access to the repository
1111
- `main` branch is up to date and CI is passing
12-
- If publishing to NuGet, the `NUGET_API_KEY` secret is configured
12+
- If `ENABLE_NUGET` is `true`: the `NUGET_API_KEY` secret (or OIDC trust policy) is configured
1313
- A `release` environment is created in GitHub (Settings → Environments) with required reviewers
1414

1515
---
@@ -45,8 +45,8 @@ After a successful run, you should see:
4545

4646
- A new tag (e.g., `v0.2.0`)
4747
- A new GitHub Release
48-
- Release assets including platform installer zips (`app-linux-x64.zip`, `app-win-x64.zip`, etc.) and the SBOM file
49-
- A corresponding package version on NuGet.org (if `NUGET_API_KEY` is configured)
48+
- Release assets: installer zips (if `ENABLE_INSTALLERS` is `true`) and the SBOM file
49+
- A corresponding package version on NuGet.org (if `ENABLE_NUGET` is `true`)
5050
- If Pages is enabled: documentation deployed automatically
5151

5252
---
@@ -70,7 +70,7 @@ After committing the change to `main`, CI automatically builds and publishes wit
7070
- `Tag already exists`: This version was already released; bump `VersionPrefix` and retry
7171
- `No .nupkg files found`: No artifacts from the packaging stage; check Build/Test/Pack logs
7272
- `Hash mismatch`: Build artifacts were corrupted during transfer; re-trigger the workflow
73-
- NuGet push failed: Verify that the `NUGET_API_KEY` secret is configured
73+
- NuGet push failed: Verify that `ENABLE_NUGET` is `true` and the credential (API key or OIDC) is configured correctly
7474

7575
---
7676

docs/guide/getting-started.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ var quotient = calculator.Divide(10, 2); // 5
2222
## Using as a Template
2323

2424
1. Click **Use this template** on the [GitHub repository](https://github.com/AGIBuild/dotnet.CI.template).
25-
2. Rename solution, projects, and namespaces to match your product.
25+
2. Run the init wizard to rename solution, projects, and namespaces:
26+
27+
```bash
28+
./init.sh # Linux / macOS
29+
./init.ps1 # Windows (PowerShell)
30+
```
31+
2632
3. Replace the sample `Calculator` class with your own code.
2733
4. Update `Directory.Build.props` with your package metadata.
2834
5. Configure the `release` environment in GitHub Settings (see [Releasing](../contributing/releasing.md)).

docs/zh-cn/contributing/ci-cd.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ push / PR to main + weekly
5454

5555
### `release`
5656
- 需要 `release` environment approval(唯一的审批入口)
57-
- 下载 NuGet 包,验证 release manifest SHA256 完整性
58-
- 推送 NuGet 包到 nuget.org(如未配置 `NUGET_API_KEY` 则跳过)
57+
- `ENABLE_NUGET``true`下载 NuGet 包,验证 release manifest SHA256 完整性,通过 API key 或 OIDC 推送到 nuget.org(由 `NUGET_USE_OIDC` 控制)
58+
- `ENABLE_INSTALLERS``true`:下载各平台安装包 zip
5959
- 生成 SBOM(SPDX 格式,`anchore/sbom-action`
60-
- 创建 Artifact Attestation(`actions/attest-build-provenance`,为 NuGet 包和安装包签署构建来源证明
60+
- 创建 Artifact Attestation(为所有可用产物签署构建来源证明
6161
- 创建 git tag 并推送到 remote
62-
- 创建 GitHub Release,附带各平台安装包 zip + SBOM 文件
62+
- 创建 GitHub Release,附带可用产物(安装包 zip 和/或 SBOM 文件
6363

6464
### `build-docs`
6565
- 每次 push/PR 均运行,与 `build-and-test` 并行(前置检查)
@@ -87,8 +87,24 @@ push / PR to main + weekly
8787
- 预期文档地址:`https://<owner>.github.io/<repo>/`
8888
- `Resolve Version` 的 Summary 会固定显示该地址,便于快速访问
8989

90+
### 功能开关
91+
92+
所有开关位于 `ci.yml` 顶层 `env:` 块中,将值改为 `'true'``'false'` 即可启用/禁用对应功能。
93+
94+
| 开关 | 默认值 | 作用 |
95+
|------|--------|------|
96+
| `ENABLE_NUGET` | `true` | NuGet 包生成(Pack)和发布到 nuget.org |
97+
| `NUGET_USE_OIDC` | `false` | `false` = 使用 `NUGET_API_KEY``true` = 使用 OIDC Trusted Publishing |
98+
| `ENABLE_INSTALLERS` | `true` | 平台安装包 zip(Publish + PackageApp) |
99+
| `ENABLE_ANDROID` | `false` | 构建矩阵中包含 Android workload |
100+
| `ENABLE_IOS` | `false` | 构建矩阵中包含 iOS workload |
101+
102+
`ENABLE_NUGET``true` 时:
103+
-`NUGET_USE_OIDC``false`,必须配置 `NUGET_API_KEY` secret,否则 release 会明确报错。
104+
-`NUGET_USE_OIDC``true`,需要在 nuget.org 上为该仓库配置 Trusted Publishing 信任策略。
105+
90106
### Secrets
91-
- `NUGET_API_KEY`:NuGet.org API key(在 repo 或 `release` environment 级别配置
107+
- `NUGET_API_KEY`:NuGet.org API key(`ENABLE_NUGET``true``NUGET_USE_OIDC``false` 时必须配置
92108

93109
---
94110

docs/zh-cn/contributing/releasing.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
- 你有仓库写权限
1111
- `main` 分支是最新、CI 通过
12-
- 如果要推 NuGet,仓库已配置 `NUGET_API_KEY` secret
12+
- 如果 `ENABLE_NUGET``true`:已配置 `NUGET_API_KEY` secret(或 OIDC 信任策略)
1313
- GitHub 仓库已创建 `release` environment(Settings → Environments),并配置 required reviewers
1414

1515
---
@@ -45,8 +45,8 @@ resolve-version─┤ ├→ d
4545

4646
- 新 tag(例如 `v0.2.0`
4747
- 一个新的 GitHub Release
48-
- Release 附件里有各平台安装包 zip(`app-linux-x64.zip``app-win-x64.zip`)和 SBOM 文件
49-
- NuGet.org 上有对应版本的包(如已配置 `NUGET_API_KEY`
48+
- Release 附件:安装包 zip(`ENABLE_INSTALLERS``true`)和 SBOM 文件
49+
- NuGet.org 上有对应版本的包(`ENABLE_NUGET``true`
5050
- 如果已启用 Pages:文档自动部署
5151

5252
---
@@ -70,7 +70,7 @@ resolve-version─┤ ├→ d
7070
- `Tag already exists`: 版本已发过,先提升 `VersionPrefix` 再重试
7171
- `No .nupkg files found`: 打包阶段没有产物,先看 Build/Test/Pack 日志
7272
- `Hash mismatch`: 构建产物在传递过程中损坏,重新触发 workflow
73-
- NuGet 推送失败: 确认 `NUGET_API_KEY` secret 已配置
73+
- NuGet 推送失败: 确认 `ENABLE_NUGET``true` 且凭据(API key 或 OIDC)已正确配置
7474

7575
---
7676

docs/zh-cn/guide/getting-started.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ var quotient = calculator.Divide(10, 2); // 5
2222
## 作为模板使用
2323

2424
1.[GitHub 仓库](https://github.com/AGIBuild/dotnet.CI.template)点击 **Use this template**
25-
2. 重命名解决方案、项目和命名空间以匹配你的产品。
25+
2. 运行初始化向导,自动重命名解决方案、项目和命名空间:
26+
27+
```bash
28+
./init.sh # Linux / macOS
29+
./init.ps1 # Windows (PowerShell)
30+
```
31+
2632
3. 用你自己的代码替换示例 `Calculator` 类。
2733
4. 更新 `Directory.Build.props` 中的包元数据。
2834
5. 在 GitHub Settings 中配置 `release` environment(参见[发版指南](../contributing/releasing.md))。

0 commit comments

Comments
 (0)