UNPKG

filetree-pro

Version:

A powerful file tree generator for VS Code and Cursor. Generate beautiful file trees in multiple formats with smart exclusions and custom configurations.

385 lines (264 loc) β€’ 8.82 kB
# πŸ”„ CI/CD Pipeline Explained ## πŸ“‹ Overview Your CI/CD pipeline has **4 stages** that run in different scenarios: | Stage | Runs On | Purpose | | -------------------- | ----------------------------- | ------------------------ | | πŸ§ͺ **Test** | PRs, Pushes to main, Releases | Validate code quality | | πŸ“¦ **Package** | PRs, Pushes to main, Releases | Build VSIX extension | | πŸš€ **Publish** | Releases only | Publish to marketplaces | | πŸ“Ž **Release Asset** | Releases only | Upload to GitHub release | --- ## 🎯 Workflow Triggers ### 1. **Pull Requests to `main`** ```yaml on: pull_request: branches: [main] ``` **What Runs:** - βœ… Build & Test (validate code) - βœ… Package Extension (test packaging works) - ❌ Publish (skip - not ready for production) - ❌ Release Asset (skip - no release yet) **Use Case:** Pre-merge validation --- ### 2. **Push to `main` Branch** ```yaml on: push: branches: [main] ``` **What Runs:** - βœ… Build & Test - βœ… Package Extension (creates VSIX) - ❌ Publish (skip - no release event) - ❌ Release Asset (skip - no release event) **Use Case:** Post-merge validation and artifact creation --- ### 3. **GitHub Release Created** ```yaml on: release: types: [published] ``` **What Runs:** - βœ… Build & Test - βœ… Package Extension - βœ… Publish to VS Code Marketplace - βœ… Publish to Open VSX Registry - βœ… Upload VSIX to GitHub Release **Use Case:** Production deployment --- ## πŸ” Job Conditions Explained ### **Test Job** - No Conditions βœ… ```yaml test: runs-on: ubuntu-latest # No if condition - ALWAYS RUNS ``` - Runs on: PRs, pushes, releases - Purpose: Validate code before anything else --- ### **Package Job** - Conditional βš™οΈ ```yaml package: needs: test if: | github.event_name == 'pull_request' || (github.ref == 'refs/heads/main' && github.event_name == 'push') || github.event_name == 'release' ``` **Runs When:** - βœ… Pull request (to test packaging) - βœ… Push to main (to create artifact) - βœ… Release event (for publishing) **Skips When:** - ❌ Push to other branches (dev, feature branches) --- ### **Publish Job** - Releases Only πŸš€ ```yaml publish: needs: [test, package] if: github.event_name == 'release' && github.event.action == 'published' environment: production ``` **Runs When:** - βœ… **ONLY** on GitHub release creation **Skips When:** - ❌ Pull requests - ❌ Branch pushes (including main) **Why:** Publishing to marketplaces should only happen on intentional releases, not automatic merges. --- ### **Release Asset Job** - Releases Only πŸ“Ž ```yaml release-asset: needs: [test, package] if: github.event_name == 'release' && github.event.action == 'published' ``` **Runs When:** - βœ… **ONLY** on GitHub release creation **Skips When:** - ❌ Pull requests - ❌ Branch pushes **Why:** Only upload VSIX to release page when creating a release. --- ## 🎬 Example Scenarios ### Scenario 1: Developer Creates PR ``` dev/feature-branch β†’ PR to main ``` **Pipeline:** 1. βœ… Build & Test (27s) - Validates code 2. βœ… Package Extension (15s) - Tests packaging 3. ⏭️ Publish - Skipped (not a release) 4. ⏭️ Release Asset - Skipped (not a release) **Result:** Developer knows code works and extension packages correctly --- ### Scenario 2: PR Merged to Main ``` git push origin main ``` **Pipeline:** 1. βœ… Build & Test (27s) 2. βœ… Package Extension (15s) - Creates VSIX artifact 3. ⏭️ Publish - Skipped (not a release) 4. ⏭️ Release Asset - Skipped (not a release) **Result:** VSIX artifact available for 10 days (testing purposes) --- ### Scenario 3: Create GitHub Release ``` GitHub UI: Create new release v0.2.0 ``` **Pipeline:** 1. βœ… Build & Test (27s) 2. βœ… Package Extension (15s) 3. βœ… Publish to VS Code Marketplace (30s) 4. βœ… Publish to Open VSX (20s) 5. βœ… Upload VSIX to Release (5s) **Result:** Extension live in both marketplaces + VSIX downloadable from GitHub --- ## 🚨 Troubleshooting ### Issue: "Jobs are skipped on PR" **Old Behavior (Before Fix):** ```yaml if: (github.ref == 'refs/heads/main' && github.event_name == 'push') || github.event_name == 'release' ``` - ❌ Skipped all PRs - ❌ No packaging validation before merge **New Behavior (After Fix):** ```yaml if: | github.event_name == 'pull_request' || (github.ref == 'refs/heads/main' && github.event_name == 'push') || github.event_name == 'release' ``` - βœ… Runs on PRs for validation - βœ… Catches packaging issues early --- ### Issue: "Package job runs but Publish is skipped" **This is CORRECT behavior!** Publishing should **only** happen on releases: ```yaml if: github.event_name == 'release' && github.event.action == 'published' ``` **To publish:** 1. Go to GitHub β†’ Releases 2. Click "Create a new release" 3. Choose tag version (e.g., `v0.2.0`) 4. Click "Publish release" 5. Pipeline automatically publishes to marketplaces --- ### Issue: "How do I test the full pipeline?" **Create a test release:** ```bash # 1. Create and push a tag git tag v0.2.0-beta git push origin v0.2.0-beta # 2. Create release on GitHub using this tag # 3. Mark as "pre-release" for testing ``` **Or use `workflow_dispatch` for manual runs:** ```yaml on: workflow_dispatch: inputs: environment: description: 'Environment to deploy' required: true default: 'staging' ``` --- ## πŸ“Š Workflow Diagram ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Trigger Event β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β” β”‚ Test β”‚ ← Always runs β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β” β”‚ Package β”‚ ← Runs on PRs, main, releases β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β” β”‚ Publish β”‚ β”‚ Publish β”‚ β”‚Upload Releaseβ”‚ β”‚ VSCE β”‚ β”‚ Open VSX β”‚ β”‚ Asset β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ Only on releases ``` --- ## 🎯 Best Practices ### 1. **Branch Strategy** ``` feature/* β†’ dev β†’ main β†’ release ``` - Feature branches: Local development - `dev` branch: Integration testing - `main` branch: Stable, tested code - Releases: Production deployments ### 2. **Release Workflow** ```bash # 1. Merge to main git checkout main git merge dev # 2. Update version in package.json npm version patch # or minor, major # 3. Push changes git push origin main git push origin --tags # 4. Create GitHub release # Go to GitHub UI and create release from tag ``` ### 3. **Testing Before Release** - βœ… Create PR β†’ Test and Package run - βœ… Merge to main β†’ Package creates artifact - βœ… Download artifact from GitHub Actions - βœ… Test VSIX locally: `code --install-extension filetree-pro-x.x.x.vsix` - βœ… If good, create release --- ## πŸ”’ Required Secrets For publishing to work, set these in GitHub: - **Settings β†’ Secrets β†’ Actions** | Secret | Purpose | Get From | | ---------- | ------------------- | ------------------------------------- | | `VSCE_PAT` | VS Code Marketplace | https://marketplace.visualstudio.com/ | | `OVSX_PAT` | Open VSX Registry | https://open-vsx.org/ | --- ## πŸ“š Additional Resources - [GitHub Actions Contexts](https://docs.github.com/en/actions/learn-github-actions/contexts) - [VS Code Publishing](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) - [Open VSX Publishing](https://github.com/eclipse/openvsx/wiki/Publishing-Extensions) --- ## πŸŽ‰ Summary **Your pipeline is designed to:** 1. βœ… Test everything (PRs, pushes, releases) 2. βœ… Package on PRs (catch issues early) 3. βœ… Create artifacts on main (for testing) 4. βœ… Publish only on releases (intentional deployments) **The "skipped jobs" are by design** - they only run when needed! πŸš€