File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99
1010jobs :
1111 publish :
12+ name : Publish Package
1213 runs-on : ubuntu-latest
14+
1315 steps :
14- - name : Checkout
16+ - name : 📥 Checkout Repository
1517 uses : actions/checkout@v4
16- - uses : pnpm/action-setup@v3
17- with :
18- version : 8
19- - name : Set up Node
18+
19+ - name : 🛠 Install pnpm
20+ uses : pnpm/action-setup@v4
21+
22+ - name : 📦 Set Up Node.js & pnpm
2023 uses : actions/setup-node@v4
2124 with :
2225 node-version : 20
2326 cache : ' pnpm'
24- - name : Install dependencies
25- run : pnpm install
26- - run : pnpm run test
27- - run : pnpm run build
28- - uses : JS-DevTools/npm-publish@v3
29- with :
30- # dry-run: true
31- token : ${{ secrets.NPM_TOKEN }}
27+ registry-url : ' https://registry.npmjs.org/'
28+
29+ - name : 📦 Install Dependencies
30+ run : pnpm install --frozen-lockfile
31+
32+ - name : ✅ Run Tests
33+ run : pnpm run test
34+
35+ - name : 🏗 Build
36+ run : pnpm run build
37+
38+ - name : 🚀 Publish Package
39+ run : |
40+ PKG_NAME=$(node -p "require('./package.json').name")
41+ PKG_VERSION=$(node -p "require('./package.json').version")
42+ NPM_VERSION=$(npm show $PKG_NAME version || echo "0.0.0")
43+
44+ if [ "$PKG_VERSION" != "$NPM_VERSION" ]; then
45+ pnpm publish --access public --no-git-checks || {
46+ echo "❌ Publish failed. Dumping logs:";
47+ npm whoami
48+ pnpm -v
49+ cat ~/.npmrc || echo "No .npmrc found"
50+ exit 1
51+ }
52+ else
53+ echo "⚠️ Version $PKG_VERSION already exists. Skipping publish."
54+ fi
55+ env :
56+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
You can’t perform that action at this time.
0 commit comments