Fix ESM output and add npm release workflows - #4
Conversation
| const trustedPackage = await getTrustedPackage(targetBranch); | ||
| const version = `${trustedPackage.baseVersion}-beta.pr${prNumber}.sha${headSha.slice(0, 12)}`; |
There was a problem hiding this comment.
🟡 バージョン更新を含む PR のベータ公開が失敗する
PR でバージョンを更新すると、候補パッケージは PR 側のバージョンで作られます。ここでは main 側のバージョンを期待するため、公開時に一致せず失敗します。
Learn more
候補ワークフローは PR の先頭コミットをチェックアウトし、その package.json のバージョンを使ってアーカイブを作ります。承認側は main の package.json から期待するバージョンを作るため、PR にバージョン更新が含まれると両者は一致しません。アーカイブの名前とバージョンの検査は 公開ステップで行われ、公開が止まります。公開直前の再検証にも同じ前提があります。
Example: main が 0.1.0、PR が 0.2.0 なら、候補は 0.2.0-beta.pr4.sha...、承認側の期待値は 0.1.0-beta.pr4.sha... です。CI と候補の作成が成功しても /beta で公開できません。
Recommended fix: PR の候補バージョンを承認処理と再検証でも同じコミットから算出してください。パッケージ名など main に固定すべき項目は別途 main と照合し、候補のバージョンと混同しないでください。
Was this helpful? React with 👍 or 👎 to provide feedback.
| - name: Publish packages | ||
| run: | | ||
| VERSION="${{ steps.tag_version.outputs.version }}" | ||
| IS_STABLE=$(echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' && echo true || echo false) | ||
|
|
||
| echo "Publishing... $IS_STABLE" | ||
| if [ "$IS_STABLE" = "true" ]; then | ||
| npm publish --provenance --access public --tag latest | ||
| elif echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+-[0-9A-Za-z.-]+$'; then | ||
| npm publish --provenance --access public --tag next |
There was a problem hiding this comment.
🔍 配布方法の説明が npm リリースフローと食い違う
README の利用案内は TypeScript ソースのコンパイルと Git タグ依存を前提にしています。npm 版と ESM 出力の利用方法も案内する必要があるか確認してください。
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
.jsrelative specifiers.betapublication after a successful PR merge or an authorized/betacomment, and SemVer tag publication (latestfor stable,nextfor prerelease).Verification
npm run buildnpm test(16 tests)npm run lintnpm run fmt:checkactionlint .github/workflows/*.ymlnode --input-type=module -e "await import('./dist/index.js')"npm pack --dry-run --jsonincludesdist/index.jsRelated to rdlabo-dev/ionic-theme-ios27#217. npm trusted publishing must be configured for this repository before its first publication.