70 lines
2.5 KiB
YAML
70 lines
2.5 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: Restore dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Build Release
|
|
run: dotnet build --configuration Release --no-restore
|
|
|
|
- name: Publish
|
|
run: dotnet publish DellMonitorControl/DellMonitorControl.csproj -c Release -o ./publish --self-contained false
|
|
|
|
- name: Create ZIP archive
|
|
run: Compress-Archive -Path ./publish/* -DestinationPath ./MonitorControl-${{ gitea.ref_name }}.zip
|
|
shell: powershell
|
|
|
|
- name: Create Release
|
|
shell: powershell
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
run: |
|
|
$tag = "${{ gitea.ref_name }}"
|
|
$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`n1. Download the ZIP file`n2. Extract to a folder`n3. Run DellMonitorControl.exe`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 asset using curl (more reliable for file uploads)
|
|
$filePath = "./MonitorControl-$tag.zip"
|
|
$fileName = "MonitorControl-$tag.zip"
|
|
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 "Asset uploaded successfully"
|