Skip to content
This repository was archived by the owner on Nov 14, 2025. It is now read-only.

Commit 62516b5

Browse files
sapientpantsclaude
andauthored
refactor: fail publish workflow if pre-built artifacts are missing (#312)
Previously, the NPM and GitHub Packages publish jobs would fall back to building from source if the pre-built artifacts from the Main workflow were not found. This created a risk of publishing untested code. Changes: - Removed continue-on-error flag from artifact download steps - Removed fallback logic that would build from source - Simplified extraction steps to fail fast with clear error messages - Renamed "Try to download" to "Download" reflecting mandatory nature This ensures the publish workflow only succeeds when it can use the exact artifacts that were built, tested, and scanned in the Main workflow, maintaining supply chain integrity and build reproducibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 301390d commit 62516b5

File tree

2 files changed

+51
-55
lines changed

2 files changed

+51
-55
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'sonarqube-mcp-server': patch
3+
---
4+
5+
Remove fallback to build from source in publish workflow
6+
7+
The NPM and GitHub Packages publish jobs now fail explicitly if pre-built artifacts are not found, instead of falling back to building from source. This ensures we always publish exactly what was tested and validated in the Main workflow, maintaining supply chain integrity.

.github/workflows/publish.yml

Lines changed: 44 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -94,48 +94,42 @@ jobs:
9494
--prefix "npm-package" \
9595
--output "$GITHUB_OUTPUT"
9696
97-
- name: Try to download pre-built NPM package
97+
- name: Download pre-built NPM package
9898
id: download
9999
# Download the pre-built, pre-scanned NPM package from main workflow
100100
# This ensures we publish exactly what was tested
101-
continue-on-error: true
102101
uses: actions/download-artifact@v4
103102
with:
104103
name: ${{ steps.artifact.outputs.artifact_name }}
105104
path: ./npm-artifact
106105
run-id: ${{ steps.artifact.outputs.run_id }}
107106
github-token: ${{ secrets.GITHUB_TOKEN }}
108107

109-
- name: Use pre-built package or build from source
108+
- name: Extract pre-built package
110109
run: |
111-
if [ -d ./npm-artifact ]; then
112-
# Check if any .tgz files exist
113-
TARBALL=$(find ./npm-artifact -name "*.tgz" -type f | head -1)
114-
if [ -n "$TARBALL" ]; then
115-
echo "✅ Using pre-built NPM package from main workflow"
116-
echo "📦 Extracting: $TARBALL"
117-
tar -xzf "$TARBALL"
118-
119-
# The package extracts to a 'package' directory
120-
# We need to move its contents to the current directory
121-
if [ -d package ]; then
122-
cp -r package/* .
123-
rm -rf package
124-
fi
125-
126-
echo "📋 Verified package contents from manifest"
127-
if [ -f ./npm-artifact/npm-package-manifest.txt ]; then
128-
echo "Package contains $(wc -l < ./npm-artifact/npm-package-manifest.txt) files"
129-
fi
130-
fi
131-
else
132-
echo "⚠️ Pre-built NPM package not found, building from source"
133-
echo "This may happen if the main workflow didn't have ENABLE_NPM_RELEASE set"
110+
# Check if any .tgz files exist
111+
TARBALL=$(find ./npm-artifact -name "*.tgz" -type f | head -1)
112+
if [ -z "$TARBALL" ]; then
113+
echo "❌ No .tgz file found in artifact!"
114+
echo "Contents of ./npm-artifact:"
115+
ls -la ./npm-artifact/
116+
exit 1
117+
fi
118+
119+
echo "✅ Using pre-built NPM package from main workflow"
120+
echo "📦 Extracting: $TARBALL"
121+
tar -xzf "$TARBALL"
122+
123+
# The package extracts to a 'package' directory
124+
# We need to move its contents to the current directory
125+
if [ -d package ]; then
126+
cp -r package/* .
127+
rm -rf package
128+
fi
134129
135-
# Install dependencies and build from source as fallback
136-
npm install -g pnpm@${{ env.PNPM_VERSION }}
137-
pnpm install --frozen-lockfile
138-
pnpm build
130+
echo "📋 Verified package contents from manifest"
131+
if [ -f ./npm-artifact/npm-package-manifest.txt ]; then
132+
echo "Package contains $(wc -l < ./npm-artifact/npm-package-manifest.txt) files"
139133
fi
140134
141135
- name: Check NPM token
@@ -216,43 +210,38 @@ jobs:
216210
--prefix "npm-package" \
217211
--output "$GITHUB_OUTPUT"
218212
219-
- name: Try to download pre-built NPM package
213+
- name: Download pre-built NPM package
220214
id: download
221-
continue-on-error: true
222215
uses: actions/download-artifact@v4
223216
with:
224217
name: ${{ steps.artifact.outputs.artifact_name }}
225218
path: ./npm-artifact
226219
run-id: ${{ steps.artifact.outputs.run_id }}
227220
github-token: ${{ secrets.GITHUB_TOKEN }}
228221

229-
- name: Use pre-built package or build from source
222+
- name: Extract pre-built package
230223
run: |
231-
if [ -d ./npm-artifact ]; then
232-
# Check if any .tgz files exist
233-
TARBALL=$(find ./npm-artifact -name "*.tgz" -type f | head -1)
234-
if [ -n "$TARBALL" ]; then
235-
echo "✅ Using pre-built NPM package from main workflow"
236-
echo "📦 Extracting: $TARBALL"
237-
tar -xzf "$TARBALL"
238-
239-
# The package extracts to a 'package' directory
240-
if [ -d package ]; then
241-
cp -r package/* .
242-
rm -rf package
243-
fi
244-
245-
echo "📋 Verified package contents"
246-
fi
247-
else
248-
echo "⚠️ Pre-built NPM package not found, building from source"
224+
# Check if any .tgz files exist
225+
TARBALL=$(find ./npm-artifact -name "*.tgz" -type f | head -1)
226+
if [ -z "$TARBALL" ]; then
227+
echo "❌ No .tgz file found in artifact!"
228+
echo "Contents of ./npm-artifact:"
229+
ls -la ./npm-artifact/
230+
exit 1
231+
fi
249232
250-
# Install dependencies and build from source as fallback
251-
npm install -g pnpm@${{ env.PNPM_VERSION }}
252-
pnpm install --frozen-lockfile
253-
pnpm build
233+
echo "✅ Using pre-built NPM package from main workflow"
234+
echo "📦 Extracting: $TARBALL"
235+
tar -xzf "$TARBALL"
236+
237+
# The package extracts to a 'package' directory
238+
if [ -d package ]; then
239+
cp -r package/* .
240+
rm -rf package
254241
fi
255242
243+
echo "📋 Verified package contents"
244+
256245
- name: Publish to GitHub Packages
257246
run: |
258247
# Scope package name to organization (required for GitHub Packages)

0 commit comments

Comments
 (0)