77 pull_request :
88 branches : [ main ]
99
10+ env :
11+ DOTNET_VERSION : ' 9.0.x'
12+ PROJECT_FILE : ' ClipSyncWindows.csproj'
13+ RUNTIME : ' win-x64'
14+
1015jobs :
1116 build :
1217 runs-on : windows-latest
1318
1419 steps :
15- - uses : actions/checkout@v4
20+ - name : Checkout code
21+ uses : actions/checkout@v4
1622
1723 - name : Setup .NET
1824 uses : actions/setup-dotnet@v4
1925 with :
20- dotnet-version : ' 9.0.x'
26+ dotnet-version : ${{ env.DOTNET_VERSION }}
27+
28+ - name : Cache NuGet packages
29+ uses : actions/cache@v4
30+ with :
31+ path : ~/.nuget/packages
32+ key : ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
33+ restore-keys : |
34+ ${{ runner.os }}-nuget-
2135
2236 - name : Restore dependencies
23- run : dotnet restore
37+ run : dotnet restore ${{ env.PROJECT_FILE }}
2438
2539 - name : Build
26- run : dotnet build ClipSyncWindows.csproj --configuration Release --no-restore
40+ run : dotnet build ${{ env.PROJECT_FILE }} --configuration Release --no-restore
2741
2842 - name : Test
29- run : dotnet test ClipSyncWindows.csproj --no-build --verbosity normal --configuration Release
43+ run : dotnet test ${{ env.PROJECT_FILE }} --no-build --verbosity normal --configuration Release
3044
31- - name : Publish
32- run : dotnet publish ClipSyncWindows.csproj --configuration Release --output ./publish --self-contained true --runtime win-x64
45+ - name : Publish application
46+ run : dotnet publish ${{ env.PROJECT_FILE }} --configuration Release --output ./publish --self-contained true --runtime ${{ env.RUNTIME }}
3347
3448 - name : Upload build artifacts
3549 uses : actions/upload-artifact@v4
3650 with :
3751 name : ClipSync-Windows-${{ github.sha }}
3852 path : ./publish/
39-
40- test-release :
53+ retention-days : 30
54+
55+ prepare-installer :
4156 needs : build
4257 runs-on : windows-latest
43- if : github.ref == 'refs/heads/test'
58+ if : github.ref == 'refs/heads/test' || startsWith(github.ref, 'refs/tags/v')
59+
60+ outputs :
61+ is-release : ${{ steps.check-release.outputs.is-release }}
62+ version : ${{ steps.get-version.outputs.version }}
4463
4564 steps :
46- - uses : actions/checkout@v4
65+ - name : Checkout code
66+ uses : actions/checkout@v4
4767
48- - name : Setup .NET
49- uses : actions/setup-dotnet @v4
68+ - name : Download build artifacts
69+ uses : actions/download-artifact @v4
5070 with :
51- dotnet-version : ' 9.0.x'
71+ name : ClipSync-Windows-${{ github.sha }}
72+ path : ./publish/
5273
53- - name : Restore dependencies
54- run : dotnet restore
74+ - name : Check if this is a release
75+ id : check-release
76+ run : |
77+ if ("${{ github.ref }}" -like "refs/tags/v*") {
78+ echo "is-release=true" >> $env:GITHUB_OUTPUT
79+ } else {
80+ echo "is-release=false" >> $env:GITHUB_OUTPUT
81+ }
5582
56- - name : Publish Self-Contained
57- run : dotnet publish ClipSyncWindows.csproj --configuration Release --output ./release --self-contained true --runtime win-x64
83+ - name : Get version
84+ id : get-version
85+ run : |
86+ if ("${{ github.ref }}" -like "refs/tags/v*") {
87+ $version = "${{ github.ref_name }}"
88+ echo "version=$version" >> $env:GITHUB_OUTPUT
89+ } else {
90+ echo "version=test-${{ github.sha }}" >> $env:GITHUB_OUTPUT
91+ }
5892
5993 - name : Setup Inno Setup
6094 run : |
61- Invoke-WebRequest -Uri "https://jrsoftware.org/download.php/is.exe" -OutFile "innosetup.exe"
62- Start-Process -FilePath "innosetup.exe" -ArgumentList "/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART" -Wait
95+ try {
96+ choco install innosetup -y --no-progress
97+ Write-Host "Inno Setup installed successfully"
98+ } catch {
99+ Write-Error "Failed to install Inno Setup: $_"
100+ exit 1
101+ }
63102
64- - name : Update Inno Setup Script for Test
103+ - name : Verify Inno Setup installation
65104 run : |
66- $content = Get-Content "InnoInstaller.iss" -Raw
67- $content = $content -replace 'Source: "publish\\\*"', 'Source: "release\*"'
68- $content = $content -replace 'SetupIconFile=publish\\app\.ico', 'SetupIconFile=release\app.ico'
69- Set-Content "InnoInstaller.iss" $content
105+ $innoPath = Get-Command "iscc.exe" -ErrorAction SilentlyContinue
106+ if (-not $innoPath) {
107+ Write-Error "Inno Setup not found in PATH"
108+ exit 1
109+ }
110+ Write-Host "Inno Setup found at: $($innoPath.Source)"
70111
71- - name : Build Installer
112+ - name : Verify installer script exists
72113 run : |
73- & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "InnoInstaller.iss"
114+ if (-not (Test-Path "InnoInstaller.iss")) {
115+ Write-Error "InnoInstaller.iss not found in repository"
116+ exit 1
117+ }
118+ Write-Host "Installer script found"
119+
120+ - name : Update Inno Setup script
121+ run : |
122+ try {
123+ $content = Get-Content "InnoInstaller.iss" -Raw -ErrorAction Stop
124+
125+ # Update source path
126+ $content = $content -replace 'Source: "publish\\\*"', 'Source: "publish\*"'
127+ $content = $content -replace 'Source: "publish\\([^"]+)"', 'Source: "publish\$1"'
128+
129+ # Update icon path if it exists
130+ if ($content -match 'SetupIconFile=') {
131+ $content = $content -replace 'SetupIconFile=publish\\([^"]*)', 'SetupIconFile=publish\$1'
132+ }
133+
134+ # Update version and filename for releases
135+ if ("${{ steps.check-release.outputs.is-release }}" -eq "true") {
136+ $version = "${{ steps.get-version.outputs.version }}"
137+ $content = $content -replace '#define MyAppVersion "[^"]*"', "#define MyAppVersion `"$version`""
138+ $content = $content -replace 'OutputBaseFilename=ClipSync_Setup', "OutputBaseFilename=ClipSync-Windows-$version-Setup"
139+ } else {
140+ # For test builds
141+ $content = $content -replace 'OutputBaseFilename=ClipSync_Setup', 'OutputBaseFilename=ClipSync-Test-Setup'
142+ }
143+
144+ Set-Content "InnoInstaller.iss" $content -ErrorAction Stop
145+ Write-Host "Installer script updated successfully"
146+
147+ # Show the changes for debugging
148+ Write-Host "Updated installer script content (first 10 lines):"
149+ Get-Content "InnoInstaller.iss" | Select-Object -First 10 | ForEach-Object { Write-Host " $_" }
150+
151+ } catch {
152+ Write-Error "Failed to update installer script: $_"
153+ exit 1
154+ }
155+
156+ - name : Build installer
157+ run : |
158+ try {
159+ iscc "InnoInstaller.iss"
160+ Write-Host "Installer built successfully"
161+
162+ # List generated files
163+ Write-Host "Generated files:"
164+ Get-ChildItem -Filter "*.exe" | ForEach-Object { Write-Host " $($_.Name)" }
165+
166+ } catch {
167+ Write-Error "Failed to build installer: $_"
168+ exit 1
169+ }
170+
171+ - name : Upload installer artifact
172+ uses : actions/upload-artifact@v4
173+ with :
174+ name : ClipSync-Installer-${{ steps.get-version.outputs.version }}
175+ path : " *.exe"
176+ retention-days : 30
177+
178+ test-release :
179+ needs : prepare-installer
180+ runs-on : windows-latest
181+ if : github.ref == 'refs/heads/test'
182+
183+ steps :
184+ - name : Download installer
185+ uses : actions/download-artifact@v4
186+ with :
187+ name : ClipSync-Installer-${{ needs.prepare-installer.outputs.version }}
188+ path : ./
189+
190+ - name : Download build artifacts
191+ uses : actions/download-artifact@v4
192+ with :
193+ name : ClipSync-Windows-${{ github.sha }}
194+ path : ./publish/
74195
75- - name : Upload Test Release Assets
196+ - name : Upload test release artifacts
76197 uses : actions/upload-artifact@v4
77198 with :
78199 name : ClipSync-Test-Release-${{ github.sha }}
79200 path : |
80- ClipSync_Setup.exe
81- ./release/
201+ *.exe
202+ ./publish/
203+ retention-days : 7
82204
83205 release :
84- needs : build
206+ needs : prepare-installer
85207 runs-on : windows-latest
86208 if : startsWith(github.ref, 'refs/tags/v')
87209
88210 steps :
89- - uses : actions/checkout@v4
90-
91- - name : Setup .NET
92- uses : actions/setup-dotnet@v4
211+ - name : Download installer
212+ uses : actions/download-artifact@v4
93213 with :
94- dotnet-version : ' 9.0.x'
95-
96- - name : Restore dependencies
97- run : dotnet restore
214+ name : ClipSync-Installer-${{ needs.prepare-installer.outputs.version }}
215+ path : ./
98216
99- - name : Publish Self-Contained Release
100- run : dotnet publish ClipSyncWindows.csproj --configuration Release --output ./release --self-contained true --runtime win-x64
101-
102- - name : Setup Inno Setup
103- run : |
104- Invoke-WebRequest -Uri "https://jrsoftware.org/download.php/is.exe" -OutFile "innosetup.exe"
105- Start-Process -FilePath "innosetup.exe" -ArgumentList "/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART" -Wait
217+ - name : Download build artifacts
218+ uses : actions/download-artifact@v4
219+ with :
220+ name : ClipSync-Windows-${{ github.sha }}
221+ path : ./publish/
106222
107- - name : Update Inno Setup Script for Release
223+ - name : Create release archive
108224 run : |
109- $content = Get-Content "InnoInstaller.iss" -Raw
110- $content = $content -replace 'Source: "publish\\\*"', 'Source: "release\*"'
111- $content = $content -replace 'SetupIconFile=publish\\app\.ico', 'SetupIconFile=release\app.ico'
112- $content = $content -replace '#define MyAppVersion "1.0.0"', '#define MyAppVersion "${{ github.ref_name }}"'
113- $content = $content -replace 'OutputBaseFilename=ClipSync_Setup', 'OutputBaseFilename=ClipSync-Windows-${{ github.ref_name }}-Setup'
114- Set-Content "InnoInstaller.iss" $content
115-
116- - name : Build Installer
117- run : |
118- & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "InnoInstaller.iss"
225+ try {
226+ Compress-Archive -Path ./publish/* -DestinationPath "ClipSync-Windows-${{ needs.prepare-installer.outputs.version }}.zip" -ErrorAction Stop
227+ Write-Host "Release archive created successfully"
228+ } catch {
229+ Write-Error "Failed to create release archive: $_"
230+ exit 1
231+ }
119232
120- - name : Create Release Archive
233+ - name : Verify release files
121234 run : |
122- Compress-Archive -Path ./release/* -DestinationPath ClipSync-Windows-${{ github.ref_name }}.zip
235+ Write-Host "Release files:"
236+ Get-ChildItem -Filter "ClipSync-Windows-*" | ForEach-Object {
237+ Write-Host " $($_.Name) ($([math]::Round($_.Length / 1MB, 2)) MB)"
238+ }
123239
124- - name : Create Release
125- id : create_release
126- uses : actions/create-release@v1
127- env :
128- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
240+ - name : Create GitHub Release
241+ uses : softprops/action-gh-release@v2
129242 with :
130- tag_name : ${{ github.ref_name }}
131- release_name : ClipSync Windows ${{ github.ref_name }}
243+ name : ClipSync Windows ${{ needs.prepare-installer.outputs.version }}
132244 body : |
133- ## What's Changed
245+ ## ClipSync Windows ${{ needs.prepare-installer.outputs.version }}
134246
135- See [CHANGELOG.md](CHANGELOG.md) for detailed changes.
247+ ### Installation Options
136248
137- ## Installation
249+ **Option 1: Installer (Recommended)**
250+ 1. Download `ClipSync-Windows-${{ needs.prepare-installer.outputs.version }}-Setup.exe`
251+ 2. Run the installer and follow the setup wizard
138252
139- 1. Download `ClipSync-Windows-${{ github.ref_name }}.zip`
253+ **Option 2: Portable**
254+ 1. Download `ClipSync-Windows-${{ needs.prepare-installer.outputs.version }}.zip`
140255 2. Extract to your desired location
141256 3. Run `ClipSyncWindows.exe`
142257
143- ## Requirements
258+ ### System Requirements
144259
145260 - Windows 10 version 1903+ or Windows 11
146261 - .NET 9.0 Runtime (included in self-contained build)
147- - Bluetooth adapter
262+ - Bluetooth adapter (for device synchronization)
263+
264+ ### What's New
265+
266+ Please see the [CHANGELOG](CHANGELOG.md) for detailed information about changes in this release.
267+ files : |
268+ ClipSync-Windows-${{ needs.prepare-installer.outputs.version }}.zip
269+ ClipSync-Windows-${{ needs.prepare-installer.outputs.version }}-Setup.exe
148270 draft : false
149271 prerelease : false
150-
151- - name : Upload Release Asset - Zip
152- uses : actions/upload-release-asset@v1
272+ generate_release_notes : true
153273 env :
154- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
155- with :
156- upload_url : ${{ steps.create_release.outputs.upload_url }}
157- asset_path : ./ClipSync-Windows-${{ github.ref_name }}.zip
158- asset_name : ClipSync-Windows-${{ github.ref_name }}.zip
159- asset_content_type : application/zip
160-
161- - name : Upload Release Asset - Installer
162- uses : actions/upload-release-asset@v1
163- env :
164- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
165- with :
166- upload_url : ${{ steps.create_release.outputs.upload_url }}
167- asset_path : ./ClipSync-Windows-${{ github.ref_name }}-Setup.exe
168- asset_name : ClipSync-Windows-${{ github.ref_name }}-Setup.exe
169- asset_content_type : application/octet-stream
274+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments