Skip to content

Commit 4436ce2

Browse files
authored
Merge pull request #2 from pnstack/copilot/setup-ci-cd-for-electron
Add production-ready CI/CD pipeline for Electron template
2 parents bdf62e4 + 92ff6bf commit 4436ce2

16 files changed

Lines changed: 1109 additions & 0 deletions

.github/CI_CD_DOCUMENTATION.md

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
# CI/CD Documentation
2+
3+
## Overview
4+
5+
This Electron template includes a comprehensive CI/CD setup using GitHub Actions. The workflows are designed to automate testing, building, and releasing across multiple platforms.
6+
7+
## Workflows
8+
9+
### 1. CI Workflow (`ci.yml`)
10+
11+
**Triggers:**
12+
- Push to `main` or `develop` branches
13+
- Pull requests to `main` or `develop` branches
14+
- Manual trigger via workflow dispatch
15+
16+
**What it does:**
17+
- Runs on Ubuntu, Windows, and macOS
18+
- Tests with Node.js 18.x and 20.x
19+
- Installs dependencies with caching
20+
- Performs TypeScript type checking
21+
- Builds the project
22+
- Builds the Electron application
23+
- Uploads build artifacts
24+
25+
**Usage:** Automatically runs on every push/PR. No manual intervention needed.
26+
27+
### 2. Release Workflow (`release.yml`)
28+
29+
**Triggers:**
30+
- Push of version tags (e.g., `v1.0.0`)
31+
- Manual trigger with version input
32+
33+
**What it does:**
34+
- Builds for Windows (NSIS installer)
35+
- Builds for macOS (DMG)
36+
- Builds for Linux (AppImage, deb)
37+
- Creates a GitHub release
38+
- Uploads binaries as release assets
39+
- Generates release notes automatically
40+
41+
**Usage:**
42+
```bash
43+
# Create a new release
44+
git tag v1.0.0
45+
git push origin v1.0.0
46+
47+
# Or use manual dispatch from GitHub Actions tab
48+
```
49+
50+
### 3. PR Check Workflow (`pr-check.yml`)
51+
52+
**Triggers:**
53+
- Pull request opened, synchronized, or reopened
54+
55+
**What it does:**
56+
- TypeScript type checking
57+
- Build verification
58+
- PR size warnings (alerts if PR has >1000 changes)
59+
60+
**Usage:** Automatically runs on PR creation/updates.
61+
62+
### 4. Code Quality Workflow (`quality.yml`)
63+
64+
**Triggers:**
65+
- Push to `main` or `develop` branches
66+
- Pull requests to `main` or `develop` branches
67+
- Weekly schedule (Mondays at 00:00 UTC)
68+
69+
**What it does:**
70+
- TypeScript type checking
71+
- Checks for console.log statements
72+
- npm security audit
73+
- Bundle size analysis
74+
75+
**Usage:** Runs automatically on schedule and with pushes/PRs.
76+
77+
### 5. Stale Workflow (`stale.yml`)
78+
79+
**Triggers:**
80+
- Daily schedule (00:00 UTC)
81+
- Manual trigger via workflow dispatch
82+
83+
**What it does:**
84+
- Marks issues as stale after 60 days of inactivity
85+
- Marks PRs as stale after 30 days of inactivity
86+
- Closes stale issues/PRs after 7 additional days
87+
- Respects exemption labels (pinned, security, etc.)
88+
89+
**Usage:** Runs automatically daily.
90+
91+
## Dependabot
92+
93+
**Configuration:** `.github/dependabot.yml`
94+
95+
**Updates:**
96+
- npm packages: Weekly
97+
- GitHub Actions: Weekly
98+
99+
**Labels:** `dependencies`, `automated`, `github-actions`
100+
101+
## Issue Templates
102+
103+
### Bug Report (`bug_report.yml`)
104+
Structured form for reporting bugs with:
105+
- Description
106+
- Steps to reproduce
107+
- Expected vs actual behavior
108+
- Environment details (OS, Node.js version)
109+
110+
### Feature Request (`feature_request.yml`)
111+
Structured form for suggesting features with:
112+
- Problem statement
113+
- Proposed solution
114+
- Alternatives considered
115+
- Implementation complexity
116+
117+
## Pull Request Template
118+
119+
**Location:** `.github/PULL_REQUEST_TEMPLATE.md`
120+
121+
**Includes:**
122+
- Description
123+
- Type of change
124+
- Related issues
125+
- Changes made
126+
- Testing checklist
127+
- Review checklist
128+
129+
## Security
130+
131+
**Security Policy:** `SECURITY.md`
132+
133+
**Best Practices:**
134+
- npm audit runs in quality workflow
135+
- Dependabot monitors dependencies
136+
- Security label exempts issues from stale bot
137+
138+
## Contributing
139+
140+
**Contributing Guide:** `CONTRIBUTING.md`
141+
142+
**Includes:**
143+
- Development setup
144+
- Code quality guidelines
145+
- Commit message conventions
146+
- PR process
147+
- Building instructions
148+
- Release process
149+
150+
## Badges
151+
152+
The README includes badges for:
153+
- CI workflow status
154+
- Release workflow status
155+
- Code Quality workflow status
156+
- MIT License
157+
158+
## Release Process
159+
160+
### Automated Release (Recommended)
161+
162+
1. Update version in `package.json`
163+
2. Update `CHANGELOG.md`
164+
3. Commit changes
165+
4. Create and push tag:
166+
```bash
167+
git tag v1.0.0
168+
git push origin v1.0.0
169+
```
170+
5. GitHub Actions will automatically:
171+
- Build for all platforms
172+
- Create GitHub release
173+
- Upload binaries
174+
- Generate release notes
175+
176+
### Manual Release
177+
178+
1. Go to Actions tab on GitHub
179+
2. Select "Release" workflow
180+
3. Click "Run workflow"
181+
4. Enter version (e.g., v1.0.0)
182+
5. Click "Run workflow" button
183+
184+
## Local Testing
185+
186+
Before pushing changes, test locally:
187+
188+
```bash
189+
# Install dependencies
190+
npm ci
191+
192+
# Type check
193+
npx tsc --noEmit
194+
195+
# Build
196+
npm run build
197+
198+
# Test Electron build (will take longer)
199+
npm run electron:build
200+
```
201+
202+
## Troubleshooting
203+
204+
### CI Fails on Type Checking
205+
- Run `npx tsc --noEmit` locally
206+
- Fix type errors
207+
- Commit and push
208+
209+
### Build Fails
210+
- Check `vite.config.ts` configuration
211+
- Ensure all dependencies are installed
212+
- Check for missing files
213+
214+
### Release Fails
215+
- Ensure tag follows semantic versioning (v1.0.0)
216+
- Check `package.json` version matches tag
217+
- Verify `electron-builder` configuration in `package.json`
218+
219+
### Artifacts Not Uploaded
220+
- Check workflow permissions
221+
- Verify artifact paths in workflow
222+
- Ensure build completed successfully
223+
224+
## Maintenance
225+
226+
### Updating Workflows
227+
228+
1. Edit workflow files in `.github/workflows/`
229+
2. Test locally if possible
230+
3. Commit and push to a feature branch
231+
4. Create PR to verify changes
232+
5. Merge when CI passes
233+
234+
### Updating Dependencies
235+
236+
- Dependabot will create PRs automatically
237+
- Review changes in PR
238+
- Merge if CI passes
239+
- Monitor for breaking changes
240+
241+
## Best Practices
242+
243+
1. **Always test locally** before pushing
244+
2. **Use semantic versioning** for releases
245+
3. **Update CHANGELOG.md** for each release
246+
4. **Keep dependencies updated** via Dependabot
247+
5. **Monitor CI failures** and fix promptly
248+
6. **Review Dependabot PRs** regularly
249+
7. **Keep documentation updated** with changes
250+
251+
## Resources
252+
253+
- [GitHub Actions Documentation](https://docs.github.com/en/actions)
254+
- [Electron Builder Documentation](https://www.electron.build/)
255+
- [Semantic Versioning](https://semver.org/)
256+
- [Keep a Changelog](https://keepachangelog.com/)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Bug Report
2+
description: File a bug report to help us improve
3+
title: "[Bug]: "
4+
labels: ["bug", "triage"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for taking the time to fill out this bug report!
10+
11+
- type: textarea
12+
id: description
13+
attributes:
14+
label: Bug Description
15+
description: A clear and concise description of what the bug is.
16+
placeholder: Tell us what you see!
17+
validations:
18+
required: true
19+
20+
- type: textarea
21+
id: reproduction
22+
attributes:
23+
label: Steps to Reproduce
24+
description: Steps to reproduce the behavior
25+
placeholder: |
26+
1. Go to '...'
27+
2. Click on '...'
28+
3. Scroll down to '...'
29+
4. See error
30+
validations:
31+
required: true
32+
33+
- type: textarea
34+
id: expected
35+
attributes:
36+
label: Expected Behavior
37+
description: A clear and concise description of what you expected to happen.
38+
validations:
39+
required: true
40+
41+
- type: textarea
42+
id: actual
43+
attributes:
44+
label: Actual Behavior
45+
description: What actually happened
46+
validations:
47+
required: true
48+
49+
- type: textarea
50+
id: screenshots
51+
attributes:
52+
label: Screenshots
53+
description: If applicable, add screenshots to help explain your problem.
54+
55+
- type: dropdown
56+
id: os
57+
attributes:
58+
label: Operating System
59+
options:
60+
- Windows
61+
- macOS
62+
- Linux
63+
- Other
64+
validations:
65+
required: true
66+
67+
- type: input
68+
id: node-version
69+
attributes:
70+
label: Node.js Version
71+
description: Output of `node --version`
72+
placeholder: v20.0.0
73+
validations:
74+
required: true
75+
76+
- type: input
77+
id: electron-version
78+
attributes:
79+
label: Electron Version
80+
description: Check package.json or node_modules
81+
placeholder: 39.2.6
82+
83+
- type: textarea
84+
id: additional
85+
attributes:
86+
label: Additional Context
87+
description: Add any other context about the problem here.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
blank_issues_enabled: true
2+
contact_links:
3+
- name: 💬 Ask a Question
4+
url: https://github.com/pnstack/template-electron/discussions
5+
about: Ask questions and discuss with the community
6+
- name: 📚 Documentation
7+
url: https://github.com/pnstack/template-electron/blob/main/README.md
8+
about: Read the documentation
9+
- name: 🔒 Security Issue
10+
url: https://github.com/pnstack/template-electron/security/policy
11+
about: Report security vulnerabilities

0 commit comments

Comments
 (0)