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
Markdown
# π 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! π