-
Notifications
You must be signed in to change notification settings - Fork 0
220 lines (176 loc) · 7.93 KB
/
build-and-release.yml
File metadata and controls
220 lines (176 loc) · 7.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
name: Build and Release
on:
push:
tags:
- 'v*.*.*' # Triggers on version tags like v1.0.0, v1.2.3, etc.
workflow_dispatch: # Allows manual triggering
env:
DOTNET_VERSION: '9.0.x'
PROJECT_PATH: 'Desktop/Desktop.csproj'
SOLUTION_PATH: 'OneBitSoftware.InputLanguageScreamer.sln'
jobs:
build-and-release:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper versioning
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Extract version from tag
id: get_version
shell: pwsh
run: |
if ($env:GITHUB_REF -match 'refs/tags/v(.*)') {
$version = $matches[1]
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
echo "TAG_NAME=v$version" >> $env:GITHUB_OUTPUT
echo "Version: $version"
} else {
$version = "1.0.0"
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
echo "TAG_NAME=v$version" >> $env:GITHUB_OUTPUT
echo "No tag found, using default version: $version"
}
- name: Update project version
shell: pwsh
run: |
$version = "${{ steps.get_version.outputs.VERSION }}"
$projectFile = "${{ env.PROJECT_PATH }}"
# Read the project file
$content = Get-Content $projectFile -Raw
# Update version numbers
$content = $content -replace '<AssemblyVersion>.*</AssemblyVersion>', "<AssemblyVersion>$version.0</AssemblyVersion>"
$content = $content -replace '<FileVersion>.*</FileVersion>', "<FileVersion>$version.0</FileVersion>"
# Write back to file
Set-Content $projectFile -Value $content -NoNewline
echo "Updated project version to $version"
- name: Restore dependencies
run: dotnet restore ${{ env.SOLUTION_PATH }}
- name: Build solution
run: dotnet build ${{ env.SOLUTION_PATH }} --configuration Release --no-restore
- name: Run tests (if any)
run: dotnet test ${{ env.SOLUTION_PATH }} --configuration Release --no-build --verbosity normal
continue-on-error: true # Continue even if no tests exist
- name: Publish Windows x64
run: |
dotnet publish ${{ env.PROJECT_PATH }} `
--configuration Release `
--runtime win-x64 `
--self-contained true `
--output ./publish/win-x64 `
--verbosity normal
- name: Publish Windows x86
run: |
dotnet publish ${{ env.PROJECT_PATH }} `
--configuration Release `
--runtime win-x86 `
--self-contained true `
--output ./publish/win-x86 `
--verbosity normal
- name: Publish Windows ARM64
run: |
dotnet publish ${{ env.PROJECT_PATH }} `
--configuration Release `
--runtime win-arm64 `
--self-contained true `
--output ./publish/win-arm64 `
--verbosity normal
- name: Create release packages
shell: pwsh
run: |
$version = "${{ steps.get_version.outputs.VERSION }}"
# Create release directory
New-Item -ItemType Directory -Force -Path "./release"
# Package Windows x64
Compress-Archive -Path "./publish/win-x64/*" -DestinationPath "./release/InputLanguageScreamer-v$version-win-x64.zip"
# Package Windows x86
Compress-Archive -Path "./publish/win-x86/*" -DestinationPath "./release/InputLanguageScreamer-v$version-win-x86.zip"
# Package Windows ARM64
Compress-Archive -Path "./publish/win-arm64/*" -DestinationPath "./release/InputLanguageScreamer-v$version-win-arm64.zip"
# Create portable package (just the executable and audio files)
New-Item -ItemType Directory -Force -Path "./portable"
Copy-Item "./publish/win-x64/Desktop.exe" -Destination "./portable/"
Copy-Item "./publish/win-x64/Audio" -Destination "./portable/" -Recurse -Force
Compress-Archive -Path "./portable/*" -DestinationPath "./release/InputLanguageScreamer-v$version-portable.zip"
echo "Created release packages:"
Get-ChildItem "./release/" | ForEach-Object { echo " - $($_.Name)" }
- name: Generate release notes
id: release_notes
shell: pwsh
run: |
$version = "${{ steps.get_version.outputs.VERSION }}"
$releaseNotes = @"
# Input Language Screamer v$version
## 🎵 What's New
This release includes the latest features and improvements for Input Language Screamer.
## 📦 Downloads
Choose the appropriate package for your system:
- **Windows x64** (Recommended for most users): `InputLanguageScreamer-v$version-win-x64.zip`
- **Windows x86** (32-bit systems): `InputLanguageScreamer-v$version-win-x86.zip`
- **Windows ARM64** (ARM-based Windows devices): `InputLanguageScreamer-v$version-win-arm64.zip`
- **Portable** (Minimal package): `InputLanguageScreamer-v$version-portable.zip`
## 🚀 Installation
1. Download the appropriate ZIP file for your system
2. Extract to your desired location
3. Add your MP3 audio files to the `Audio` folder
4. Run `Desktop.exe`
## 🎵 Supported Audio Files
Place MP3 files in the `Audio` folder named after your languages:
- `English.mp3` for English
- `Bulgarian.mp3` for Bulgarian
- `Spanish.mp3` for Spanish
- etc.
## 🔧 System Requirements
- Windows 10/11
- .NET 9.0 Runtime (included in self-contained packages)
## 📞 Support
- [Issues](https://github.com/OneBitSoftware/OneBitSoftware.InputLanguageScreamer/issues)
- [Discussions](https://github.com/OneBitSoftware/OneBitSoftware.InputLanguageScreamer/discussions)
---
**Full Changelog**: https://github.com/OneBitSoftware/OneBitSoftware.InputLanguageScreamer/compare/v$version
"@
# Save to file for GitHub release
$releaseNotes | Out-File -FilePath "./release-notes.md" -Encoding UTF8
# Output for GitHub Actions (escape newlines)
$escapedNotes = $releaseNotes -replace "`r`n", "%0A" -replace "`n", "%0A"
echo "RELEASE_NOTES=$escapedNotes" >> $env:GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get_version.outputs.TAG_NAME }}
name: Input Language Screamer ${{ steps.get_version.outputs.TAG_NAME }}
body_path: ./release-notes.md
draft: false
prerelease: false
files: |
./release/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts-${{ steps.get_version.outputs.VERSION }}
path: |
./release/*.zip
./release-notes.md
retention-days: 30
- name: Build summary
shell: pwsh
run: |
$version = "${{ steps.get_version.outputs.VERSION }}"
echo "## 🎉 Build Summary" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "✅ **Version**: $version" >> $env:GITHUB_STEP_SUMMARY
echo "✅ **Build**: Successful" >> $env:GITHUB_STEP_SUMMARY
echo "✅ **Platforms**: Windows x64, x86, ARM64" >> $env:GITHUB_STEP_SUMMARY
echo "✅ **Release**: Created" >> $env:GITHUB_STEP_SUMMARY
echo "" >> $env:GITHUB_STEP_SUMMARY
echo "### 📦 Release Packages" >> $env:GITHUB_STEP_SUMMARY
Get-ChildItem "./release/*.zip" | ForEach-Object {
$size = [math]::Round($_.Length / 1MB, 2)
echo "- **$($_.Name)** ($size MB)" >> $env:GITHUB_STEP_SUMMARY
}