Skip to content

Commit e2cc6a9

Browse files
committed
Add workflows
1 parent 1b97c4a commit e2cc6a9

File tree

3 files changed

+377
-0
lines changed

3 files changed

+377
-0
lines changed

.github/workflows/README.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# GitHub Workflows
2+
3+
This directory contains GitHub Actions workflows for building and releasing GhostDraw.
4+
5+
## Workflows
6+
7+
### 1. CI Build (`ci.yml`)
8+
9+
**Triggers:**
10+
- Push to `main` branch
11+
- Pull requests to `main` branch
12+
13+
**What it does:**
14+
- Builds the application
15+
- Runs tests
16+
- Builds the installer MSI
17+
- Uploads installer as artifact (retained for 7 days)
18+
19+
**Purpose:** Ensures the code builds successfully and the installer can be created.
20+
21+
---
22+
23+
### 2. Release Build (`release.yml`)
24+
25+
**Triggers:**
26+
- Push of version tags (e.g., `v1.0.0`, `v1.2.3`)
27+
28+
**What it does:**
29+
1. Extracts version from the tag
30+
2. Builds the application with the version number
31+
3. Generates WiX component list
32+
4. Builds the installer MSI
33+
5. Creates a GitHub release
34+
6. Uploads the MSI to the release
35+
36+
**Purpose:** Automates the release process and creates downloadable installers.
37+
38+
---
39+
40+
## Creating a Release
41+
42+
To create a new release:
43+
44+
### 1. Update Version (Optional)
45+
46+
If you want to update version strings in the code:
47+
48+
```bash
49+
# Update version in Product.wxs if needed
50+
# Update version in GhostDraw.csproj if needed
51+
```
52+
53+
### 2. Create and Push a Version Tag
54+
55+
```bash
56+
# Create a tag
57+
git tag v1.0.0
58+
59+
# Or create an annotated tag with a message
60+
git tag -a v1.0.0 -m "Release version 1.0.0"
61+
62+
# Push the tag to GitHub
63+
git push origin v1.0.0
64+
```
65+
66+
### 3. Monitor the Workflow
67+
68+
1. Go to **Actions** tab in GitHub
69+
2. Watch the "Build and Release" workflow run
70+
3. Once complete, check the **Releases** page
71+
72+
### 4. Verify the Release
73+
74+
The release will include:
75+
- Release notes
76+
- `GhostDrawSetup-1.0.0.msi` installer file
77+
- Download statistics
78+
79+
---
80+
81+
## Version Numbering
82+
83+
Use [Semantic Versioning](https://semver.org/):
84+
- **MAJOR.MINOR.PATCH** (e.g., `v1.0.0`)
85+
- **MAJOR**: Breaking changes
86+
- **MINOR**: New features (backwards compatible)
87+
- **PATCH**: Bug fixes
88+
89+
Examples:
90+
- `v1.0.0` - Initial release
91+
- `v1.1.0` - New feature added
92+
- `v1.1.1` - Bug fix
93+
- `v2.0.0` - Breaking change
94+
95+
---
96+
97+
## Pre-release Versions
98+
99+
To create a pre-release:
100+
101+
```bash
102+
git tag v1.0.0-beta.1
103+
git push origin v1.0.0-beta.1
104+
```
105+
106+
Then manually mark it as "pre-release" in the GitHub UI.
107+
108+
---
109+
110+
## Troubleshooting
111+
112+
### Workflow Failed
113+
114+
1. Check the Actions tab for error logs
115+
2. Common issues:
116+
- Missing dependencies
117+
- Test failures
118+
- WiX compilation errors
119+
120+
### Release Not Created
121+
122+
1. Ensure the tag starts with `v` (e.g., `v1.0.0` not `1.0.0`)
123+
2. Check the tag was pushed to GitHub: `git push origin <tag>`
124+
3. Verify workflow permissions in repository settings
125+
126+
### Installer Not Uploaded
127+
128+
1. Check that the MSI file path is correct
129+
2. Verify the version in the filename matches the tag
130+
3. Check workflow logs for upload errors
131+
132+
---
133+
134+
## Manual Build
135+
136+
To build locally without creating a release:
137+
138+
```powershell
139+
# From the repository root
140+
cd installer
141+
.\build.ps1 -Version "1.0.0"
142+
```
143+
144+
The installer will be at:
145+
```
146+
installer\bin\x64\Release\GhostDrawSetup-1.0.0.msi
147+
```

.github/workflows/ci.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: CI Build
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: windows-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup .NET 8
18+
uses: actions/setup-dotnet@v4
19+
with:
20+
dotnet-version: '8.0.x'
21+
22+
- name: Install WiX Toolset
23+
shell: pwsh
24+
run: |
25+
dotnet tool install --global wix --version 4.0.5
26+
wix --version
27+
28+
- name: Restore dependencies
29+
run: dotnet restore src/GhostDraw.csproj
30+
31+
- name: Build application
32+
run: dotnet build src/GhostDraw.csproj -c Release --no-restore
33+
34+
- name: Run tests
35+
run: dotnet test src/GhostDraw.sln -c Release --no-build --verbosity normal
36+
37+
- name: Publish application
38+
shell: pwsh
39+
run: |
40+
dotnet publish src/GhostDraw.csproj `
41+
-c Release `
42+
-r win-x64 `
43+
--self-contained true `
44+
-p:PublishSingleFile=false `
45+
-p:Version=0.0.0-ci
46+
47+
- name: Generate WiX component list
48+
shell: pwsh
49+
working-directory: installer
50+
run: |
51+
.\Generate-FileList.ps1 `
52+
-PublishPath "..\src\bin\Release\net8.0-windows\win-x64\publish" `
53+
-OutputFile "HarvestedFiles.wxs"
54+
55+
- name: Build installer MSI
56+
shell: pwsh
57+
working-directory: installer
58+
run: |
59+
dotnet build GhostDraw.Installer.wixproj `
60+
-c Release `
61+
-p:Version=0.0.0-ci `
62+
-p:PublishDir="..\src\bin\Release\net8.0-windows\win-x64\publish\"
63+
64+
- name: Verify build outputs
65+
shell: pwsh
66+
run: |
67+
$exePath = "src\bin\Release\net8.0-windows\win-x64\publish\GhostDraw.exe"
68+
$msiPath = "installer\bin\x64\Release\GhostDrawSetup-0.0.0-ci.msi"
69+
70+
if (Test-Path $exePath) {
71+
Write-Host "✓ Application EXE built successfully" -ForegroundColor Green
72+
} else {
73+
Write-Error "Application EXE not found"
74+
exit 1
75+
}
76+
77+
if (Test-Path $msiPath) {
78+
$size = (Get-Item $msiPath).Length / 1MB
79+
Write-Host "✓ Installer MSI built successfully" -ForegroundColor Green
80+
Write-Host " Size: $([math]::Round($size, 2)) MB" -ForegroundColor Gray
81+
} else {
82+
Write-Error "Installer MSI not found"
83+
exit 1
84+
}
85+
86+
- name: Upload installer artifact
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: GhostDrawSetup-CI-${{ github.sha }}
90+
path: installer/bin/x64/Release/GhostDrawSetup-0.0.0-ci.msi
91+
retention-days: 7

.github/workflows/release.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*' # Triggers on version tags like v1.0.0, v1.2.3, etc.
7+
8+
permissions:
9+
contents: write # Required for creating releases
10+
11+
jobs:
12+
build-and-release:
13+
runs-on: windows-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # Full history for proper versioning
20+
21+
- name: Extract version from tag
22+
id: get_version
23+
shell: pwsh
24+
run: |
25+
$tag = "${{ github.ref_name }}"
26+
$version = $tag -replace '^v', ''
27+
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
28+
echo "Version: $version"
29+
30+
- name: Setup .NET 8
31+
uses: actions/setup-dotnet@v4
32+
with:
33+
dotnet-version: '8.0.x'
34+
35+
- name: Install WiX Toolset
36+
shell: pwsh
37+
run: |
38+
dotnet tool install --global wix --version 4.0.5
39+
dotnet --version
40+
wix --version
41+
42+
- name: Restore dependencies
43+
run: dotnet restore src/GhostDraw.csproj
44+
45+
- name: Build and publish application
46+
shell: pwsh
47+
run: |
48+
dotnet publish src/GhostDraw.csproj `
49+
-c Release `
50+
-r win-x64 `
51+
--self-contained true `
52+
-p:PublishSingleFile=false `
53+
-p:Version=${{ steps.get_version.outputs.VERSION }}
54+
55+
- name: Generate WiX component list
56+
shell: pwsh
57+
working-directory: installer
58+
run: |
59+
.\Generate-FileList.ps1 `
60+
-PublishPath "..\src\bin\Release\net8.0-windows\win-x64\publish" `
61+
-OutputFile "HarvestedFiles.wxs"
62+
63+
- name: Build installer MSI
64+
shell: pwsh
65+
working-directory: installer
66+
run: |
67+
dotnet build GhostDraw.Installer.wixproj `
68+
-c Release `
69+
-p:Version=${{ steps.get_version.outputs.VERSION }} `
70+
-p:PublishDir="..\src\bin\Release\net8.0-windows\win-x64\publish\"
71+
72+
- name: Verify installer created
73+
shell: pwsh
74+
run: |
75+
$msiPath = "installer\bin\x64\Release\GhostDrawSetup-${{ steps.get_version.outputs.VERSION }}.msi"
76+
if (Test-Path $msiPath) {
77+
$size = (Get-Item $msiPath).Length / 1MB
78+
Write-Host "✓ Installer created: $msiPath"
79+
Write-Host " Size: $([math]::Round($size, 2)) MB"
80+
} else {
81+
Write-Error "Installer not found at: $msiPath"
82+
exit 1
83+
}
84+
85+
- name: Create GitHub Release
86+
id: create_release
87+
uses: actions/create-release@v1
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
with:
91+
tag_name: ${{ github.ref_name }}
92+
release_name: GhostDraw ${{ steps.get_version.outputs.VERSION }}
93+
body: |
94+
## GhostDraw v${{ steps.get_version.outputs.VERSION }}
95+
96+
### Installation
97+
98+
Download `GhostDrawSetup-${{ steps.get_version.outputs.VERSION }}.msi` and run it.
99+
100+
**Requirements:** Windows 10/11 (64-bit) - No additional dependencies needed
101+
102+
### Features
103+
104+
- Press and hold **Ctrl+Alt+D**, then click and drag to draw on screen
105+
- Release **Ctrl+Alt+D** to clear the drawing
106+
- Press **ESC** to force clear if needed
107+
- Runs in system tray
108+
- Configurable hotkeys, colors, and brush thickness
109+
110+
### What's Changed
111+
112+
See commit history for detailed changes.
113+
114+
---
115+
116+
🤖 Generated with [GitHub Actions](https://github.com/${{ github.repository }}/actions)
117+
draft: false
118+
prerelease: false
119+
120+
- name: Upload MSI to Release
121+
uses: actions/upload-release-asset@v1
122+
env:
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124+
with:
125+
upload_url: ${{ steps.create_release.outputs.upload_url }}
126+
asset_path: ./installer/bin/x64/Release/GhostDrawSetup-${{ steps.get_version.outputs.VERSION }}.msi
127+
asset_name: GhostDrawSetup-${{ steps.get_version.outputs.VERSION }}.msi
128+
asset_content_type: application/x-msi
129+
130+
- name: Build summary
131+
shell: pwsh
132+
run: |
133+
Write-Host "=====================================" -ForegroundColor Cyan
134+
Write-Host " Release Build Complete! " -ForegroundColor Green
135+
Write-Host "=====================================" -ForegroundColor Cyan
136+
Write-Host ""
137+
Write-Host "Version: ${{ steps.get_version.outputs.VERSION }}" -ForegroundColor White
138+
Write-Host "Installer: GhostDrawSetup-${{ steps.get_version.outputs.VERSION }}.msi" -ForegroundColor White
139+
Write-Host "Release: ${{ steps.create_release.outputs.html_url }}" -ForegroundColor White

0 commit comments

Comments
 (0)