@aramassa/ai-rules 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,666 @@
1
+ ---
2
+ type: development-rules
3
+ category: package-publish
4
+ framework: npm
5
+ language:
6
+ - typescript
7
+ - nodejs
8
+ applyTo: ".github/workflows/**/*.yml"
9
+ ---
10
+
11
+ # npm Package Publishing Workflow 実装ルール
12
+
13
+ このドキュメントは、npmパッケージ(GitHub PackagesとnpmjsへのDual Registry公開)のための
14
+ GitHub Actions ワークフローの標準実装ルールを定義します。
15
+
16
+ ## 目的
17
+
18
+ - 複数リポジトリで一貫したpublishワークフローを実現
19
+ - バージョン管理、ビルド、公開プロセスの標準化
20
+ - メンテナンス性と再利用性の向上
21
+
22
+ ## ワークフロー全体構造
23
+
24
+ ```yaml
25
+ name: Publish package
26
+
27
+ on:
28
+ workflow_dispatch:
29
+ inputs:
30
+ version_bump:
31
+ description: |-
32
+ Version bump type:
33
+ - `current`: Use current version (no version update)
34
+ - `patch`: Patch version update (e.g., 0.3.0 → 0.3.1)
35
+ - `minor`: Minor version update (e.g., 0.3.0 → 0.4.0)
36
+ - `major`: Major version update (e.g., 0.3.0 → 1.0.0)
37
+ required: true
38
+ default: "current"
39
+ type: choice
40
+ options:
41
+ - current
42
+ - patch
43
+ - minor
44
+ - major
45
+ release_type:
46
+ description: |-
47
+ Release type determines where the package is published:
48
+ - `stable`: Publish to both npmjs.org and GitHub Packages (production release)
49
+ - `pre-build`: Publish to GitHub Packages only (development/testing release)
50
+ required: true
51
+ default: "pre-build"
52
+ type: choice
53
+ options:
54
+ - stable
55
+ - pre-build
56
+
57
+ jobs:
58
+ version-bump:
59
+ # バージョンバンプとGitHubリリース作成
60
+
61
+ build:
62
+ # ビルドとテスト実行、アーティファクトアップロード
63
+
64
+ publish-github:
65
+ # GitHub Packagesへの公開
66
+
67
+ publish-npm:
68
+ # npmjs.orgへの公開(stableのみ)
69
+ ```
70
+
71
+ ## Job 1: version-bump
72
+
73
+ ### 目的
74
+ - package.jsonのバージョン更新
75
+ - Gitタグの作成とプッシュ
76
+ - GitHubリリースの作成(自動リリースノート生成)
77
+
78
+ ### 実装
79
+
80
+ ```yaml
81
+ version-bump:
82
+ if: github.event_name == 'workflow_dispatch' && github.event.inputs.version_bump != 'current'
83
+ runs-on: ubuntu-latest
84
+ permissions:
85
+ contents: write
86
+ outputs:
87
+ new_version: ${{ steps.bump_version.outputs.new_version }}
88
+ new_tag: ${{ steps.bump_version.outputs.new_tag }}
89
+ steps:
90
+ - uses: actions/checkout@v4
91
+ with:
92
+ token: ${{ secrets.GITHUB_TOKEN }}
93
+
94
+ - name: Configure Git
95
+ run: |
96
+ git config user.name "github-actions[bot]"
97
+ git config user.email "github-actions[bot]@users.noreply.github.com"
98
+
99
+ - uses: actions/setup-node@v4
100
+ with:
101
+ node-version: 20
102
+
103
+ - name: Bump version and create tag
104
+ id: bump_version
105
+ run: |
106
+ # Run npm version and capture the new version
107
+ NEW_VERSION=$(npm version ${{ github.event.inputs.version_bump }} --git-tag-version=true)
108
+ echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT
109
+ echo "new_tag=${NEW_VERSION}" >> $GITHUB_OUTPUT
110
+ echo "Version bumped to: ${NEW_VERSION}"
111
+
112
+ - name: Push changes and tags
113
+ run: |
114
+ git push origin HEAD:${{ github.ref_name }}
115
+ git push origin --tags
116
+
117
+ - name: Create GitHub Release
118
+ uses: softprops/action-gh-release@v2
119
+ with:
120
+ tag_name: ${{ steps.bump_version.outputs.new_tag }}
121
+ name: Release ${{ steps.bump_version.outputs.new_version }}
122
+ draft: false
123
+ prerelease: false
124
+ generate_release_notes: true
125
+ ```
126
+
127
+ ### 重要ポイント
128
+
129
+ 1. **条件付き実行**: `version_bump != 'current'`の場合のみ実行
130
+ 2. **permissions**: `contents: write`が必須(タグプッシュとリリース作成のため)
131
+ 3. **Git設定**: github-actions[bot]として実行
132
+ 4. **npm version**: `--git-tag-version=true`でタグも同時作成
133
+ 5. **リリース作成**: `softprops/action-gh-release@v2`を使用(v1よりv2推奨)
134
+ - `generate_release_notes: true`で自動的にリリースノート生成
135
+ - `draft: false`, `prerelease: false`で即座に公開
136
+
137
+ ### outputs
138
+ - `new_version`: バージョン番号(例: `v0.5.3`)
139
+ - `new_tag`: Gitタグ名(例: `v0.5.3`)
140
+
141
+ ## Job 2: build
142
+
143
+ ### 目的
144
+ - 依存関係のインストール
145
+ - テストの実行
146
+ - パッケージのビルド
147
+ - 公開用アーティファクトのアップロード
148
+
149
+ ### 実装
150
+
151
+ ```yaml
152
+ build:
153
+ needs: [version-bump]
154
+ if: always() && (needs.version-bump.result == 'success' || needs.version-bump.result == 'skipped')
155
+ runs-on: ubuntu-latest
156
+ outputs:
157
+ version: ${{ steps.get_version.outputs.version }}
158
+ release_type: ${{ steps.determine_release_type.outputs.release_type }}
159
+ steps:
160
+ - uses: actions/checkout@v4
161
+ with:
162
+ # If version was bumped, checkout the new tag; otherwise checkout the current ref
163
+ ref: ${{ needs.version-bump.outputs.new_tag || github.ref_name }}
164
+ fetch-depth: 0
165
+
166
+ - name: Get package version
167
+ id: get_version
168
+ run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
169
+
170
+ - name: Determine release type
171
+ id: determine_release_type
172
+ run: |
173
+ if [ "${{ github.event_name }}" = "push" ]; then
174
+ echo "release_type=stable" >> $GITHUB_OUTPUT
175
+ elif [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.version_bump }}" != "current" ]; then
176
+ # For version bump workflows, use stable since we're creating an official release
177
+ echo "release_type=stable" >> $GITHUB_OUTPUT
178
+ else
179
+ echo "release_type=${{ github.event.inputs.release_type }}" >> $GITHUB_OUTPUT
180
+ fi
181
+
182
+ - uses: actions/setup-node@v4
183
+ with:
184
+ node-version: 20
185
+
186
+ - name: Setup npmrc for GitHub Packages
187
+ uses: ./.github/actions/setup-npmrc
188
+ with:
189
+ github_token: ${{ secrets.GH_TOKEN }}
190
+ env:
191
+ NPM_CONFIG_USERCONFIG: ~/.npmrc
192
+
193
+ - name: Install dependencies
194
+ run: npm install
195
+
196
+ - name: Build packages
197
+ run: npm run build:pkg:clean && npm run root:build
198
+
199
+ - name: Run tests
200
+ run: npm test
201
+
202
+ - name: Upload artifact
203
+ uses: actions/upload-artifact@v4
204
+ with:
205
+ name: package
206
+ path: |
207
+ dist/
208
+ package.json
209
+ package-lock.json
210
+ artifact/
211
+ presets/
212
+ schemas/
213
+ README-npmjs.md
214
+ .github/actions/
215
+ retention-days: 1
216
+ ```
217
+
218
+ ### 重要ポイント
219
+
220
+ 1. **needs依存**: `version-bump`ジョブに依存
221
+ 2. **条件付き実行**: `always()`で常に評価し、version-bumpが成功またはスキップされた場合のみ実行
222
+ 3. **checkout ref**: バージョンバンプされた場合は新しいタグをcheckout、そうでなければ現在のref
223
+ 4. **fetch-depth: 0**: 完全なGit履歴を取得(リリースノート生成などに必要)
224
+ 5. **カスタムアクション**: `.github/actions/setup-npmrc`を使用してnpmrc設定を一元管理
225
+ 6. **ビルドコマンド**: プロジェクト固有のビルドコマンドに合わせて調整
226
+ - 例: `npm run build:clean`, `npm run build:pkg:clean && npm run root:build`
227
+ 7. **アーティファクトパス**: プロジェクトに必要なファイルをすべて含める
228
+ - 必須: `dist/`, `package.json`, `package-lock.json`
229
+ - オプション: `README-npmjs.md`, プロジェクト固有のディレクトリ
230
+ - カスタムアクション再利用: `.github/actions/`
231
+
232
+ ### outputs
233
+ - `version`: 現在のパッケージバージョン
234
+ - `release_type`: 実際のリリースタイプ(stable/pre-build)
235
+
236
+ ### プロジェクト固有の調整が必要な箇所
237
+
238
+ 1. **ビルドコマンド**: `npm run build:pkg:clean && npm run root:build`
239
+ - monorepoの場合: workspace対応のビルドコマンド
240
+ - 単一パッケージの場合: `npm run build:clean`
241
+
242
+ 2. **アーティファクトパス**: プロジェクトの公開ファイルに合わせる
243
+ ```yaml
244
+ path: |
245
+ dist/
246
+ package.json
247
+ package-lock.json
248
+ # プロジェクト固有のディレクトリ
249
+ artifact/ # ai-rulesの場合
250
+ presets/ # ai-rulesの場合
251
+ schemas/ # ai-rulesの場合
252
+ README-npmjs.md # npmjs用READMEがある場合
253
+ .github/actions/ # カスタムアクションを再利用する場合
254
+ ```
255
+
256
+ ## Job 3: publish-github
257
+
258
+ ### 目的
259
+ - GitHub Packagesへのパッケージ公開
260
+ - プレリリースバージョンの管理
261
+
262
+ ### 実装
263
+
264
+ ```yaml
265
+ publish-github:
266
+ needs: build
267
+ runs-on: ubuntu-latest
268
+ permissions:
269
+ contents: read
270
+ packages: write
271
+ steps:
272
+ - uses: actions/download-artifact@v4
273
+ with:
274
+ name: package
275
+ path: .
276
+
277
+ - uses: actions/setup-node@v4
278
+ with:
279
+ node-version: 20
280
+ registry-url: "https://npm.pkg.github.com/"
281
+
282
+ - name: Setup npmrc for GitHub Packages
283
+ uses: ./.github/actions/setup-npmrc
284
+ with:
285
+ github_token: ${{ secrets.GH_TOKEN }}
286
+ env:
287
+ NPM_CONFIG_USERCONFIG: ~/.npmrc
288
+
289
+ - name: Setup prerelease version
290
+ if: needs.build.outputs.release_type != 'stable'
291
+ run: |
292
+ TIMESTAMP=$(date +%Y%m%d%H%M%S)
293
+ PRERELEASE_VERSION="${{ needs.build.outputs.version }}-${{ needs.build.outputs.release_type }}.${TIMESTAMP}"
294
+ npm version $PRERELEASE_VERSION --no-git-tag-version
295
+
296
+ - name: Publish to GitHub Packages
297
+ run: |
298
+ if [ "${{ needs.build.outputs.release_type }}" = "stable" ]; then
299
+ npm publish --tag latest --verbose
300
+ else
301
+ npm publish --tag ${{ needs.build.outputs.release_type }} --verbose
302
+ fi
303
+ env:
304
+ NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
305
+ ```
306
+
307
+ ### 重要ポイント
308
+
309
+ 1. **permissions**: `contents: read`, `packages: write`が必須
310
+ 2. **アーティファクトダウンロード**: buildジョブでアップロードしたファイルを取得
311
+ 3. **registry-url**: GitHub Packages用のレジストリURL
312
+ 4. **プレリリースバージョン**: タイムスタンプ付きバージョンを生成
313
+ - フォーマット: `{version}-{release_type}.{YYYYMMDDHHMMSS}`
314
+ - 例: `0.5.2-pre-build.20241028123456`
315
+ 5. **タグ管理**:
316
+ - stable: `--tag latest`(デフォルトインストール対象)
317
+ - pre-build: `--tag pre-build`(明示的に指定が必要)
318
+ 6. **認証**: `NODE_AUTH_TOKEN`に`secrets.GITHUB_TOKEN`を使用
319
+
320
+ ## Job 4: publish-npm
321
+
322
+ ### 目的
323
+ - npmjs.orgへのパッケージ公開(stableリリースのみ)
324
+ - npm provenanceのサポート
325
+
326
+ ### 実装
327
+
328
+ ```yaml
329
+ publish-npm:
330
+ needs: build
331
+ if: needs.build.outputs.release_type == 'stable'
332
+ runs-on: ubuntu-latest
333
+ permissions:
334
+ contents: read
335
+ id-token: write # for npm provenance
336
+ steps:
337
+ - uses: actions/download-artifact@v4
338
+ with:
339
+ name: package
340
+ path: .
341
+
342
+ - uses: actions/setup-node@v4
343
+ with:
344
+ node-version: 20
345
+ registry-url: "https://registry.npmjs.org/"
346
+
347
+ - name: Prepare minimal package for npmjs.org
348
+ run: |
349
+ cp README-npmjs.md README.md
350
+
351
+ - name: Verify package contents (npmjs.org)
352
+ run: |
353
+ echo "Package contents preview for npmjs.org:"
354
+ npm pack --dry-run
355
+
356
+ - name: Publish to npmjs.org
357
+ run: npm publish --access public --provenance --verbose
358
+ env:
359
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
360
+ ```
361
+
362
+ ### 重要ポイント
363
+
364
+ 1. **条件付き実行**: `release_type == 'stable'`の場合のみ実行
365
+ 2. **permissions**: `id-token: write`が必須(npm provenance用)
366
+ 3. **registry-url**: npmjs.org用のレジストリURL
367
+ 4. **README準備**: `README-npmjs.md`が存在する場合は置き換え
368
+ - プロジェクト固有のREADMEをnpmjs用に最適化
369
+ 5. **検証**: `npm pack --dry-run`で公開内容を事前確認
370
+ 6. **公開オプション**:
371
+ - `--access public`: スコープ付きパッケージを公開する場合必須
372
+ - `--provenance`: パッケージの来歴情報を付与(セキュリティ向上)
373
+ - `--verbose`: 詳細ログ出力
374
+ 7. **認証**: `NODE_AUTH_TOKEN`に`secrets.NPM_TOKEN`を使用
375
+
376
+ ### README-npmjs.mdについて
377
+
378
+ npmjs.orgとGitHub(リポジトリ/GitHub Packages)で異なるREADMEを使いたい場合:
379
+
380
+ 1. **README.md**: GitHubリポジトリ用(開発者向け、詳細な情報)
381
+ 2. **README-npmjs.md**: npmjs.org用(ユーザー向け、シンプルな説明)
382
+
383
+ 存在しない場合は、この手順をスキップまたは削除してください。
384
+
385
+ ## カスタムアクション: setup-npmrc
386
+
387
+ ### 目的
388
+ - npmrc設定を一元管理
389
+ - 複数ジョブでの再利用性向上
390
+
391
+ ### ファイル構造
392
+
393
+ ```
394
+ .github/
395
+ actions/
396
+ setup-npmrc/
397
+ action.yml
398
+ ```
399
+
400
+ ### 実装: .github/actions/setup-npmrc/action.yml
401
+
402
+ ```yaml
403
+ name: Setup npmrc
404
+ description: Setup npmrc for GitHub Packages authentication
405
+
406
+ inputs:
407
+ github_token:
408
+ description: 'GitHub token for authentication'
409
+ required: true
410
+
411
+ runs:
412
+ using: composite
413
+ steps:
414
+ - name: Setup .npmrc
415
+ shell: bash
416
+ run: |
417
+ cat > ~/.npmrc << EOF
418
+ @aramassa:registry=https://npm.pkg.github.com
419
+ //npm.pkg.github.com/:_authToken=${{ inputs.github_token }}
420
+ registry=https://registry.npmjs.org/
421
+ EOF
422
+ echo "Created ~/.npmrc for GitHub Packages"
423
+ ```
424
+
425
+ ### 重要ポイント
426
+
427
+ 1. **スコープ設定**: `@aramassa:registry`をGitHub Packagesに設定
428
+ 2. **認証トークン**: `//npm.pkg.github.com/:_authToken`で認証
429
+ 3. **デフォルトレジストリ**: `registry=https://registry.npmjs.org/`(npmjsをデフォルトに)
430
+ 4. **組織名**: `@aramassa`は実際の組織名/ユーザー名に置き換える
431
+
432
+ ### プロジェクト固有の調整
433
+
434
+ ```yaml
435
+ @{your-org-or-username}:registry=https://npm.pkg.github.com
436
+ ```
437
+
438
+ ## package.json 設定
439
+
440
+ ### 必須設定
441
+
442
+ ```json
443
+ {
444
+ "name": "@aramassa/package-name",
445
+ "version": "0.5.2",
446
+ "publishConfig": {
447
+ "access": "public",
448
+ "registry": "https://npm.pkg.github.com/"
449
+ },
450
+ "files": [
451
+ "dist/",
452
+ "README.md"
453
+ ],
454
+ "bin": {
455
+ "package-name": "dist/cli.js"
456
+ }
457
+ }
458
+ ```
459
+
460
+ ### 重要ポイント
461
+
462
+ 1. **name**: スコープ付き(`@aramassa/`)にする
463
+ 2. **publishConfig**:
464
+ - `access: "public"`: 公開パッケージとして設定
465
+ - `registry`: GitHub Packagesをデフォルトに(publish-npmジョブでnpmjs.orgを明示的に指定)
466
+ 3. **files**: 公開するファイルを明示的に指定
467
+ - `dist/`: ビルド成果物
468
+ - プロジェクト固有のディレクトリ(`artifact/`, `presets/`, `schemas/`など)
469
+ 4. **bin**: CLIツールの場合は必須
470
+
471
+ ### monorepoの場合
472
+
473
+ ルートpackage.jsonとworkspaceパッケージのpackage.jsonで設定が必要:
474
+
475
+ ```json
476
+ {
477
+ "workspaces": [
478
+ "packages/extract",
479
+ "packages/core"
480
+ ],
481
+ "publishConfig": {
482
+ "registry": "https://npm.pkg.github.com/"
483
+ }
484
+ }
485
+ ```
486
+
487
+ ## Secrets設定
488
+
489
+ ### 必要なシークレット
490
+
491
+ | Secret名 | 用途 | 取得方法 |
492
+ |----------|------|----------|
493
+ | `GITHUB_TOKEN` | GitHub Packages公開、リリース作成 | 自動提供(設定不要) |
494
+ | `GH_TOKEN` | GitHub Packages認証(依存関係インストール) | Personal Access Token (classic) |
495
+ | `NPM_TOKEN` | npmjs.org公開 | npmjs.org Automation Token |
496
+
497
+ ### GH_TOKEN の作成
498
+
499
+ 1. GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)
500
+ 2. Generate new token (classic)
501
+ 3. 権限: `read:packages`, `write:packages`
502
+ 4. リポジトリの Settings → Secrets and variables → Actions → New repository secret
503
+ 5. Name: `GH_TOKEN`, Value: 生成したトークン
504
+
505
+ ### NPM_TOKEN の作成
506
+
507
+ 1. npmjs.org → Account Settings → Access Tokens
508
+ 2. Generate New Token → Automation
509
+ 3. リポジトリの Settings → Secrets and variables → Actions → New repository secret
510
+ 4. Name: `NPM_TOKEN`, Value: 生成したトークン
511
+
512
+ ## 使用方法
513
+
514
+ ### 1. プレリリース公開(GitHub Packagesのみ)
515
+
516
+ ```
517
+ Actions → Publish package → Run workflow
518
+ - version_bump: current
519
+ - release_type: pre-build
520
+ → Run workflow
521
+ ```
522
+
523
+ **結果**:
524
+ - GitHub Packagesに`{version}-pre-build.{timestamp}`として公開
525
+ - タグ: `pre-build`
526
+
527
+ ### 2. 正式リリース(バージョンアップなし)
528
+
529
+ ```
530
+ Actions → Publish package → Run workflow
531
+ - version_bump: current
532
+ - release_type: stable
533
+ → Run workflow
534
+ ```
535
+
536
+ **結果**:
537
+ - GitHub Packagesとnpmjsにstableバージョンとして公開
538
+ - タグ: `latest`
539
+
540
+ ### 3. 正式リリース(パッチバージョンアップ)
541
+
542
+ ```
543
+ Actions → Publish package → Run workflow
544
+ - version_bump: patch
545
+ - release_type: stable
546
+ → Run workflow
547
+ ```
548
+
549
+ **結果**:
550
+ - バージョンが`0.5.2`→`0.5.3`に更新
551
+ - Gitタグ`v0.5.3`が作成
552
+ - GitHubリリース作成
553
+ - GitHub Packagesとnpmjsにstableバージョンとして公開
554
+
555
+ ## トラブルシューティング
556
+
557
+ ### エラー: "This request requires authentication"
558
+
559
+ **原因**: `GH_TOKEN`が設定されていないか、権限が不足
560
+
561
+ **解決策**:
562
+ 1. `GH_TOKEN`がSecretsに登録されているか確認
563
+ 2. トークンの権限に`read:packages`, `write:packages`が含まれているか確認
564
+
565
+ ### エラー: "You cannot publish over the previously published versions"
566
+
567
+ **原因**: 同じバージョンが既に公開されている
568
+
569
+ **解決策**:
570
+ 1. `version_bump`を`current`以外に設定してバージョンを上げる
571
+ 2. または、package.jsonのバージョンを手動で更新してコミット
572
+
573
+ ### エラー: "npm ERR! 404 Not Found - GET https://npm.pkg.github.com/@aramassa/..."
574
+
575
+ **原因**: 依存関係がGitHub Packagesに存在しないか、認証エラー
576
+
577
+ **解決策**:
578
+ 1. `.github/actions/setup-npmrc`が正しく実行されているか確認
579
+ 2. `GH_TOKEN`の権限を確認
580
+ 3. 依存関係のpackage.jsonの`publishConfig.registry`を確認
581
+
582
+ ### ビルドが失敗する
583
+
584
+ **確認ポイント**:
585
+ 1. ローカルで`npm install && npm test && npm run build`が成功するか
586
+ 2. Node.jsバージョンが一致しているか(ワークフローではv20を使用)
587
+ 3. `.github/actions/setup-npmrc`が存在するか
588
+
589
+ ### npm provenanceエラー
590
+
591
+ **原因**: `id-token: write`権限が不足
592
+
593
+ **解決策**:
594
+ ```yaml
595
+ publish-npm:
596
+ permissions:
597
+ contents: read
598
+ id-token: write # この行を追加
599
+ ```
600
+
601
+ ## ベストプラクティス
602
+
603
+ ### 1. バージョン管理戦略
604
+
605
+ - **プレリリース**: `version_bump: current`, `release_type: pre-build`
606
+ - 頻繁なテスト公開
607
+ - 開発中の機能確認
608
+
609
+ - **正式リリース**: `version_bump: patch/minor/major`, `release_type: stable`
610
+ - セマンティックバージョニングに従う
611
+ - GitHubリリースも作成される
612
+
613
+ ### 2. ワークフロー実行順序
614
+
615
+ 1. まずプレリリースで動作確認(`pre-build`)
616
+ 2. 問題なければ正式リリース(`stable`)
617
+ 3. バージョンバンプは正式リリース時に実施
618
+
619
+ ### 3. README管理
620
+
621
+ - **README.md**: 開発者向け(詳細なビルド手順、貢献ガイドライン)
622
+ - **README-npmjs.md**: ユーザー向け(インストール方法、基本的な使い方)
623
+
624
+ ### 4. アーティファクト管理
625
+
626
+ - `retention-days: 1`: 不要なストレージ使用を避ける
627
+ - 必要最小限のファイルのみアップロード
628
+
629
+ ### 5. セキュリティ
630
+
631
+ - `npm publish --provenance`: パッケージの来歴を記録
632
+ - `permissions`: 各ジョブで必要最小限の権限のみ付与
633
+ - `secrets.GITHUB_TOKEN`: 自動提供されるトークンを優先使用
634
+
635
+ ## チェックリスト
636
+
637
+ 新しいリポジトリにこのワークフローを実装する際のチェックリスト:
638
+
639
+ - [ ] `.github/workflows/publish.yml`を作成
640
+ - [ ] `.github/actions/setup-npmrc/action.yml`を作成
641
+ - [ ] package.jsonに`publishConfig`を追加
642
+ - [ ] `GH_TOKEN`をSecretsに登録
643
+ - [ ] `NPM_TOKEN`をSecretsに登録(npmjs公開する場合)
644
+ - [ ] `README-npmjs.md`を作成(必要に応じて)
645
+ - [ ] ビルドコマンドをプロジェクトに合わせて調整
646
+ - [ ] アーティファクトパスをプロジェクトに合わせて調整
647
+ - [ ] `@aramassa`をプロジェクトの組織名/ユーザー名に置き換え
648
+ - [ ] ローカルで`npm install && npm test && npm run build`が成功することを確認
649
+ - [ ] プレリリースで動作確認(`pre-build`)
650
+ - [ ] 正式リリースのテスト(`stable`)
651
+
652
+ ## 参考実装
653
+
654
+ このルールは以下の3つの実装から良い点を統合したものです:
655
+
656
+ 1. **ai-rules**: `.github/workflows/publish.yml`
657
+ - 柔軟なバージョンバンプ戦略
658
+ - 詳細なアーティファクト管理
659
+
660
+ 2. **mcp-docs-collector**: `.github/workflows/publish-root.yml`
661
+ - `softprops/action-gh-release`の使用
662
+ - カスタムアクションによるnpmrc設定
663
+
664
+ 3. **skel-extractor**: `.github/workflows/publish-gpr.yml`
665
+ - シンプルなプレリリースバージョン管理
666
+ - 効率的なアーティファクト処理