-
Notifications
You must be signed in to change notification settings - Fork 1
175 lines (150 loc) · 5.92 KB
/
Copy pathrelease.yml
File metadata and controls
175 lines (150 loc) · 5.92 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
name: Build and Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version number (e.g., 1.0.3)'
required: true
type: string
env:
DOTNET_VERSION: '8.0.x'
PROJECT_PATH: 'src/MouseEffects.App/MouseEffects.App.csproj'
TARGET_FRAMEWORK: 'net8.0-windows10.0.19041.0'
# Required for creating releases
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Determine version
id: version
shell: pwsh
run: |
if ("${{ github.event.inputs.version }}" -ne "") {
$version = "${{ github.event.inputs.version }}"
} else {
$version = "${{ github.ref_name }}".TrimStart('v')
}
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
echo "Version: $version"
- name: Restore dependencies
run: dotnet restore
# ============================================================
# BUILD AND PUBLISH FOR x64
# ============================================================
- name: Build solution (x64)
run: dotnet build --configuration Release --no-restore -p:Platform=x64
- name: Publish application (x64)
run: |
dotnet publish ${{ env.PROJECT_PATH }} `
--configuration Release `
--runtime win-x64 `
--self-contained true `
--output ./publish/win-x64 `
-p:PublishSingleFile=false `
-p:Version=${{ steps.version.outputs.VERSION }}
- name: Copy plugins (x64)
shell: pwsh
run: |
$pluginsSource = "./src/MouseEffects.App/bin/x64/Release/${{ env.TARGET_FRAMEWORK }}/plugins"
$pluginsDest = "./publish/win-x64/plugins"
if (Test-Path $pluginsSource) {
New-Item -ItemType Directory -Force -Path $pluginsDest | Out-Null
Copy-Item -Path "$pluginsSource\*" -Destination $pluginsDest -Recurse -Force
Write-Host "x64 plugins copied"
} else {
Write-Host "Warning: x64 plugins not found at $pluginsSource"
}
# ============================================================
# CREATE VELOPACK PACKAGE
# ============================================================
- name: Install Velopack CLI
run: dotnet tool install -g vpk
- name: Create Velopack release (x64)
shell: pwsh
run: |
vpk pack `
--packId MouseEffects `
--packVersion ${{ steps.version.outputs.VERSION }} `
--packDir ./publish/win-x64 `
--mainExe MouseEffects.App.exe `
--outputDir ./releases/x64 `
--packTitle "MouseEffects" `
--icon ./src/MouseEffects.App/MouseEffects.ico
# ============================================================
# RENAME ARTIFACTS FOR CLARITY
# ============================================================
- name: Rename artifacts
shell: pwsh
run: |
$version = "${{ steps.version.outputs.VERSION }}"
# Rename setup file to include architecture
Move-Item -Path "./releases/x64/MouseEffects-win-Setup.exe" -Destination "./releases/MouseEffects-x64-Setup.exe" -Force
# Rename nupkg files to include architecture
Get-ChildItem -Path "./releases/x64/*.nupkg" | ForEach-Object {
$newName = $_.Name -replace "-full\.nupkg$", "-x64-full.nupkg"
Move-Item -Path $_.FullName -Destination "./releases/$newName" -Force
}
# Update RELEASES file content to match renamed nupkg files, then rename the file
$releasesContent = Get-Content -Path "./releases/x64/RELEASES" -Raw
$updatedContent = $releasesContent -replace "-full\.nupkg", "-x64-full.nupkg"
Set-Content -Path "./releases/RELEASES-x64" -Value $updatedContent -NoNewline
Remove-Item -Path "./releases/x64/RELEASES" -Force
- name: List release artifacts
shell: pwsh
run: |
echo "Release artifacts:"
Get-ChildItem -Path ./releases -Recurse | Format-Table Name, Length
# ============================================================
# UPLOAD AND RELEASE
# ============================================================
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: MouseEffects-${{ steps.version.outputs.VERSION }}
path: |
./releases/MouseEffects-x64-Setup.exe
./releases/*.nupkg
./releases/RELEASES-*
retention-days: 30
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
name: MouseEffects v${{ steps.version.outputs.VERSION }}
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
generate_release_notes: true
files: |
./releases/MouseEffects-x64-Setup.exe
./releases/*-x64-full.nupkg
./releases/RELEASES-x64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release (manual trigger)
if: github.event_name == 'workflow_dispatch'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.VERSION }}
name: MouseEffects v${{ steps.version.outputs.VERSION }}
draft: true
prerelease: false
generate_release_notes: true
files: |
./releases/MouseEffects-x64-Setup.exe
./releases/*-x64-full.nupkg
./releases/RELEASES-x64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}