Skip to content

Commit b58f684

Browse files
committed
fix(ci): improve npm publish error detection in release workflow
- Check for success marker (+ package@version) instead of relying on exit codes - Handle auth errors gracefully for GitHub Packages (401/403) and continue to npmjs - Add explicit success notices and better error reporting - Fixes false positive failures when npm publish returns non-zero despite success
1 parent 6abfdd6 commit b58f684

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

‎.git-ai/lancedb.tar.gz‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:2398f5dd1592b08f6a39f43e197bf33a1e18d1060157206d441bb1d9c97a4438
3-
size 314362
2+
oid sha256:b30e7f67c4cfed10caec590edb722d7394c9dd1fb6d9631f3c4524242fb84bea
3+
size 314594

‎.github/workflows/release.yml‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,19 @@ jobs:
113113
id: publish_github
114114
run: |
115115
npm pkg set name="@${{ github.repository_owner }}/git-ai"
116-
npm publish --access public 2>&1 | tee publish_output.txt
116+
npm publish --access public 2>&1 | tee publish_output.txt || true
117117
if grep -q "You cannot publish over the previously published versions" publish_output.txt; then
118118
echo "::notice::Version already exists on GitHub Packages, skipping"
119119
echo "skipped=true" >> "$GITHUB_OUTPUT"
120-
elif [ ${PIPESTATUS[0]} -ne 0 ]; then
120+
elif grep -q "^\+ @${{ github.repository_owner }}/git-ai@" publish_output.txt; then
121+
echo "::notice::Successfully published to GitHub Packages"
122+
echo "skipped=false" >> "$GITHUB_OUTPUT"
123+
elif grep -q "npm error 40[13]" publish_output.txt; then
124+
echo "::warning::GitHub Packages publish failed with auth error, continuing to npmjs.org"
125+
echo "skipped=true" >> "$GITHUB_OUTPUT"
126+
else
121127
echo "::error::Failed to publish to GitHub Packages"
128+
cat publish_output.txt
122129
exit 1
123130
fi
124131
env:
@@ -144,11 +151,16 @@ jobs:
144151
if grep -q "You cannot publish over the previously published versions" publish_output.txt; then
145152
echo "::notice::Version already exists on npmjs.org, skipping"
146153
echo "skipped=true" >> "$GITHUB_OUTPUT"
154+
elif grep -q "^\+ @mars167/git-ai@" publish_output.txt; then
155+
echo "::notice::Successfully published to npmjs.org"
156+
echo "skipped=false" >> "$GITHUB_OUTPUT"
147157
elif grep -q "npm error" publish_output.txt; then
148158
echo "::error::Failed to publish to npmjs.org"
149159
cat publish_output.txt
150160
exit 1
151161
else
162+
echo "::warning::Unexpected npm publish output, check logs"
163+
cat publish_output.txt
152164
echo "skipped=false" >> "$GITHUB_OUTPUT"
153165
fi
154166
env:

0 commit comments

Comments
 (0)