Skip to content

Commit dd366f7

Browse files
fix: Improve NPM publishing workflow with comprehensive debugging
- Remove unnecessary scope configuration from setup-node - Add comprehensive NPM authentication testing - Add version conflict checking before publishing - Add npm ping and package existence checks - This should help identify the exact cause of publishing failures
1 parent 2a51331 commit dd366f7

1 file changed

Lines changed: 38 additions & 6 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ jobs:
3535
with:
3636
node-version: '20'
3737
registry-url: 'https://registry.npmjs.org'
38-
scope: '@devora_no'
3938

4039
- name: Enable corepack
4140
run: corepack enable
@@ -70,7 +69,7 @@ jobs:
7069
echo "Current package.json version:"
7170
cat package.json | grep '"version"'
7271
if [ "${{ github.event_name }}" = "push" ] && [[ "${{ github.ref }}" == refs/tags/v* ]]; then
73-
echo "Expected version from tag: ${{ steps.extract_version.outputs.version }}"
72+
echo "Expected version from tag: ${{ steps.extract_version.outputs.version || 'unknown' }}"
7473
else
7574
echo "Not a tag push, skipping version check"
7675
fi
@@ -91,14 +90,47 @@ jobs:
9190
echo "version=$VERSION" >> $GITHUB_OUTPUT
9291
echo "Extracted version: $VERSION"
9392
94-
- name: Publish to NPM
93+
- name: Test NPM Authentication
9594
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
9695
run: |
97-
echo "Publishing version ${{ steps.extract_version.outputs.version }} to NPM..."
96+
echo "Testing NPM authentication..."
9897
echo "NPM_TOKEN is set: ${{ secrets.NPM_TOKEN != '' }}"
98+
echo "NODE_AUTH_TOKEN is set: ${{ env.NODE_AUTH_TOKEN != '' }}"
9999
echo "Current directory: $(pwd)"
100-
echo "Package.json contents:"
101-
cat package.json | head -20
100+
echo "Package.json version:"
101+
cat package.json | grep '"version"'
102+
echo "Package name:"
103+
cat package.json | grep '"name"'
104+
echo "Testing npm whoami..."
105+
npm whoami || echo "npm whoami failed"
106+
echo "Testing pnpm whoami..."
107+
pnpm whoami || echo "pnpm whoami failed"
108+
echo "Testing npm ping..."
109+
npm ping || echo "npm ping failed"
110+
echo "Checking if package exists on NPM..."
111+
npm view @devora_no/prompt-assistant-mcp version || echo "Package not found or access denied"
112+
env:
113+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
114+
115+
- name: Check if version already exists
116+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
117+
run: |
118+
echo "Checking if version ${{ steps.extract_version.outputs.version }} already exists..."
119+
if npm view @devora_no/prompt-assistant-mcp@${{ steps.extract_version.outputs.version }} version > /dev/null 2>&1; then
120+
echo "Version ${{ steps.extract_version.outputs.version }} already exists on NPM!"
121+
echo "Available versions:"
122+
npm view @devora_no/prompt-assistant-mcp versions --json
123+
exit 1
124+
else
125+
echo "Version ${{ steps.extract_version.outputs.version }} does not exist, proceeding with publish..."
126+
fi
127+
env:
128+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
129+
130+
- name: Publish to NPM
131+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
132+
run: |
133+
echo "Publishing version ${{ steps.extract_version.outputs.version }} to NPM..."
102134
echo "Running pnpm publish..."
103135
pnpm publish --access public --verbose
104136
env:

0 commit comments

Comments
 (0)