1+ name : CI/CD Pipeline
2+
3+ on :
4+ pull_request :
5+ paths :
6+ - ' source/**'
7+ - ' tests/**'
8+ - ' .github/workflows/ci-cd.yml'
9+ - ' *.props'
10+ - ' *.targets'
11+ - ' Directory.Build.props'
12+ push :
13+ branches :
14+ - master
15+ paths :
16+ - ' source/**'
17+ - ' tests/**'
18+ - ' .github/workflows/ci-cd.yml'
19+ - ' Directory.Build.props'
20+ - ' *.props'
21+ - ' *.targets'
22+ - ' Documentation/**'
23+ release :
24+ types : [created]
25+ workflow_dispatch :
26+
27+ env :
28+ DOTNET_NOLOGO : true
29+ DOTNET_SKIP_FIRST_TIME_EXPERIENCE : true
30+ DOTNET_CLI_TELEMETRY_OPTOUT : true
31+ NUGET_AUTH_TOKEN : ${{ secrets.PUBLISH_TO_NUGET_ORG }}
32+
33+ jobs :
34+ # CI/CD job for PR and push events
35+ ci :
36+ if : github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/master')
37+ runs-on : ubuntu-latest
38+ defaults :
39+ run :
40+ shell : pwsh
41+ steps :
42+ - name : Checkout code
43+ uses : actions/checkout@v4
44+
45+ - name : Cache NuGet packages
46+ uses : actions/cache@v4
47+ with :
48+ path : ~/.nuget/packages
49+ key : ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
50+ restore-keys : |
51+ ${{ runner.os }}-nuget-
52+
53+ - name : Setup .NET
54+ uses : actions/setup-dotnet@v4
55+ with :
56+ dotnet-version : |
57+ 9.0.x
58+ 10.0.100-preview.7.25380.108
59+
60+ - name : Clean solution
61+ run : dotnet run --project ./scripts/clean.cs
62+ working-directory : ${{ github.workspace }}
63+
64+ - name : Build solution
65+ run : dotnet run --project ./scripts/build.cs
66+ working-directory : ${{ github.workspace }}
67+
68+ - name : Run tests
69+ run : dotnet run --project ./scripts/test.cs
70+ working-directory : ${{ github.workspace }}
71+
72+ - name : Run E2E tests
73+ run : dotnet run --project ./scripts/e2e.cs
74+ working-directory : ${{ github.workspace }}
75+ env :
76+ UseHttp : " true"
77+
78+ # Documentation publishing job
79+ docs :
80+ if : github.event_name == 'push' && github.ref == 'refs/heads/master' && contains(github.event.head_commit.modified, 'Documentation/')
81+ runs-on : windows-latest
82+ defaults :
83+ run :
84+ shell : pwsh
85+ permissions :
86+ contents : read
87+ pages : write
88+ id-token : write
89+ environment :
90+ name : github-pages
91+ url : ${{ steps.deployment.outputs.page_url }}
92+ concurrency :
93+ group : " pages"
94+ cancel-in-progress : false
95+ steps :
96+ - name : Checkout code
97+ uses : actions/checkout@v4
98+
99+ - name : Cache NuGet packages
100+ uses : actions/cache@v4
101+ with :
102+ path : ~/.nuget/packages
103+ key : ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
104+ restore-keys : |
105+ ${{ runner.os }}-nuget-
106+
107+ - name : Setup .NET
108+ uses : actions/setup-dotnet@v4
109+ with :
110+ dotnet-version : 8.x
111+
112+ - name : Setup DocFX
113+ run : dotnet tool update --global docfx
114+
115+ - name : Build solution
116+ run : dotnet run --project ./scripts/build.cs
117+ working-directory : ${{ github.workspace }}
118+
119+ - name : Build documentation
120+ working-directory : Documentation
121+ run : docfx docfx.json
122+
123+ - name : Setup Pages
124+ uses : actions/configure-pages@v5
125+
126+ - name : Upload documentation
127+ uses : actions/upload-pages-artifact@v3
128+ with :
129+ path : ' ./Documentation/_site'
130+
131+ - name : Deploy to GitHub Pages
132+ id : deployment
133+ uses : actions/deploy-pages@v4
134+
135+ # Release publishing job
136+ release :
137+ if : github.event_name == 'release' || github.event_name == 'workflow_dispatch'
138+ runs-on : ubuntu-latest
139+ defaults :
140+ run :
141+ shell : pwsh
142+ steps :
143+ - name : Checkout code
144+ uses : actions/checkout@v4
145+
146+ - name : Cache NuGet packages
147+ uses : actions/cache@v4
148+ with :
149+ path : ~/.nuget/packages
150+ key : ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
151+ restore-keys : |
152+ ${{ runner.os }}-nuget-
153+
154+ - name : Setup .NET
155+ uses : actions/setup-dotnet@v4
156+ with :
157+ dotnet-version : ' 8.0.403'
158+
159+ - name : Extract version from source/Directory.Build.props
160+ id : extract_version
161+ run : |
162+ [xml]$xml = Get-Content -Path "source/Directory.Build.props"
163+ $version = $xml.SelectSingleNode("//TimeWarpStateVersion").InnerText
164+ $version = $version.Trim()
165+ echo "version=$version" >> $env:GITHUB_OUTPUT
166+ shell : pwsh
167+
168+ - name : Validate release version matches tag
169+ if : github.event_name == 'release'
170+ run : |
171+ $releaseVersion = "${{ steps.extract_version.outputs.version }}"
172+ $tagName = "${{ github.event.release.tag_name }}"
173+ $tagNameForComparison = $tagName
174+ if ($tagName.StartsWith("v")) {
175+ $tagNameForComparison = $tagName.Substring(1)
176+ }
177+
178+ if ($releaseVersion -ne $tagNameForComparison) {
179+ throw "Release version ($releaseVersion) does not match tag name ($tagName)"
180+ }
181+ Write-Host "✅ Release version matches tag name"
182+ shell : pwsh
183+
184+ - name : Create NuGet packages
185+ run : dotnet run --project ./scripts/package.cs
186+ working-directory : ${{ github.workspace }}
187+
188+ - name : Publish TimeWarp.State to NuGet
189+ run : |
190+ $packagePath = "./artifacts/packages/TimeWarp.State.*.nupkg"
191+ if (!(Test-Path $packagePath)) {
192+ throw "NuGet package not found for TimeWarp.State"
193+ }
194+ dotnet nuget push $packagePath --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.PUBLISH_TO_NUGET_ORG }}
195+ working-directory : ${{ github.workspace }}
196+
197+ - name : Publish TimeWarp.State.Plus to NuGet
198+ run : |
199+ $packagePath = "./artifacts/packages/TimeWarp.State.Plus.*.nupkg"
200+ if (!(Test-Path $packagePath)) {
201+ throw "NuGet package not found for TimeWarp.State.Plus"
202+ }
203+ dotnet nuget push $packagePath --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.PUBLISH_TO_NUGET_ORG }}
204+ working-directory : ${{ github.workspace }}
205+
206+ - name : Publish TimeWarp.State.Policies to NuGet
207+ run : |
208+ $packagePath = "./artifacts/packages/TimeWarp.State.Policies.*.nupkg"
209+ if (!(Test-Path $packagePath)) {
210+ throw "NuGet package not found for TimeWarp.State.Policies"
211+ }
212+ dotnet nuget push $packagePath --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.PUBLISH_TO_NUGET_ORG }}
213+ working-directory : ${{ github.workspace }}
0 commit comments