Update main.yml #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Acode Plugin | ||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| pull_request: | ||
| branches: ["main"] | ||
| workflow_dispatch: {} | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'npm' | ||
| - name: Install dependencies | ||
| shell: bash | ||
| run: | | ||
| npm install | ||
| - name: Run build script (show stdout/stderr) | ||
| shell: bash | ||
| run: | | ||
| echo "== RUNNING BUILD ==" | ||
| node -v | ||
| npm -v | ||
| set -o pipefail | ||
| npm run build 2>&1 | tee build-output.log || true | ||
| echo "=== BUILD OUTPUT (last 200 lines) ===" | ||
| tail -n 200 build-output.log || true | ||
| - name: Debug: show workspace recursively | ||
| shell: bash | ||
| run: | | ||
| echo "Working dir: $(pwd)" | ||
| echo "Top-level files:" | ||
| ls -la | ||
| echo "Find zip files (if any):" | ||
| find . -type f -name "*.zip" -print -exec ls -lh {} \; || true | ||
| echo "Show dist folder (if exists):" | ||
| if [ -d "dist" ]; then | ||
| ls -la dist | ||
| else | ||
| echo "dist/ not found" | ||
| fi | ||
| echo "Show .acode folder (if exists):" | ||
| if [ -d ".acode" ]; then | ||
| ls -la .acode | ||
| else | ||
| echo ".acode/ not found" | ||
| fi | ||
| - name: Ensure zip tool present | ||
| shell: bash | ||
| run: | | ||
| if ! command -v zip >/dev/null; then | ||
| sudo apt-get update -y | ||
| sudo apt-get install -y zip | ||
| fi | ||
| zip -v || true | ||
| - name: Create artifact zip (guaranteed) | ||
| shell: bash | ||
| run: | | ||
| mkdir -p .artifacts | ||
| found=0 | ||
| # copy any existing zip files into .artifacts | ||
| find . -type f -name "*.zip" -print0 | while IFS= read -r -d '' f; do | ||
| echo "Copying existing zip: $f" | ||
| cp "$f" .artifacts/ || true | ||
| found=1 | ||
| done | ||
| # if no zip found, create one from dist (and manifest.json if present) | ||
| if [ "$found" -eq 0 ]; then | ||
| echo "No existing zip found — creating .artifacts/acode-plugin.zip from dist/ + manifest.json" | ||
| if [ -d "dist" ]; then | ||
| if [ -f "manifest.json" ]; then | ||
| zip -r .artifacts/acode-plugin.zip dist manifest.json >/dev/null 2>&1 || true | ||
| else | ||
| zip -r .artifacts/acode-plugin.zip dist >/dev/null 2>&1 || true | ||
| fi | ||
| else | ||
| echo "ERROR: dist/ not found. Listing current dir:" | ||
| ls -la | ||
| fi | ||
| fi | ||
| echo "Contents of .artifacts:" | ||
| ls -la .artifacts || true | ||
| - name: Upload plugin artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: acode-plugin | ||
| path: .artifacts/*.zip | ||