forked from community-outpost/GenHub
-
Notifications
You must be signed in to change notification settings - Fork 0
412 lines (337 loc) · 15.3 KB
/
Copy pathrelease.yml
File metadata and controls
412 lines (337 loc) · 15.3 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
name: GenHub Release
permissions:
contents: write
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
DOTNET_VERSION: '8.0.x'
BUILD_CONFIGURATION: 'Release'
CORE_PROJECT: 'GenHub/GenHub.Core/GenHub.Core.csproj'
UI_PROJECT: 'GenHub/GenHub/GenHub.csproj'
WINDOWS_PROJECT: 'GenHub/GenHub.Windows/GenHub.Windows.csproj'
LINUX_PROJECT: 'GenHub/GenHub.Linux/GenHub.Linux.csproj'
jobs:
build-windows:
name: Build Windows
runs-on: windows-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet Packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Extract Build Info
id: buildinfo
shell: pwsh
run: |
$shortHash = "${{ github.sha }}".Substring(0, 7)
$runNumber = "${{ github.run_number }}"
$version = "0.0.$runNumber"
$channel = "Release"
Write-Host "Release Build Info:"
Write-Host " Short Hash: $shortHash"
Write-Host " Run Number: $runNumber"
Write-Host " Version: $version"
Write-Host " Channel: $channel"
echo "SHORT_HASH=$shortHash" >> $env:GITHUB_OUTPUT
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
echo "CHANNEL=$channel" >> $env:GITHUB_OUTPUT
- name: Build Windows Projects
shell: pwsh
run: |
$buildProps = @(
"-p:Version=${{ steps.buildinfo.outputs.VERSION }}"
"-p:GitShortHash=${{ steps.buildinfo.outputs.SHORT_HASH }}"
"-p:BuildChannel=${{ steps.buildinfo.outputs.CHANNEL }}"
)
Write-Host "Building Core project"
dotnet build "${{ env.CORE_PROJECT }}" -c ${{ env.BUILD_CONFIGURATION }} @buildProps
dotnet build "${{ env.UI_PROJECT }}" -c ${{ env.BUILD_CONFIGURATION }} @buildProps
dotnet build "${{ env.WINDOWS_PROJECT }}" -c ${{ env.BUILD_CONFIGURATION }} @buildProps
- name: Publish Windows App
shell: pwsh
run: |
$buildProps = @(
"-p:Version=${{ steps.buildinfo.outputs.VERSION }}"
"-p:GitShortHash=${{ steps.buildinfo.outputs.SHORT_HASH }}"
"-p:BuildChannel=${{ steps.buildinfo.outputs.CHANNEL }}"
)
Write-Host "Publishing Windows application"
dotnet publish "${{ env.WINDOWS_PROJECT }}" `
-c ${{ env.BUILD_CONFIGURATION }} `
-r win-x64 `
--self-contained true `
-o "win-publish" `
@buildProps
- name: Install Velopack CLI
run: dotnet tool install -g vpk
- name: Create Velopack Windows Package
shell: pwsh
run: |
Write-Host "Creating Velopack Windows package..."
vpk pack `
--packId GenHub `
--packVersion ${{ steps.buildinfo.outputs.VERSION }} `
--packDir win-publish `
--mainExe GenHub.Windows.exe `
--packTitle "GenHub" `
--packAuthors "Community Outpost" `
--icon GenHub/GenHub/Assets/Icons/generalshub.ico `
--outputDir velopack-release-windows
Write-Host "Windows artifacts created:"
Get-ChildItem -Path "velopack-release-windows" -Recurse | Select-Object Name, Length
- name: Create Portable Windows Build
shell: pwsh
run: |
Write-Host "Creating portable Windows build..."
# Create portable directory structure
$portableDir = "GenHub-Portable"
New-Item -ItemType Directory -Force -Path $portableDir | Out-Null
# Copy published files to portable directory
Copy-Item -Path "win-publish\*" -Destination $portableDir -Recurse -Force
# Create README for portable version
$readmeContent = @"
GenHub Portable v${{ steps.buildinfo.outputs.VERSION }}
==========================================
This is a portable version of GenHub that does not require installation.
HOW TO USE:
1. Extract this entire folder to any location on your computer
2. Run GenHub.Windows.exe to start the application
3. Your settings and data will be stored in this folder
NOTES:
- This version will NOT auto-update. Download new versions manually.
- Keep this entire folder together - do not move individual files.
- You can move the entire folder to a USB drive or another computer.
For the auto-updating installer version, download GenHub-win-Setup.exe instead.
Build Information:
- Version: ${{ steps.buildinfo.outputs.VERSION }}
- Commit: ${{ steps.buildinfo.outputs.SHORT_HASH }}
- Build Date: $(Get-Date -Format "yyyy-MM-dd HH:mm:ss UTC")
"@
Set-Content -Path "$portableDir\README.txt" -Value $readmeContent
# Create zip file
$zipName = "GenHub-${{ steps.buildinfo.outputs.VERSION }}-win-portable.zip"
Compress-Archive -Path $portableDir -DestinationPath $zipName -Force
Write-Host "Portable build created: $zipName"
Write-Host "Size: $((Get-Item $zipName).Length / 1MB) MB"
- name: Upload Windows Release Artifacts
uses: actions/upload-artifact@v4
with:
name: windows-release-${{ steps.buildinfo.outputs.VERSION }}
path: velopack-release-windows/*
if-no-files-found: error
retention-days: 2
- name: Upload Windows Portable Artifact
uses: actions/upload-artifact@v4
with:
name: windows-portable-${{ steps.buildinfo.outputs.VERSION }}
path: GenHub-${{ steps.buildinfo.outputs.VERSION }}-win-portable.zip
if-no-files-found: error
retention-days: 2
build-linux:
name: Build Linux
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install Linux Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libx11-dev
- name: Cache NuGet Packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Extract Build Info
id: buildinfo
run: |
SHORT_HASH=$(echo "${{ github.sha }}" | cut -c1-7)
RUN_NUMBER="${{ github.run_number }}"
VERSION="0.0.${RUN_NUMBER}"
CHANNEL="Release"
echo "Release Build Info:"
echo " Short Hash: $SHORT_HASH"
echo " Run Number: $RUN_NUMBER"
echo " Version: $VERSION"
echo " Channel: $CHANNEL"
echo "SHORT_HASH=$SHORT_HASH" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "CHANNEL=$CHANNEL" >> $GITHUB_OUTPUT
- name: Build Linux Projects
run: |
BUILD_PROPS="-p:Version=${{ steps.buildinfo.outputs.VERSION }} -p:GitShortHash=${{ steps.buildinfo.outputs.SHORT_HASH }} -p:BuildChannel=${{ steps.buildinfo.outputs.CHANNEL }}"
echo "Building Linux projects"
dotnet build "${{ env.CORE_PROJECT }}" -c ${{ env.BUILD_CONFIGURATION }} $BUILD_PROPS
dotnet build "${{ env.UI_PROJECT }}" -c ${{ env.BUILD_CONFIGURATION }} $BUILD_PROPS
dotnet build "${{ env.LINUX_PROJECT }}" -c ${{ env.BUILD_CONFIGURATION }} $BUILD_PROPS
- name: Publish Linux App
run: |
BUILD_PROPS="-p:Version=${{ steps.buildinfo.outputs.VERSION }} -p:GitShortHash=${{ steps.buildinfo.outputs.SHORT_HASH }} -p:BuildChannel=${{ steps.buildinfo.outputs.CHANNEL }}"
echo "Publishing Linux application"
dotnet publish "${{ env.LINUX_PROJECT }}" \
-c ${{ env.BUILD_CONFIGURATION }} \
-r linux-x64 \
--self-contained true \
-o "linux-publish" \
$BUILD_PROPS
- name: Install Velopack CLI
run: dotnet tool install -g vpk
- name: Create Velopack Linux Package
run: |
echo "Creating Velopack Linux package..."
vpk pack \
--packId GenHub \
--packVersion ${{ steps.buildinfo.outputs.VERSION }} \
--packDir linux-publish \
--mainExe GenHub.Linux \
--packTitle "GenHub" \
--packAuthors "Community Outpost" \
--icon GenHub/GenHub/Assets/Icons/generalshub-icon.png \
--outputDir velopack-release-linux
echo "Linux artifacts created:"
ls -lh velopack-release-linux/
- name: Upload Linux Release Artifacts
uses: actions/upload-artifact@v4
with:
name: linux-release-${{ steps.buildinfo.outputs.VERSION }}
path: velopack-release-linux/*
if-no-files-found: error
retention-days: 7
create-release:
name: Create GitHub Release
needs: [build-windows, build-linux]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for changelog generation
- name: Extract Version
id: version
# We can reconstruct version from run_number since it's deterministic and identical across jobs
run: |
SHORT_HASH=$(echo "${{ github.sha }}" | cut -c1-7)
VERSION="0.0.${{ github.run_number }}"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "SHORT_HASH=$SHORT_HASH" >> $GITHUB_OUTPUT
- name: Generate Changelog
id: changelog
run: |
echo "Generating changelog from development branch commits..."
# Fetch development branch
git fetch origin development:development || echo "Development branch not found, skipping changelog"
# Count commits between main and development
COMMIT_COUNT=$(git rev-list --count HEAD..development 2>/dev/null || echo "0")
echo "COMMIT_COUNT=$COMMIT_COUNT" >> $GITHUB_OUTPUT
# Generate changelog from commit messages
if [ "$COMMIT_COUNT" -gt "0" ]; then
echo "Found $COMMIT_COUNT commits in development branch"
# Extract commit messages and format them
CHANGELOG=$(git log --pretty=format:"- %s" HEAD..development 2>/dev/null || echo "")
# Save changelog to file (multiline output)
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "No commits found between main and development"
echo "CHANGELOG=No changes recorded" >> $GITHUB_OUTPUT
fi
- name: Download Windows Artifacts
uses: actions/download-artifact@v4
with:
name: windows-release-${{ steps.version.outputs.VERSION }}
path: release-assets/windows
- name: Download Windows Portable Artifact
uses: actions/download-artifact@v4
with:
name: windows-portable-${{ steps.version.outputs.VERSION }}
path: release-assets/portable
- name: Download Linux Artifacts
uses: actions/download-artifact@v4
with:
name: linux-release-${{ steps.version.outputs.VERSION }}
path: release-assets/linux
- name: Prepare Release Assets
run: |
mkdir final-assets
# Copy Windows assets
cp release-assets/windows/*.nupkg final-assets/
cp release-assets/windows/RELEASES final-assets/
cp release-assets/windows/*-Setup.exe final-assets/
cp release-assets/windows/*.json final-assets/ || true
# Copy Windows Portable
cp release-assets/portable/*.zip final-assets/
# Copy Linux assets
cp release-assets/linux/*.nupkg final-assets/
cp release-assets/linux/*.json final-assets/ || true
echo "Final release assets:"
ls -lh final-assets/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.VERSION }}
name: GenHub Alpha v${{ steps.version.outputs.VERSION }}
prerelease: true
draft: false
body: |
## GenHub Alpha Release v${{ steps.version.outputs.VERSION }}
### 📦 Installation
**First-time users (Windows):**
- **Installer (Recommended):** Download `GenHub-win-Setup.exe` and run it
- **Portable:** Download `GenHub-${{ steps.version.outputs.VERSION }}-win-portable.zip`, extract, and run `GenHub.Windows.exe`
**Existing users:**
- The app will auto-update using Velopack (installer version only)
- Portable users: Download the new portable zip manually
### 🆕 What's New
**${{ steps.changelog.outputs.COMMIT_COUNT }} commits** merged from development branch:
${{ steps.changelog.outputs.CHANGELOG }}
### 📝 Build Information
- **Version:** ${{ steps.version.outputs.VERSION }}
- **Commit:** ${{ steps.version.outputs.SHORT_HASH }}
- **Channel:** Release
### 🔧 Assets Included
- `GenHub-win-Setup.exe` - Windows installer (auto-updates)
- `GenHub-${{ steps.version.outputs.VERSION }}-win-portable.zip` - Windows portable (no installation required)
- `GenHub-{version}-win-full.nupkg` - Windows update package
- `GenHub-{version}-linux-full.nupkg` - Linux update package
- `RELEASES` - Windows update metadata
files: final-assets/*
- name: Build Summary
run: |
echo "### 🚀 GenHub Release v${{ steps.version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Status:** ✅ Release created successfully" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ steps.version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** ${{ steps.version.outputs.SHORT_HASH }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📦 Assets Published" >> $GITHUB_STEP_SUMMARY
echo "- Windows Setup Installer" >> $GITHUB_STEP_SUMMARY
echo "- Windows Portable Build" >> $GITHUB_STEP_SUMMARY
echo "- Windows Update Package" >> $GITHUB_STEP_SUMMARY
echo "- Linux Update Package" >> $GITHUB_STEP_SUMMARY
echo "- Update Metadata Files" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📋 Changelog" >> $GITHUB_STEP_SUMMARY
echo "**${{ steps.changelog.outputs.COMMIT_COUNT }} commits** from development branch" >> $GITHUB_STEP_SUMMARY