Skip to content

Commit 18d80b5

Browse files
committed
GH Build & Release (WIN)
1 parent 0500cf5 commit 18d80b5

5 files changed

Lines changed: 271 additions & 2 deletions

File tree

File renamed without changes.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
tags:
7+
- 'v*'
8+
pull_request:
9+
branches: [ main, master ]
10+
11+
jobs:
12+
build:
13+
runs-on: windows-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '18'
23+
cache: 'npm'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Build renderer
29+
run: npm run build:renderer
30+
31+
- name: Build Electron app for Windows
32+
run: npm run build
33+
env:
34+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Upload Windows artifacts
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: windows-build
40+
path: |
41+
dist/*.exe
42+
dist/*.msi
43+
dist/*.zip
44+
dist/*Setup*.exe
45+
dist/*Portable*.exe
46+
retention-days: 30
47+
if-no-files-found: warn
48+
49+
release:
50+
needs: build
51+
runs-on: ubuntu-latest
52+
if: startsWith(github.ref, 'refs/tags/v')
53+
54+
steps:
55+
- name: Checkout code
56+
uses: actions/checkout@v4
57+
58+
- name: Download Windows artifacts
59+
uses: actions/download-artifact@v4
60+
with:
61+
name: windows-build
62+
path: dist/
63+
64+
- name: Create GitHub Release
65+
uses: softprops/action-gh-release@v1
66+
with:
67+
files: |
68+
dist/*.exe
69+
dist/*.msi
70+
dist/*.zip
71+
draft: false
72+
prerelease: false
73+
generate_release_notes: true
74+
name: Release ${{ github.ref_name }}
75+
tag_name: ${{ github.ref_name }}
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
79+
# Optional: Build on every push for testing (without release)
80+
build-on-push:
81+
runs-on: windows-latest
82+
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
83+
84+
steps:
85+
- name: Checkout code
86+
uses: actions/checkout@v4
87+
88+
- name: Setup Node.js
89+
uses: actions/setup-node@v4
90+
with:
91+
node-version: '18'
92+
cache: 'npm'
93+
94+
- name: Install dependencies
95+
run: npm ci
96+
97+
- name: Build renderer
98+
run: npm run build:renderer
99+
100+
- name: Test build (without publishing)
101+
run: npx electron-builder --windows --publish never
102+
env:
103+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

RELEASE.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Release Process
2+
3+
This project is configured with automated GitHub Actions to build and release Windows executables.
4+
5+
## How it works
6+
7+
1. **On every push** to `main`/`master`: The workflow builds the app to test that everything compiles correctly
8+
2. **On tag push** (version tags like `v1.0.0`): The workflow builds the app and creates a GitHub release with Windows executables
9+
10+
## Creating a Release
11+
12+
### Method 1: Using the release scripts (Recommended)
13+
14+
```bash
15+
# For patch version (1.0.0 -> 1.0.1)
16+
npm run release:patch
17+
18+
# For minor version (1.0.0 -> 1.1.0)
19+
npm run release:minor
20+
21+
# For major version (1.0.0 -> 2.0.0)
22+
npm run release:major
23+
```
24+
25+
These scripts will:
26+
- Bump the version in `package.json`
27+
- Create a git tag
28+
- Push changes and tags to GitHub
29+
- Trigger the GitHub Actions workflow automatically
30+
31+
### Method 2: Manual process
32+
33+
```bash
34+
# Bump version manually
35+
npm version patch # or minor, major
36+
37+
# Push changes and tags
38+
git push
39+
git push --tags
40+
```
41+
42+
## What gets built
43+
44+
The GitHub Actions workflow will create:
45+
- **NSIS Installer** (`.exe`) - Standard Windows installer
46+
- **Portable Executable** (`.exe`) - Standalone executable that doesn't require installation
47+
- **MSI Package** (if configured) - Windows Installer package
48+
49+
## Build Configuration
50+
51+
The build configuration is in `package.json` under the `build` section:
52+
53+
```json
54+
{
55+
"build": {
56+
"appId": "cdc.starterkit.electron",
57+
"productName": "CDC Electron Starterkit",
58+
"win": {
59+
"target": [
60+
{
61+
"target": "nsis",
62+
"arch": ["x64"]
63+
},
64+
{
65+
"target": "portable",
66+
"arch": ["x64"]
67+
}
68+
]
69+
}
70+
}
71+
}
72+
```
73+
74+
## GitHub Actions Workflow
75+
76+
The workflow file is located at `.github/workflows/build-and-release.yml` and includes:
77+
78+
- **Build job**: Runs on Windows, builds the app, uploads artifacts
79+
- **Release job**: Creates GitHub release with built executables (only on tag push)
80+
- **Build-on-push job**: Tests builds on every push without releasing
81+
82+
## Requirements
83+
84+
- Repository must have GitHub Actions enabled
85+
- The `GITHUB_TOKEN` is automatically provided by GitHub Actions
86+
- Repository must match the one configured in `package.json` (`codesign-cloud/cdc-electron-starterkit`)
87+
88+
## Troubleshooting
89+
90+
If builds fail:
91+
1. Check the GitHub Actions logs in the "Actions" tab of your repository
92+
2. Ensure all dependencies are properly listed in `package.json`
93+
3. Test the build locally with `npm run build`
94+
4. Make sure the repository name in `package.json` matches your actual repository
95+
96+
## Local Testing
97+
98+
To test the build process locally:
99+
100+
```bash
101+
# Install dependencies
102+
npm ci
103+
104+
# Build renderer
105+
npm run build:renderer
106+
107+
# Build for Windows (requires Windows or cross-compilation setup)
108+
npm run build

package.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cdc-electron-starterkit",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Electron app starter kit",
55
"author": {
66
"name": "thinkdj",
@@ -24,6 +24,18 @@
2424
"dmg": {
2525
"icon": false
2626
},
27+
"win": {
28+
"target": [
29+
{
30+
"target": "nsis",
31+
"arch": ["x64"]
32+
},
33+
{
34+
"target": "portable",
35+
"arch": ["x64"]
36+
}
37+
]
38+
},
2739
"linux": {
2840
"target": [
2941
"AppImage"
@@ -46,7 +58,10 @@
4658
"test": "jest",
4759
"test:watch": "jest --watch",
4860
"lint": "echo 'Linting not configured yet'",
49-
"clean": "rimraf dist"
61+
"clean": "rimraf dist",
62+
"release:patch": "node scripts/create-release.js patch",
63+
"release:minor": "node scripts/create-release.js minor",
64+
"release:major": "node scripts/create-release.js major"
5065
},
5166
"license": "CC0-1.0",
5267
"devDependencies": {

scripts/create-release.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env node
2+
3+
const { execSync } = require('child_process');
4+
const fs = require('fs');
5+
const path = require('path');
6+
7+
// Read current version from package.json
8+
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
9+
const currentVersion = packageJson.version;
10+
11+
console.log(`Current version: ${currentVersion}`);
12+
13+
// Get version type from command line argument
14+
const versionType = process.argv[2] || 'patch';
15+
16+
if (!['major', 'minor', 'patch'].includes(versionType)) {
17+
console.error('Usage: node scripts/create-release.js [major|minor|patch]');
18+
process.exit(1);
19+
}
20+
21+
try {
22+
// Bump version
23+
console.log(`Bumping ${versionType} version...`);
24+
execSync(`npm version ${versionType}`, { stdio: 'inherit' });
25+
26+
// Get new version
27+
const newPackageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
28+
const newVersion = newPackageJson.version;
29+
30+
console.log(`New version: ${newVersion}`);
31+
32+
// Push changes and tags
33+
console.log('Pushing changes and tags...');
34+
execSync('git push', { stdio: 'inherit' });
35+
execSync('git push --tags', { stdio: 'inherit' });
36+
37+
console.log(`✅ Release v${newVersion} created successfully!`);
38+
console.log('GitHub Actions will now build and create the release automatically.');
39+
40+
} catch (error) {
41+
console.error('❌ Error creating release:', error.message);
42+
process.exit(1);
43+
}

0 commit comments

Comments
 (0)