Skip to content

Commit 9010062

Browse files
committed
fix(ci): create npmrc directly in package directory for publishing
- Publish script now creates .npmrc in the package dir (binaries/...) - Simplified GitHub Actions workflow - npm publish runs from package dir, so needs .npmrc there
1 parent 47fccaf commit 9010062

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

.github/workflows/build-binaries.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,4 @@ jobs:
7171
env:
7272
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
7373
CI: true
74-
shell: bash
75-
run: |
76-
echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" > ~/.npmrc
77-
echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" > .npmrc
78-
chmod 600 ~/.npmrc .npmrc
79-
bun scripts/publish-platform.mjs --tag latest --access public
74+
run: bun scripts/publish-platform.mjs --tag latest --access public

scripts/publish-platform.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ try {
100100
console.log(`${cyan}${reset} Running in CI mode with NODE_AUTH_TOKEN\n`);
101101
}
102102

103+
// In CI mode, create .npmrc in the package directory
104+
if (isCI && process.env.NODE_AUTH_TOKEN) {
105+
const { writeFileSync } = await import('node:fs');
106+
const npmrcPath = join(packageDir, '.npmrc');
107+
const npmrcContent = `//registry.npmjs.org/:_authToken=${process.env.NODE_AUTH_TOKEN}`;
108+
writeFileSync(npmrcPath, npmrcContent, { mode: 0o600 });
109+
console.log(`${green}${reset} ${dim}Created .npmrc in package directory${reset}\n`);
110+
}
111+
103112
// Build publish command
104113
const publishCmd = dryRun
105114
? `npm publish --dry-run --tag ${tag} --access ${access}`

0 commit comments

Comments
 (0)