|
1 | | -# dotnet.CI.template |
| 1 | +# Dotnet.CI.Template |
2 | 2 |
|
3 | 3 | [](https://github.com/AGIBuild/dotnet.CI.template/actions/workflows/ci.yml) |
4 | 4 | [](https://github.com/AGIBuild/dotnet.CI.template/actions/workflows/codeql.yml) |
5 | 5 | [](LICENSE) |
6 | 6 |
|
7 | | -**Stop wiring CI from scratch.** Start with a production-grade pipeline that builds, tests, packages, and releases your .NET projects across platforms -- with a single approval click. |
| 7 | +Build your .NET product on top of a complete engineering foundation, not from a blank folder. |
8 | 8 |
|
9 | | ---- |
| 9 | +This repository is a **productized starter** that gives you: |
| 10 | +- a real project structure (`src/`, `tests/`, `docs/`) |
| 11 | +- a typed build system (NUKE) |
| 12 | +- release-ready delivery (NuGet, GitHub Releases, SBOM, attestation) |
| 13 | +- multilingual documentation (English + Chinese) |
10 | 14 |
|
11 | | -## What You Get |
| 15 | +CI/CD is here, but it is not the protagonist; your product is. |
12 | 16 |
|
13 | | -Use this template and you instantly have: |
| 17 | + |
14 | 18 |
|
15 | | -``` |
16 | | -Push to main |
17 | | - | |
18 | | - v |
19 | | -resolve-version ── Reads VersionPrefix, computes matrix, outputs version info |
20 | | - | |
21 | | - ├──────────────────────────────┐ |
22 | | - v v |
23 | | -build-and-test ─── Matrix build build-docs ── VitePress build (pre-check) |
24 | | - | (3 platforms) | |
25 | | - v | |
26 | | -release ────────── [approval] | |
27 | | - | NuGet + tag | |
28 | | - ├──────────────────────────────┘ |
29 | | - v |
30 | | -deploy-docs ────── Deploy to GitHub Pages (optional, i18n) |
31 | | -``` |
32 | | - |
33 | | -Both **pull requests** and **main pushes** run the full multi-platform matrix (linux / windows / macos) for Build + Test. On **releases** (version bumped), Publish + PackageApp are additionally enabled. |
| 19 | +## Why This Repo Exists |
34 | 20 |
|
35 | | -### Pipeline Highlights |
| 21 | +Most new projects lose momentum in the first week to repetitive setup: |
| 22 | +- wiring build scripts |
| 23 | +- writing CI pipelines |
| 24 | +- standardizing versioning |
| 25 | +- bolting on documentation later |
36 | 26 |
|
37 | | -| Feature | Details | |
38 | | -|---------|---------| |
39 | | -| **NUKE Build** | All build logic lives in C# targets -- no scattered shell scripts in YAML | |
40 | | -| **Single Approval** | One `release` environment gate controls the entire release flow | |
41 | | -| **Multi-Platform Matrix** | linux-x64, win-x64, osx-arm64 (+ optional Android/iOS) | |
42 | | -| **NuGet Publishing** | Auto-push to NuGet.org with SHA256 manifest verification | |
43 | | -| **Installer Packages** | Platform-specific zip archives attached to GitHub Releases | |
44 | | -| **Version from Code** | `VersionPrefix` in `Directory.Build.props` is the single source of truth | |
45 | | -| **SemVer Release Tags** | `v0.2.0` format — release triggers only when version is bumped | |
46 | | -| **CodeQL Security** | Automated vulnerability scanning on every push and weekly | |
47 | | -| **Graceful Degradation** | Missing NuGet key? Skipped. No docs config? Skipped. Nothing breaks. | |
| 27 | +`Dotnet.CI.Template` removes that tax. You start with a working product baseline and focus on business features from day one. |
48 | 28 |
|
49 | | ---- |
50 | | - |
51 | | -## Quick Start |
| 29 | +## Product Capabilities |
52 | 30 |
|
53 | | -### 1. Create your repo from this template |
| 31 | +| Capability | What You Get | Why It Matters | |
| 32 | +|---|---|---| |
| 33 | +| Product-ready structure | `src`, `tests`, `docs`, centralized build properties | Clear boundaries from the beginning | |
| 34 | +| Build system | NUKE targets in `build/BuildTask.*.cs` | Build logic in C#, not YAML sprawl | |
| 35 | +| Version model | `VersionPrefix` as single source of truth | Reproducible, auditable releases | |
| 36 | +| Delivery pipeline | Build, test, pack, publish, package, release | One flow from code to artifacts | |
| 37 | +| Supply-chain trust | SBOM + artifact attestation | Better compliance and traceability | |
| 38 | +| Documentation portal | VitePress with i18n and auto deployment | Docs evolve with code, not after it | |
54 | 39 |
|
55 | | -Click **[Use this template](https://github.com/AGIBuild/dotnet.CI.template/generate)** on GitHub. |
| 40 | +## Experience Snapshot |
56 | 41 |
|
57 | | -### 2. Configure environments |
| 42 | +### Product-first docs experience |
58 | 43 |
|
59 | | -Go to **Settings > Environments** and create a `release` environment with at least one required reviewer. |
| 44 | + |
60 | 45 |
|
61 | | -### 3. Set secrets (optional) |
| 46 | +### CI/CD as one module in Contributing |
62 | 47 |
|
63 | | -| Secret | Purpose | |
64 | | -|--------|---------| |
65 | | -| `NUGET_API_KEY` | Push packages to NuGet.org | |
66 | | - |
67 | | -### 4. Push code and watch it go |
68 | | - |
69 | | -```bash |
70 | | -git push origin main |
71 | | -``` |
| 48 | + |
72 | 49 |
|
73 | | -The pipeline runs automatically. When `build-and-test` completes, go to **Actions > Review deployments** to approve the release. |
| 50 | +## What Makes It Better Than Starting Empty |
74 | 51 |
|
75 | | ---- |
| 52 | +| Comparison | Blank Repo | Dotnet.CI.Template | |
| 53 | +|---|---|---| |
| 54 | +| First successful release | days of setup | built-in path | |
| 55 | +| Build orchestration | mixed shell + YAML | NUKE targets | |
| 56 | +| Version governance | manual and error-prone | semantic, code-owned | |
| 57 | +| Documentation | added later (often stale) | integrated from day one | |
| 58 | +| Artifact provenance | optional / inconsistent | standardized | |
76 | 59 |
|
77 | | -## Project Structure |
| 60 | +## Architecture At A Glance |
78 | 61 |
|
| 62 | +```text |
| 63 | +Product Code (src/) + Tests (tests/) |
| 64 | + | |
| 65 | + v |
| 66 | + NUKE Build Targets (build/) |
| 67 | + | |
| 68 | + v |
| 69 | + CI and Release Workflow (.github/workflows/ci.yml) |
| 70 | + | |
| 71 | + +--> Packages (.nupkg/.snupkg) |
| 72 | + +--> Installers (app-{runtime}.zip) |
| 73 | + +--> SBOM + Attestation |
| 74 | + +--> Docs Site (GitHub Pages) |
79 | 75 | ``` |
80 | | -. |
81 | | -├── .github/workflows/ |
82 | | -│ ├── ci.yml # CI + Release pipeline |
83 | | -│ └── codeql.yml # Security analysis |
84 | | -├── build/ |
85 | | -│ ├── BuildTask.*.cs # NUKE targets (Build, Test, Pack, Publish, PackageApp, ...) |
86 | | -│ └── _build.csproj |
87 | | -├── src/ # Your application code |
88 | | -├── tests/ # Your test projects |
89 | | -├── docs/ # VitePress documentation (English + 中文) |
90 | | -├── Directory.Build.props # Version + shared build properties |
91 | | -└── global.json # SDK version pinning |
92 | | -``` |
93 | | - |
94 | | ---- |
95 | | - |
96 | | -## Version Management |
97 | | - |
98 | | -Versions follow SemVer (3-segment `Major.Minor.Patch`): |
99 | 76 |
|
100 | | -- **`VersionPrefix` in `Directory.Build.props`** is the single source of truth (e.g., `0.2.0`) |
101 | | -- **Tags are created automatically**: `v0.2.0` — release triggers only when the tag doesn't exist yet |
102 | | -- **`FileVersion`** includes the CI build number for traceability (e.g., `0.2.0.42`), visible in DLL properties |
103 | | -- No manual tagging. No version input fields. Bump `VersionPrefix` via PR to trigger a release. |
| 77 | +## Quick Start |
104 | 78 |
|
105 | | -### Version commands |
| 79 | +1. Create your repository from this template: |
| 80 | + [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 |
106 | 84 |
|
107 | 85 | ```bash |
108 | | -./build.sh ShowVersion # show current version |
109 | | -./build.sh UpdateVersion # patch increment: 0.2.0 -> 0.2.1 |
110 | | -./build.sh UpdateVersion --VersionPrefix 1.0.0 # set exact version |
111 | | -``` |
112 | | - |
113 | | -Then commit and push -- CI takes care of the rest. |
114 | | - |
115 | | ---- |
116 | | - |
117 | | -## Extending the Build |
118 | | - |
119 | | -Build logic is in `build/BuildTask.*.cs` using [NUKE](https://nuke.build). Add new targets in C# and call them from workflows: |
120 | | - |
121 | | -```csharp |
122 | | -Target MyTarget => _ => _ |
123 | | - .DependsOn(Build) |
124 | | - .Executes(() => |
125 | | - { |
126 | | - // your build logic here |
127 | | - }); |
128 | | -``` |
129 | | - |
130 | | -```yaml |
131 | | -# in ci.yml |
132 | | -- run: ./build.sh MyTarget |
| 86 | +git push origin main |
133 | 87 | ``` |
134 | 88 |
|
135 | | ---- |
136 | | -
|
137 | | -## Mobile Platform Support |
| 89 | +## Key Commands |
138 | 90 |
|
139 | | -Android and iOS builds are supported but disabled by default. Toggle them in `ci.yml`: |
140 | | - |
141 | | -```yaml |
142 | | -env: |
143 | | - ENABLE_ANDROID: 'true' |
144 | | - ENABLE_IOS: 'true' |
| 91 | +```bash |
| 92 | +./build.sh ShowVersion # show current version |
| 93 | +./build.sh UpdateVersion # patch increment |
| 94 | +./build.sh UpdateVersion --VersionPrefix 1.0.0 # set exact version |
| 95 | +./build.sh Test # build + test |
| 96 | +./build.sh Pack # build + test + pack |
145 | 97 | ``` |
146 | 98 |
|
147 | | ---- |
148 | | - |
149 | | -## Concurrency |
150 | | - |
151 | | -`CI and Release` runs are **serialized per branch** by default. The workflow uses a concurrency group (`ci-${{ github.ref }}`) with `cancel-in-progress: false`, meaning a new run on the same branch queues behind the running one instead of cancelling it. |
152 | | - |
153 | | ---- |
154 | | - |
155 | | -## Documentation Deployment |
156 | | - |
157 | | -Documentation is built with [VitePress](https://vitepress.dev/) and supports English (default) and Chinese. |
158 | | - |
159 | | -To enable automatic documentation deployment to GitHub Pages: |
160 | | - |
161 | | -1. `docs/package.json` is included by default in this template |
162 | | -2. Enable GitHub Pages in **Settings > Pages > Source: GitHub Actions** |
163 | | -3. The `build-docs` job builds VitePress on every push/PR (pre-check); `deploy-docs` deploys after each release |
164 | | -4. Expected docs URL: `https://<owner>.github.io/<repo>/` (for this repo: `https://agibuild.github.io/dotnet.CI.template/`) |
165 | | - |
166 | | -The `Resolve Version` job summary always shows this expected docs URL, even when docs deployment is skipped. |
167 | | -If Pages is not enabled, `deploy-docs` is skipped with a notice instead of failing the whole workflow. |
| 99 | +## Documentation |
168 | 100 |
|
169 | | ---- |
| 101 | +- Live docs: `https://agibuild.github.io/dotnet.CI.template/` |
| 102 | +- Product docs are organized as: |
| 103 | + - `guide/` (product understanding and onboarding) |
| 104 | + - `reference/` (API/reference content) |
| 105 | + - `contributing/` (development, CI/CD, releasing) |
170 | 106 |
|
171 | 107 | ## License |
172 | 108 |
|
|
0 commit comments