2222 - target : x86_64-unknown-linux-musl
2323 os : ubuntu-latest
2424 name : ccline-linux-x64-static.tar.gz
25- - target : x86_64-pc-windows-gnu
26- os : ubuntu -latest
25+ - target : x86_64-pc-windows-msvc
26+ os : windows -latest
2727 name : ccline-windows-x64.zip
2828 - target : x86_64-apple-darwin
2929 os : macos-latest
4141 with :
4242 targets : ${{ matrix.target }}
4343
44- - name : Install cross-compilation tools
45- if : matrix.target == 'x86_64-pc-windows-gnu'
46- run : |
47- sudo apt-get update
48- sudo apt-get install -y mingw-w64
49-
5044 - name : Install musl tools
5145 if : matrix.target == 'x86_64-unknown-linux-musl'
5246 run : |
@@ -57,20 +51,20 @@ jobs:
5751 run : cargo build --release --target ${{ matrix.target }}
5852
5953 - name : Package Linux/macOS
60- if : matrix.os != 'windows-latest' && matrix.target != 'x86_64-pc-windows-gnu '
54+ if : matrix.os != 'windows-latest' && matrix.target != 'x86_64-pc-windows-msvc '
6155 run : |
6256 mkdir -p dist
6357 cp target/${{ matrix.target }}/release/ccometixline-packycc dist/ccline
6458 cd dist
6559 tar czf ../${{ matrix.name }} ccline
6660
6761 - name : Package Windows
68- if : matrix.target == 'x86_64-pc-windows-gnu '
62+ if : matrix.target == 'x86_64-pc-windows-msvc '
6963 run : |
70- mkdir -p dist
71- cp target/ ${{ matrix.target }}/ release/ ccometixline-packycc.exe dist/ ccline.exe
64+ mkdir dist
65+ copy " target\ ${{ matrix.target }}\ release\ ccometixline-packycc.exe" " dist\ ccline.exe"
7266 cd dist
73- zip ../ ${{ matrix.name }} ccline.exe
67+ 7z a "..\ ${{ matrix.name }}" ccline.exe
7468
7569 - name : Upload artifact
7670 uses : actions/upload-artifact@v4
@@ -138,6 +132,46 @@ jobs:
138132 # Prepare packages with version management
139133 node npm/scripts/prepare-packages.js
140134
135+ # Validate extracted binaries before copying
136+ echo "🔍 Validating extracted binaries..."
137+
138+ # Check macOS x64
139+ if [[ ! -f "extracted/ccline-darwin-x64" ]]; then
140+ echo "❌ Missing Darwin x64 binary"
141+ exit 1
142+ fi
143+ file extracted/ccline-darwin-x64
144+
145+ # Check macOS ARM64
146+ if [[ ! -f "extracted/ccline-darwin-arm64" ]]; then
147+ echo "❌ Missing Darwin ARM64 binary"
148+ exit 1
149+ fi
150+ file extracted/ccline-darwin-arm64
151+
152+ # Check Linux x64
153+ if [[ ! -f "extracted/ccline-linux-x64" ]]; then
154+ echo "❌ Missing Linux x64 binary"
155+ exit 1
156+ fi
157+ file extracted/ccline-linux-x64
158+
159+ # Check Linux musl
160+ if [[ ! -f "extracted/ccline-linux-x64-musl" ]]; then
161+ echo "❌ Missing Linux x64-musl binary"
162+ exit 1
163+ fi
164+ file extracted/ccline-linux-x64-musl
165+
166+ # Check Windows
167+ if [[ ! -f "extracted/ccline-win32-x64.exe" ]]; then
168+ echo "❌ Missing Windows x64 binary"
169+ exit 1
170+ fi
171+ file extracted/ccline-win32-x64.exe
172+
173+ echo "✅ All binaries validated successfully"
174+
141175 # Copy binaries to platform directories
142176 cp extracted/ccline-darwin-x64 npm-publish/darwin-x64/ccline
143177 cp extracted/ccline-darwin-arm64 npm-publish/darwin-arm64/ccline
@@ -151,36 +185,174 @@ jobs:
151185 chmod +x npm-publish/linux-x64/ccline
152186 chmod +x npm-publish/linux-x64-musl/ccline
153187
188+ # Final validation - check binaries in npm-publish directories
189+ echo "🔍 Validating copied binaries in npm-publish directories..."
190+ for platform in darwin-x64 darwin-arm64 linux-x64 linux-x64-musl; do
191+ binary_path="npm-publish/$platform/ccline"
192+ if [[ ! -f "$binary_path" ]]; then
193+ echo "❌ Missing binary in $platform directory"
194+ exit 1
195+ fi
196+ if [[ ! -x "$binary_path" ]]; then
197+ echo "❌ Binary not executable in $platform directory"
198+ exit 1
199+ fi
200+ echo "✅ $platform: binary ready"
201+ done
202+
203+ # Check Windows binary
204+ if [[ ! -f "npm-publish/win32-x64/ccline.exe" ]]; then
205+ echo "❌ Missing Windows binary in npm-publish directory"
206+ exit 1
207+ fi
208+ echo "✅ win32-x64: binary ready"
209+
154210 # Verify packages
155- echo "Package structure:"
211+ echo "📋 Package structure verification :"
156212 find npm-publish -name "package.json" -exec echo "=== {} ===" \; -exec head -5 {} \;
157213
158214 - name : Publish platform packages to NPM
159215 env :
160216 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
161217 run : |
162- # Publish platform packages first
163- for platform in darwin-x64 darwin-arm64 linux-x64 linux-x64-musl win32-x64; do
164- echo "📦 Publishing @ding113/ccline-packycc-$platform"
218+ # Function to publish with retry
219+ publish_with_retry() {
220+ local platform=$1
221+ local max_attempts=3
222+ local attempt=1
223+
165224 cd npm-publish/$platform
166- npm publish --access public
225+ PACKAGE_NAME=$(node -p "require('./package.json').name")
226+
227+ while [ $attempt -le $max_attempts ]; do
228+ echo "📦 Publishing $PACKAGE_NAME (attempt $attempt/$max_attempts)"
229+
230+ if npm publish --access public; then
231+ echo "✅ Published $PACKAGE_NAME successfully"
232+
233+ # Verify package is available on NPM registry
234+ echo "🔍 Verifying $PACKAGE_NAME availability..."
235+ sleep 10
236+
237+ if npm view $PACKAGE_NAME version >/dev/null 2>&1; then
238+ echo "✅ Verified $PACKAGE_NAME is available on NPM"
239+ cd ../..
240+ return 0
241+ else
242+ echo "⚠️ Package published but not yet available on registry, retrying verification..."
243+ sleep 15
244+
245+ if npm view $PACKAGE_NAME version >/dev/null 2>&1; then
246+ echo "✅ Verified $PACKAGE_NAME is now available on NPM"
247+ cd ../..
248+ return 0
249+ fi
250+ fi
251+ fi
252+
253+ echo "❌ Attempt $attempt failed for $PACKAGE_NAME"
254+ attempt=$((attempt + 1))
255+
256+ if [ $attempt -le $max_attempts ]; then
257+ echo "⏳ Waiting 30 seconds before retry..."
258+ sleep 30
259+ fi
260+ done
261+
262+ echo "❌ Failed to publish $PACKAGE_NAME after $max_attempts attempts"
167263 cd ../..
168- echo "✅ Published @ding113/ccline-packycc-$platform"
264+ return 1
265+ }
266+
267+ # Publish platform packages with retry logic
268+ echo "🚀 Publishing platform packages with retry logic..."
269+ failed_packages=()
270+
271+ for platform in darwin-x64 darwin-arm64 linux-x64 linux-x64-musl win32-x64; do
272+ if ! publish_with_retry $platform; then
273+ failed_packages+=($platform)
274+ fi
169275 done
276+
277+ # Check if any packages failed
278+ if [ ${#failed_packages[@]} -gt 0 ]; then
279+ echo "❌ The following packages failed to publish:"
280+ printf '%s\n' "${failed_packages[@]}"
281+ echo "❌ Aborting release due to platform package failures"
282+ exit 1
283+ fi
284+
285+ echo "✅ All platform packages published successfully!"
170286
171287 - name : Wait for NPM registry
172288 run : |
173289 echo "⏳ Waiting for platform packages to be available on NPM..."
174- sleep 30
290+ sleep 60
175291
176292 - name : Publish main package to NPM
177293 env :
178294 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
179295 run : |
180296 cd npm-publish/main
181- echo "📦 Publishing @ding113/ccline-packycc"
182- npm publish --access public
183- echo "✅ Published @ding113/ccline-packycc"
184- echo ""
185- echo "🎉 NPM packages published successfully!"
186- echo "Install with: npm install -g @ding113/ccline-packycc"
297+ PACKAGE_NAME=$(node -p "require('./package.json').name")
298+
299+ # Function to publish main package with retry
300+ publish_main_with_retry() {
301+ local max_attempts=3
302+ local attempt=1
303+
304+ while [ $attempt -le $max_attempts ]; do
305+ echo "📦 Publishing $PACKAGE_NAME (attempt $attempt/$max_attempts)"
306+
307+ if npm publish --access public; then
308+ echo "✅ Published $PACKAGE_NAME successfully"
309+
310+ # Verify package is available on NPM registry
311+ echo "🔍 Verifying $PACKAGE_NAME availability..."
312+ sleep 10
313+
314+ if npm view $PACKAGE_NAME version >/dev/null 2>&1; then
315+ echo "✅ Verified $PACKAGE_NAME is available on NPM"
316+ return 0
317+ else
318+ echo "⚠️ Package published but not yet available on registry, retrying verification..."
319+ sleep 15
320+
321+ if npm view $PACKAGE_NAME version >/dev/null 2>&1; then
322+ echo "✅ Verified $PACKAGE_NAME is now available on NPM"
323+ return 0
324+ fi
325+ fi
326+ fi
327+
328+ echo "❌ Attempt $attempt failed for $PACKAGE_NAME"
329+ attempt=$((attempt + 1))
330+
331+ if [ $attempt -le $max_attempts ]; then
332+ echo "⏳ Waiting 30 seconds before retry..."
333+ sleep 30
334+ fi
335+ done
336+
337+ echo "❌ Failed to publish $PACKAGE_NAME after $max_attempts attempts"
338+ return 1
339+ }
340+
341+ # Publish main package
342+ if publish_main_with_retry; then
343+ echo "✅ Main package published successfully!"
344+ echo ""
345+ echo "🎉 NPM packages published successfully!"
346+ echo "📥 Install with: npm install -g $PACKAGE_NAME"
347+
348+ # Final verification - check that main package can find all dependencies
349+ echo "🔍 Final verification - checking package dependencies..."
350+ if npm view $PACKAGE_NAME optionalDependencies >/dev/null 2>&1; then
351+ echo "✅ Main package dependencies verified"
352+ else
353+ echo "⚠️ Warning: Could not verify main package dependencies"
354+ fi
355+ else
356+ echo "❌ Failed to publish main package"
357+ exit 1
358+ fi
0 commit comments