Use System.IO.File methods with UTF-8 BOM to preserve special characters 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
123 lines
4.7 KiB
YAML
123 lines
4.7 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: windows
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: '9.0.x'
|
|
|
|
- name: Update version in project files
|
|
shell: powershell
|
|
run: |
|
|
$version = "${{ gitea.ref_name }}".TrimStart("v")
|
|
Write-Host "Setting version to: $version"
|
|
|
|
# Update csproj (preserve UTF-8 BOM encoding)
|
|
$csprojPath = "DellMonitorControl/DellMonitorControl.csproj"
|
|
$content = [System.IO.File]::ReadAllText($csprojPath)
|
|
$content = $content -replace '<Version>.*</Version>', "<Version>$version</Version>"
|
|
$content = $content -replace '<AssemblyVersion>.*</AssemblyVersion>', "<AssemblyVersion>$version.0</AssemblyVersion>"
|
|
$content = $content -replace '<FileVersion>.*</FileVersion>', "<FileVersion>$version.0</FileVersion>"
|
|
[System.IO.File]::WriteAllText($csprojPath, $content, [System.Text.UTF8Encoding]::new($true))
|
|
|
|
# Update ISS
|
|
$issPath = "DellMonitorControl/MonitorControl.iss"
|
|
$issContent = [System.IO.File]::ReadAllText($issPath)
|
|
$issContent = $issContent -replace '#define MyAppVersion ".*"', "#define MyAppVersion `"$version`""
|
|
[System.IO.File]::WriteAllText($issPath, $issContent, [System.Text.UTF8Encoding]::new($true))
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Build Release
|
|
run: dotnet build --configuration Release --no-restore
|
|
|
|
- name: List build output
|
|
shell: cmd
|
|
run: |
|
|
echo "Current directory:"
|
|
cd
|
|
echo "DellMonitorControl contents:"
|
|
dir DellMonitorControl
|
|
echo "DellMonitorControl\bin contents:"
|
|
dir DellMonitorControl\bin
|
|
echo "DellMonitorControl\bin\Release contents:"
|
|
dir DellMonitorControl\bin\Release
|
|
echo "DellMonitorControl\bin\Release\net9.0-windows contents:"
|
|
dir DellMonitorControl\bin\Release\net9.0-windows
|
|
|
|
- name: Build Installer
|
|
shell: cmd
|
|
run: |
|
|
echo Copying to short path to avoid path length issues...
|
|
mkdir C:\build 2>nul
|
|
xcopy /E /I /Y DellMonitorControl C:\build\app
|
|
echo.
|
|
echo Working from C:\build\app
|
|
cd /d C:\build\app
|
|
echo Current directory:
|
|
cd
|
|
echo.
|
|
set TEMP=C:\build\temp
|
|
set TMP=C:\build\temp
|
|
mkdir C:\build\temp 2>nul
|
|
mkdir installer 2>nul
|
|
echo.
|
|
echo Running Inno Setup...
|
|
"C:\Program Files (x86)\Inno Setup 6\ISCC.exe" MonitorControl.iss
|
|
echo.
|
|
echo ISCC exit code: %ERRORLEVEL%
|
|
echo.
|
|
echo Installer directory contents:
|
|
dir installer
|
|
|
|
- name: Create Release
|
|
shell: powershell
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
run: |
|
|
$tag = "${{ gitea.ref_name }}"
|
|
$version = $tag.TrimStart("v")
|
|
$repo = "misc/ControlMyMonitorManagement"
|
|
$baseUrl = "https://git.marketally.com/api/v1"
|
|
|
|
Write-Host "Creating release for tag: $tag"
|
|
|
|
# Check if release already exists
|
|
try {
|
|
$existing = Invoke-RestMethod -Uri "$baseUrl/repos/$repo/releases/tags/$tag" -Headers @{"Authorization"="token $env:GITEA_TOKEN"} -ErrorAction Stop
|
|
$releaseId = $existing.id
|
|
Write-Host "Release already exists with ID: $releaseId"
|
|
} catch {
|
|
# Create new release
|
|
$body = @{
|
|
tag_name = $tag
|
|
name = "Monitor Control $tag"
|
|
body = "## Monitor Control $tag`n`n### Installation`nDownload and run the installer.`n`n### Features`n- System tray monitor control`n- Brightness/Contrast adjustment`n- Input source switching`n- Quick-switch toolbar`n`n### Requirements`n- Windows 10/11`n- .NET 9.0 Runtime"
|
|
} | ConvertTo-Json
|
|
|
|
$release = Invoke-RestMethod -Uri "$baseUrl/repos/$repo/releases" -Method Post -Headers @{"Authorization"="token $env:GITEA_TOKEN"; "Content-Type"="application/json"} -Body $body
|
|
$releaseId = $release.id
|
|
Write-Host "Release created with ID: $releaseId"
|
|
}
|
|
|
|
# Upload installer
|
|
$filePath = "C:\build\app\installer\MonitorControl-Setup-$version.exe"
|
|
$fileName = "MonitorControl-Setup-$version.exe"
|
|
Write-Host "Uploading $fileName..."
|
|
|
|
curl.exe -X POST -H "Authorization: token $env:GITEA_TOKEN" -F "attachment=@$filePath" "$baseUrl/repos/$repo/releases/$releaseId/assets?name=$fileName"
|
|
|
|
Write-Host "Installer uploaded successfully"
|