Skip to content

Commit 6499be9

Browse files
ibrahimcesarclaude
andauthored
feat: Enable dual publishing to both scoped and unscoped NPM packages (#218)
Syncs both packages so users can install either way: - npm install @ibrahimcesar/react-lite-youtube-embed (scoped) - npm install react-lite-youtube-embed (unscoped) Changes: 1. Split "Publish to NPM" into two steps: - First publishes scoped package: @ibrahimcesar/react-lite-youtube-embed - Then modifies package.json and publishes unscoped: react-lite-youtube-embed - Restores original package.json after publishing 2. Updated release summary to show both packages: - Lists both NPM package URLs - Clearly identifies scoped vs unscoped - Shows package names for copy/paste 3. Applied to both workflows: - auto-release.yml (manual releases) - release.yml (GitHub release triggers) Benefits: - Both packages stay in sync automatically - Users can use whichever package name they prefer - Backward compatibility with existing installations - Same code, same version, published to both names All 51 tests passing ✅ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 79b5762 commit 6499be9

File tree

2 files changed

+61
-7
lines changed

2 files changed

+61
-7
lines changed

.github/workflows/auto-release.yml

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,14 @@ jobs:
240240
--notes-file CHANGELOG.md
241241
fi
242242
243-
- name: Publish to NPM
243+
- name: Publish to NPM (scoped package)
244244
run: |
245245
# Configure npm for public registry
246246
npm config set registry https://registry.npmjs.org
247247
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
248248
249-
# Publish with provenance for SLSA attestation
249+
# Publish scoped package (@ibrahimcesar/react-lite-youtube-embed)
250+
echo "Publishing scoped package: @ibrahimcesar/react-lite-youtube-embed"
250251
if [ "${{ github.event.inputs.is_beta }}" == "true" ]; then
251252
npm publish --tag beta --provenance
252253
else
@@ -255,6 +256,31 @@ jobs:
255256
env:
256257
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
257258

259+
- name: Publish to NPM (unscoped package)
260+
run: |
261+
# Configure npm for public registry
262+
npm config set registry https://registry.npmjs.org
263+
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
264+
265+
# Backup original package.json
266+
cp package.json package.json.backup
267+
268+
# Modify package.json to use unscoped name
269+
node -e "const pkg = require('./package.json'); pkg.name = 'react-lite-youtube-embed'; require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));"
270+
271+
# Publish unscoped package (react-lite-youtube-embed)
272+
echo "Publishing unscoped package: react-lite-youtube-embed"
273+
if [ "${{ github.event.inputs.is_beta }}" == "true" ]; then
274+
npm publish --tag beta --provenance
275+
else
276+
npm publish --provenance
277+
fi
278+
279+
# Restore original package.json
280+
mv package.json.backup package.json
281+
env:
282+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
283+
258284
- name: Setup Node for GitHub Packages
259285
uses: actions/setup-node@v6
260286
with:
@@ -300,11 +326,17 @@ jobs:
300326
echo "" >> $GITHUB_STEP_SUMMARY
301327
echo "### 🔗 Links" >> $GITHUB_STEP_SUMMARY
302328
echo "- [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.bump_version.outputs.version }})" >> $GITHUB_STEP_SUMMARY
329+
echo "" >> $GITHUB_STEP_SUMMARY
330+
echo "**NPM Packages:**" >> $GITHUB_STEP_SUMMARY
303331
if [ "${{ github.event.inputs.is_beta }}" == "true" ]; then
304-
echo "- [NPM Package (beta)](https://www.npmjs.com/package/react-lite-youtube-embed/v/${{ steps.clean_version.outputs.version }})" >> $GITHUB_STEP_SUMMARY
332+
echo "- [Scoped Package (beta)](https://www.npmjs.com/package/@ibrahimcesar/react-lite-youtube-embed/v/${{ steps.clean_version.outputs.version }}) - \`@ibrahimcesar/react-lite-youtube-embed\`" >> $GITHUB_STEP_SUMMARY
333+
echo "- [Unscoped Package (beta)](https://www.npmjs.com/package/react-lite-youtube-embed/v/${{ steps.clean_version.outputs.version }}) - \`react-lite-youtube-embed\`" >> $GITHUB_STEP_SUMMARY
305334
else
306-
echo "- [NPM Package](https://www.npmjs.com/package/react-lite-youtube-embed/v/${{ steps.clean_version.outputs.version }})" >> $GITHUB_STEP_SUMMARY
335+
echo "- [Scoped Package](https://www.npmjs.com/package/@ibrahimcesar/react-lite-youtube-embed/v/${{ steps.clean_version.outputs.version }}) - \`@ibrahimcesar/react-lite-youtube-embed\`" >> $GITHUB_STEP_SUMMARY
336+
echo "- [Unscoped Package](https://www.npmjs.com/package/react-lite-youtube-embed/v/${{ steps.clean_version.outputs.version }}) - \`react-lite-youtube-embed\`" >> $GITHUB_STEP_SUMMARY
307337
fi
308-
echo "- [GitHub Packages](https://github.com/${{ github.repository }}/pkgs/npm/react-lite-youtube-embed)" >> $GITHUB_STEP_SUMMARY
338+
echo "" >> $GITHUB_STEP_SUMMARY
339+
echo "**GitHub Packages:**" >> $GITHUB_STEP_SUMMARY
340+
echo "- [@ibrahimcesar/react-lite-youtube-embed](https://github.com/${{ github.repository }}/pkgs/npm/react-lite-youtube-embed)" >> $GITHUB_STEP_SUMMARY
309341
echo "" >> $GITHUB_STEP_SUMMARY
310342
cat CHANGELOG.md >> $GITHUB_STEP_SUMMARY

.github/workflows/release.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,39 @@ jobs:
8383
name: dist
8484
path: dist/
8585

86-
- name: Publish to NPM
86+
- name: Publish to NPM (scoped package)
8787
run: |
8888
# Configure npm for public registry
8989
npm config set registry https://registry.npmjs.org
9090
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
9191
92-
# Publish with provenance for SLSA attestation
92+
# Publish scoped package (@ibrahimcesar/react-lite-youtube-embed)
93+
echo "Publishing scoped package: @ibrahimcesar/react-lite-youtube-embed"
9394
npm publish --provenance
9495
env:
9596
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
9697

98+
- name: Publish to NPM (unscoped package)
99+
run: |
100+
# Configure npm for public registry
101+
npm config set registry https://registry.npmjs.org
102+
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
103+
104+
# Backup original package.json
105+
cp package.json package.json.backup
106+
107+
# Modify package.json to use unscoped name
108+
node -e "const pkg = require('./package.json'); pkg.name = 'react-lite-youtube-embed'; require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));"
109+
110+
# Publish unscoped package (react-lite-youtube-embed)
111+
echo "Publishing unscoped package: react-lite-youtube-embed"
112+
npm publish --provenance
113+
114+
# Restore original package.json
115+
mv package.json.backup package.json
116+
env:
117+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
118+
97119
publish-github:
98120
name: Publish on GitHub Packages
99121
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)