Skip to content

Commit 3a6e7e2

Browse files
committed
chore: fix npm publish
1 parent d0ef067 commit 3a6e7e2

1 file changed

Lines changed: 41 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ name: Release
22

33
on:
44
workflow_dispatch:
5+
push:
6+
branches:
7+
- 09-17-chore_fix_npm_publish
58

69
jobs:
710
build-rust:
811
runs-on: ubuntu-latest
12+
needs: check-publish
913
strategy:
1014
fail-fast: false
1115
matrix:
@@ -112,11 +116,45 @@ jobs:
112116
sed -i 's/"version": "0.0.0"/"version": "0.0.0-${{ github.sha }}"/' packages/global/package.json
113117
sed -i 's/"version": "0.0.0"/"version": "0.0.0-${{ github.sha }}"/' packages/cli/package.json
114118
119+
- name: Setup Node.js and Authenticate
120+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
121+
with:
122+
node-version-file: ".node-version"
123+
# This tells setup-node which registry you want to log in to
124+
registry-url: "https://npm.pkg.github.com"
125+
# If your packages are scoped (e.g., @your-org/your-package), add this
126+
scope: "@voidzero-dev"
127+
115128
- name: Publish
116129
run: |
117-
echo "//npm.pkg.github.com/:_authToken=${NPM_TOKEN}" >> ${NPM_CONFIG_USERCONFIG}
118-
echo "@voidzero-dev:registry=https://npm.pkg.github.com/" >> ${NPM_CONFIG_USERCONFIG}
130+
pnpm whoami --registry https://npm.pkg.github.com
119131
pnpm publish --filter=./packages/global --registry https://npm.pkg.github.com --no-git-checks
120132
pnpm publish --filter=./packages/cli --registry https://npm.pkg.github.com --no-git-checks
121133
env:
122-
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135+
136+
check-publish:
137+
runs-on: ubuntu-latest
138+
permissions:
139+
contents: read
140+
packages: write
141+
steps:
142+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
143+
144+
- uses: oxc-project/setup-node@f42e3bda950c7454575e78ee4eaac880a077700c # v1.0.0
145+
146+
- name: Setup Node.js and Authenticate
147+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
148+
with:
149+
node-version-file: ".node-version"
150+
# This tells setup-node which registry you want to log in to
151+
registry-url: "https://npm.pkg.github.com"
152+
# If your packages are scoped (e.g., @your-org/your-package), add this
153+
scope: "@voidzero-dev"
154+
155+
- name: Verify Authentication
156+
run: pnpm whoami --registry https://npm.pkg.github.com # This should now succeed and show your GitHub username
157+
env:
158+
# This is the authentication token that setup-node uses.
159+
# GITHUB_TOKEN is automatically provided by the runner.
160+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)