-
Notifications
You must be signed in to change notification settings - Fork 0
421 lines (364 loc) · 13 KB
/
Copy pathsdk-cli-release.yml
File metadata and controls
421 lines (364 loc) · 13 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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
name: Evolith SDK CLI - Release Pipeline
on:
push:
branches:
- main
paths:
- 'sdk/cli/**'
- '.release-please-manifest.json'
- 'release-please-config.json'
- '.github/workflows/sdk-cli-release.yml'
- '.harness/**'
workflow_dispatch:
env:
NODE_VERSION: '20'
CLI_DIR: 'sdk/cli'
jobs:
# ============================================
# GATE 0: Evolith Core Validation
# ============================================
core-validation:
name: Evolith Core Validation
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Validate Documentation Standards
run: node .harness/scripts/validate-docs.mjs
- name: Check Bilingual Parity
run: node .harness/scripts/check-bilingual-parity.mjs
- name: Verify Root Cleanliness
run: node .harness/scripts/validate-root-cleanliness.mjs
- name: Verify Version Alignment
run: |
node .harness/scripts/verify-version-log.mjs
node .harness/scripts/verify-git-tag.mjs
# ============================================
# GATE 1: Release Please
# ============================================
release-please:
needs: core-validation
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
release_created: ${{ steps.release.outputs.cli_release_created }}
tag_name: ${{ steps.release.outputs.cli_tag_name }}
version: ${{ steps.release.outputs.cli_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run Release Please
id: release
uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
release-type: node
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
- name: Log Release Decision
if: ${{ steps.release.outputs.cli_release_created }}
run: |
echo "Release created: ${{ steps.release.outputs.cli_tag_name }}"
echo "Version: ${{ steps.release.outputs.cli_version }}"
- name: No Release Needed
if: ${{ !steps.release.outputs.cli_release_created }}
run: |
echo "ℹ️ No release needed (no changes detected)"
# ============================================
# GATE 2: Build and Test
# ============================================
build-and-test:
needs: release-please
if: ${{ needs.release-please.outputs.release_created }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
- name: Install Dependencies
run: npm ci
- name: Architecture Boundary Lint (eslint-plugin-boundaries)
working-directory: ${{ env.CLI_DIR }}
run: npm run lint
- name: Type Check and Build
working-directory: ${{ env.CLI_DIR }}
run: npm run build
- name: Security Audit
working-directory: ${{ env.CLI_DIR }}
run: npm audit --audit-level=high
- name: Unit Tests (MUST PASS)
working-directory: ${{ env.CLI_DIR }}
run: npm test
- name: Verify Package Integrity
run: |
echo "Verifying package..."
node -e "
const pkg = require('./${{ env.CLI_DIR }}/package.json');
const binTargets = typeof pkg.bin === 'string' ? [pkg.bin] : Object.values(pkg.bin);
console.log('Name:', pkg.name);
console.log('Version:', pkg.version);
console.log('Main:', pkg.main);
console.log('Bin:', binTargets);
if (!pkg.name || !pkg.version || !pkg.main || binTargets.length === 0) {
throw new Error('package.json is missing required identity fields');
}
"
# ============================================
# GATE 3: Publish to NPM
# ============================================
publish-npm:
needs: build-and-test
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
- name: Install Dependencies
run: npm ci
- name: Build
working-directory: ${{ env.CLI_DIR }}
run: npm run build
- name: Publish to NPM
working-directory: ${{ env.CLI_DIR }}
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Confirm Publication
run: |
echo "✅ Published @evolith/smart-cli@${{ needs.release-please.outputs.version }} to NPM"
# ============================================
# GATE 4: Package Binaries
# ============================================
package-binaries:
needs: publish-npm
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: ubuntu-latest
target: node20-linux-x64
ext: ''
- os: macos-latest
target: node20-macos-x64
ext: ''
- os: windows-latest
target: node20-win-x64
ext: '.exe'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install Dependencies
run: npm ci
- name: Build
working-directory: ${{ env.CLI_DIR }}
run: npm run build
- name: Package Binary
id: pkg
working-directory: ${{ env.CLI_DIR }}
run: npx pkg@5.8.1 . --targets ${{ matrix.target }} --output-dir ./binaries
- name: Rename Binary
shell: bash
run: |
cd ${{ env.CLI_DIR }}/binaries
produced=$(ls | head -1)
if [ -z "$produced" ]; then
echo "❌ pkg produced no binary for target ${{ matrix.target }}"
exit 1
fi
mv "$produced" "smart-cli-${{ matrix.target }}${{ matrix.ext }}"
ls -la
- name: Upload Binary Artifact
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.target }}
path: ${{ env.CLI_DIR }}/binaries/smart-cli-${{ matrix.target }}${{ matrix.ext }}
if-no-files-found: error
retention-days: 7
# ============================================
# GATE 5: Binary Smoke Test
# ============================================
smoke-test:
needs: [package-binaries, release-please]
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-latest
target: node20-linux-x64
bin: smart-cli-node20-linux-x64
- os: macos-latest
target: node20-macos-x64
bin: smart-cli-node20-macos-x64
- os: windows-latest
target: node20-win-x64
bin: smart-cli-node20-win-x64.exe
runs-on: ${{ matrix.os }}
steps:
- name: Download Binary
uses: actions/download-artifact@v4
with:
name: binaries-${{ matrix.target }}
path: ./binaries
- name: Setup Binary (non-Windows)
if: runner.os != 'Windows'
shell: bash
run: chmod +x ./binaries/${{ matrix.bin }}
- name: Smoke Test - Help Command
shell: bash
run: |
./binaries/${{ matrix.bin }} --help || { echo "❌ Binary failed to execute on ${{ matrix.os }}"; exit 1; }
echo "✅ Binary executable works on ${{ matrix.os }}"
- name: Smoke Test - Version
shell: bash
run: |
VERSION=$(./binaries/${{ matrix.bin }} --version) || { echo "❌ Binary --version failed on ${{ matrix.os }}"; exit 1; }
echo "Binary version: $VERSION"
# ============================================
# GATE 5b: Functional + NPM Smoke (Linux)
# ============================================
smoke-test-functional:
needs: [package-binaries, release-please]
runs-on: ubuntu-latest
steps:
- name: Download Binary
uses: actions/download-artifact@v4
with:
name: binaries-node20-linux-x64
path: ./binaries
- name: Setup Binary
shell: bash
run: chmod +x ./binaries/smart-cli-node20-linux-x64
- name: Smoke Test - Init Command
shell: bash
run: |
mkdir -p /tmp/evolith-test
cd /tmp/evolith-test
echo "test-project" | "$GITHUB_WORKSPACE/binaries/smart-cli-node20-linux-x64" init --runtime nodejs --monorepo none --arch clean \
|| { echo "❌ Init command smoke test failed"; exit 1; }
ls -la
echo "✅ Init command smoke test completed"
- name: Smoke Test - NPM Package
shell: bash
run: |
npm install -g @evolith/smart-cli@${{ needs.release-please.outputs.version }}
smart-cli --help || { echo "❌ NPM binary failed to execute"; exit 1; }
echo "✅ NPM package smoke test completed"
# ============================================
# GATE 6: Upload Release Assets
# ============================================
upload-assets:
needs: [package-binaries, smoke-test, smoke-test-functional]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download All Binaries
uses: actions/download-artifact@v4
with:
pattern: binaries-*
path: ./release-assets
merge-multiple: true
- name: List Assets
run: |
ls -la ./release-assets/
count=$(find ./release-assets -type f | wc -l)
if [ "$count" -lt 3 ]; then
echo "❌ Expected 3 platform binaries, found $count"
exit 1
fi
echo "✅ All $count platform binaries present"
- name: Upload to Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.release-please.outputs.tag_name }}
name: Release ${{ needs.release-please.outputs.tag_name }}
body: |
## Release Summary
**Version:** `${{ needs.release-please.outputs.version }}`
### ✅ Quality Gates Passed
- [x] Core Validation (docs, bilingual, cleanliness)
- [x] Build and Type Check
- [x] Unit Tests
- [x] Security Audit
- [x] NPM Publication
- [x] Binary Packaging
- [x] Smoke Tests
### 📦 Assets
| Platform | Architecture | Download |
|----------|--------------|----------|
| Linux | x64 | `smart-cli-node20-linux-x64` |
| macOS | x64 | `smart-cli-node20-macos-x64` |
| Windows | x64 | `smart-cli-node20-win-x64.exe` |
### 🚀 Installation
```bash
# NPM
npm install -g @evolith/smart-cli
# Or download binary directly
```
files: release-assets/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Confirm Release
run: |
echo "✅ Release ${{ needs.release-please.outputs.tag_name }} published with all assets"
# ============================================
# Cleanup on Failure
# ============================================
failure-notification:
needs: [publish-npm, package-binaries, smoke-test, smoke-test-functional, upload-assets]
if: failure()
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- name: Notify Failure
run: |
echo "❌ Release pipeline failed"
echo "Please check the logs above for details"
shell: bash
- name: Create Issue on Failure
if: ${{ github.event_name == 'push' }}
uses: actions/github-script@v7
with:
script: |
try {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '❌ Release Pipeline Failed',
body: `Release pipeline failed for tag ${{ needs.release-please.outputs.tag_name || 'unknown' }}
Please check the workflow logs and fix the issue.
@beyondnetcode/evolith-team`,
labels: ['bug', 'release']
});
core.info('Failure issue created');
} catch (error) {
// Degrade safely: a missing permission must not fail the notifier itself.
core.warning(`Could not create failure issue: ${error.message}`);
}