-
Notifications
You must be signed in to change notification settings - Fork 0
406 lines (346 loc) · 14.6 KB
/
Copy pathdotnet.yml
File metadata and controls
406 lines (346 loc) · 14.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
name: FastFind.NET Build & Deploy
on:
# Manual trigger - Always available for direct execution
workflow_dispatch:
inputs:
push_to_nuget:
description: 'Push packages to NuGet (even without version tag)'
required: false
default: false
type: boolean
# Automatic trigger - source changes are validated; a version change also deploys
push:
branches: [ "main" ]
paths:
- 'src/**' # Source changes must be built and tested
- '.github/workflows/**' # Workflow updates
# Pull request validation - Build validation only (tests run locally)
pull_request:
branches: [ "main" ]
paths:
- 'src/**'
- '.github/workflows/**'
env:
DOTNET_VERSION: '10.0.x'
SOLUTION_PATH: 'src/FastFind.sln'
jobs:
# 🧭 배포 여부 결정 — 이 워크플로에서 단 한 번만 판정한다.
# pack-and-publish 는 매트릭스 잡이라 job output 이 어느 leg 의 값인지 보장되지 않는다.
# 판정을 독립 잡으로 분리해야 create-release 가 신뢰할 수 있는 output 을 참조할 수 있다.
decide:
runs-on: ubuntu-latest
outputs:
should_deploy: ${{ steps.check.outputs.SHOULD_DEPLOY }}
version: ${{ steps.check.outputs.CURRENT_VERSION }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Decide whether this run deploys
id: check
env:
EVENT_NAME: ${{ github.event_name }}
EVENT_BEFORE: ${{ github.event.before }}
EVENT_SHA: ${{ github.sha }}
GIT_REF: ${{ github.ref }}
MANUAL_PUSH: ${{ github.event.inputs.push_to_nuget }}
run: |
set -euo pipefail
CURRENT_VERSION=$(grep -oP '<Version>\K[^<]+' src/Directory.Build.props)
SHOULD_DEPLOY="false"
REASON="no_trigger"
echo "📦 Current version: ${CURRENT_VERSION}"
# A push to main that changes the declared version is the release trigger.
if [ "${EVENT_NAME}" = "push" ] \
&& [ "${GIT_REF}" = "refs/heads/main" ] \
&& [ "${EVENT_BEFORE}" != "0000000000000000000000000000000000000000" ]; then
if git diff --name-only "${EVENT_BEFORE}..${EVENT_SHA}" | grep -q '^src/Directory.Build.props$'; then
PREVIOUS_VERSION=$(git show "${EVENT_BEFORE}:src/Directory.Build.props" | grep -oP '<Version>\K[^<]+' || echo "0.0.0")
echo "📊 ${PREVIOUS_VERSION} → ${CURRENT_VERSION}"
if [ "${PREVIOUS_VERSION}" != "${CURRENT_VERSION}" ]; then
SHOULD_DEPLOY="true"
REASON="version_change_on_main"
else
REASON="props_change_no_version"
fi
fi
fi
# Manual override.
if [ "${MANUAL_PUSH:-false}" = "true" ]; then
SHOULD_DEPLOY="true"
REASON="manual_trigger"
fi
echo "SHOULD_DEPLOY=${SHOULD_DEPLOY}" >> "$GITHUB_OUTPUT"
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> "$GITHUB_OUTPUT"
echo "📋 Should deploy: ${SHOULD_DEPLOY} (${REASON})"
# 🔍 빌드 검증 — PR 과 main push 양쪽
validate:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
steps:
- uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v6
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('src/Directory.Packages.props', '**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore ${{ env.SOLUTION_PATH }}
- name: Build solution
run: dotnet build ${{ env.SOLUTION_PATH }} --configuration Release --no-restore
# 🐧 Linux 테스트 (PR + push to main)
test-linux:
runs-on: ubuntu-latest
if: >
github.event_name == 'pull_request' ||
(github.event_name == 'push' && github.ref == 'refs/heads/main')
steps:
- uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v6
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('src/Directory.Packages.props', '**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Build Unix Tests
run: dotnet build src/FastFind.Unix.Tests/FastFind.Unix.Tests.csproj --configuration Release
- name: Run Linux Tests
run: dotnet test src/FastFind.Unix.Tests/FastFind.Unix.Tests.csproj --configuration Release --no-build --logger "trx;LogFileName=test-results.trx" --results-directory ./test-results
- name: Upload test results
uses: actions/upload-artifact@v7
if: always()
with:
name: linux-test-results
path: ./test-results/
retention-days: 1
# 🪟 Windows 테스트 (PR + main push) — 이 라이브러리의 주 플랫폼이고,
# 배포는 이 잡을 통과해야만 진행된다.
test-windows:
runs-on: windows-latest
if: >
github.event_name == 'pull_request' ||
(github.event_name == 'push' && github.ref == 'refs/heads/main')
steps:
- uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v6
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('src/Directory.Packages.props', '**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Build Windows Tests
run: dotnet build src/FastFind.Windows.Tests/FastFind.Windows.Tests.csproj --configuration Release
- name: Run Windows Tests
run: dotnet test src/FastFind.Windows.Tests/FastFind.Windows.Tests.csproj --configuration Release --no-build --filter "Category!=Performance" --logger "trx;LogFileName=test-results.trx" --results-directory ./test-results
- name: Upload test results
uses: actions/upload-artifact@v7
if: always()
with:
name: windows-test-results
path: ./test-results/
retention-days: 1
# 🍎 macOS 테스트 (수동 트리거 전용 — 비용 최소화)
test-macos:
runs-on: macos-latest
if: github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v6
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('src/Directory.Packages.props', '**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Build Unix Tests
run: dotnet build src/FastFind.Unix.Tests/FastFind.Unix.Tests.csproj --configuration Release
- name: Run macOS Tests
run: dotnet test src/FastFind.Unix.Tests/FastFind.Unix.Tests.csproj --configuration Release --no-build --filter "Category!=Performance" --logger "trx;LogFileName=test-results.trx" --results-directory ./test-results
- name: Upload test results
uses: actions/upload-artifact@v7
if: always()
with:
name: macos-test-results
path: ./test-results/
retention-days: 1
# 🐳 Linux 호환성 테스트 (수동 트리거 전용)
test-linux-compat:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
strategy:
matrix:
container: ['mcr.microsoft.com/dotnet/sdk:10.0']
container:
image: ${{ matrix.container }}
steps:
- uses: actions/checkout@v7
- name: Build & Test
run: |
dotnet build src/FastFind.Unix.Tests/FastFind.Unix.Tests.csproj --configuration Release
dotnet test src/FastFind.Unix.Tests/FastFind.Unix.Tests.csproj --configuration Release --no-build
# 📦 빌드 및 배포 (테스트는 로컬에서만 수행)
pack-and-publish:
runs-on: ubuntu-latest
# 배포는 되돌릴 수 없다 — NuGet 패키지는 unlist 만 되고 삭제되지 않는다.
# 따라서 pack 은 빌드·테스트 잡을 통과한 뒤에만 실행한다.
# workflow_dispatch 에서는 그 잡들이 skipped 이고, skipped 는 failure 가 아니므로
# !failure() 가 참이 되어 기존 수동 검증 경로는 그대로 동작한다.
needs: [decide, validate, test-linux, test-windows]
if: >
!failure() && !cancelled() &&
(needs.decide.outputs.should_deploy == 'true' || github.event_name == 'workflow_dispatch')
strategy:
matrix:
project:
- path: 'src/FastFind/FastFind.csproj'
name: 'FastFind.Core'
- path: 'src/FastFind.Windows/FastFind.Windows.csproj'
name: 'FastFind.Windows'
- path: 'src/FastFind.SQLite/FastFind.SQLite.csproj'
name: 'FastFind.SQLite'
- path: 'src/FastFind.Unix/FastFind.Unix.csproj'
name: 'FastFind.Unix'
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # Full history for version comparison
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v6
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('src/Directory.Packages.props', '**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore ${{ env.SOLUTION_PATH }}
- name: Build ${{ matrix.project.name }}
run: dotnet build ${{ matrix.project.path }} --configuration Release --no-restore
- name: Pack ${{ matrix.project.name }}
run: dotnet pack ${{ matrix.project.path }} --configuration Release --no-build --output nupkg
- name: List generated packages
run: ls -la nupkg/
- name: Validate package
run: |
for package in nupkg/*.nupkg; do
echo "Validating package: $package"
dotnet nuget verify "$package" || echo "Package verification failed for $package"
done
- name: Push ${{ matrix.project.name }} to NuGet
if: needs.decide.outputs.should_deploy == 'true'
run: |
echo "🚀 Deploying ${{ matrix.project.name }} v${{ needs.decide.outputs.version }} to NuGet"
echo "📦 Packages in nupkg/:"
ls -la nupkg/
echo "📤 Pushing to NuGet..."
dotnet nuget push ./nupkg/*.nupkg \
--source https://api.nuget.org/v3/index.json \
--api-key ${{ secrets.NUGET_API_KEY }} \
--skip-duplicate \
--no-symbols
echo "✅ NuGet deployment completed for ${{ matrix.project.name }} v${{ needs.decide.outputs.version }}"
# Release 에 attach 하기 위한 중간 산출물 — create-release 가 끝나면 즉시 삭제된다.
- name: Upload packages
uses: actions/upload-artifact@v7
with:
name: nuget-packages-${{ matrix.project.name }}
path: nupkg/*.nupkg
retention-days: 1
create-release:
needs: [decide, pack-and-publish]
runs-on: ubuntu-latest
if: needs.decide.outputs.should_deploy == 'true' && github.ref == 'refs/heads/main'
# contents: 태그와 릴리스 생성. actions: 아래 delete-artifact 가 artifact 를 지운다.
permissions:
contents: write
actions: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # Full history for changelog generation
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts/
- name: Get version info
id: version
run: |
echo "VERSION=v${{ needs.decide.outputs.version }}" >> "$GITHUB_OUTPUT"
echo "Using version: v${{ needs.decide.outputs.version }}"
- name: Generate changelog
id: changelog
run: |
if [ "${{ steps.version.outputs.VERSION }}" != "$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo 'v0.0.0')" ]; then
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo 'HEAD~10')
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "### 📋 Changes from ${PREVIOUS_TAG}" >> $GITHUB_OUTPUT
git log ${PREVIOUS_TAG}..HEAD --oneline --pretty=format:'- %s (%h)' >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "CHANGELOG=### 📋 Changes\nSee commit history for details." >> $GITHUB_OUTPUT
fi
- name: Create Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.version.outputs.VERSION }}
name: FastFind.NET ${{ steps.version.outputs.VERSION }}
body: |
## FastFind.NET ${{ steps.version.outputs.VERSION }}
### 📦 Published Packages
- **FastFind.Core**: Core interfaces, models, cross-platform SIMD string matching
- **FastFind.Windows**: Windows-optimized implementation (MFT, USN Journal)
- **FastFind.Unix**: Linux and macOS implementation (Channel BFS, inotify/FSEvents)
- **FastFind.SQLite**: SQLite persistence provider
### 🚀 Key Features
- Cross-platform SIMD string matching (Vector256/Vector128 auto-dispatch)
- String interning to avoid retaining a copy of every repeated path segment
- Real-time file system monitoring (USN Journal / inotify)
- Windows: NTFS MFT direct enumeration
- Linux: Channel-based BFS parallel enumeration
- Optional disk-backed index, so memory need not grow with the corpus
${{ steps.changelog.outputs.CHANGELOG }}
### 📥 Installation
```bash
# Core package
dotnet add package FastFind.Core
# Windows implementation
dotnet add package FastFind.Windows
# SQLite persistence
dotnet add package FastFind.SQLite
```
draft: false
prerelease: ${{ contains(steps.version.outputs.VERSION, '-') }}
files: artifacts/**/*.nupkg
generate_release_notes: true
make_latest: ${{ !contains(steps.version.outputs.VERSION, '-') }}
# 패키지는 Release 에 attach 됐으므로 artifact 보관은 저장용량만 차지한다.
- name: Delete packaging artifacts
uses: geekyeggo/delete-artifact@v6
if: always()
with:
name: nuget-packages-*
failOnError: false