Files
controlmymonitormanagement/.gitea/workflows/release.yaml

62 lines
2.1 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"
Write-Host "Token length: $($env:GITEA_TOKEN.Length)"
$headers = @{
"Authorization" = "token $env:GITEA_TOKEN"
"Content-Type" = "application/json"
}
$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 $headers -Body $body
Write-Host "Release created with ID: $($release.id)"
$filePath = "./MonitorControl-$tag.zip"
Invoke-RestMethod -Uri "$baseUrl/repos/$repo/releases/$($release.id)/assets?name=MonitorControl-$tag.zip" -Method Post -Headers @{"Authorization"="token $env:GITEA_TOKEN"} -InFile $filePath -ContentType "application/zip"
Write-Host "Asset uploaded successfully"