146 lines
6.1 KiB
YAML
146 lines
6.1 KiB
YAML
name: CI
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- "v*"
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
concurrency:
|
|
group: ${{ gitea.workflow }}-${{ gitea.ref }}
|
|
cancel-in-progress: ${{ !startsWith(gitea.ref, 'refs/tags/') }}
|
|
env:
|
|
NUGET_PACKAGES: ${{ runner.temp }}\.nuget\packages
|
|
DOTNET_NOLOGO: true
|
|
DOTNET_CLI_TELEMETRY_OPT_OUT: true
|
|
jobs:
|
|
build-and-test:
|
|
runs-on: windows-latest
|
|
timeout-minutes: 20
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
|
with:
|
|
fetch-depth: 1
|
|
- name: Setup .NET 8 SDK
|
|
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9
|
|
with:
|
|
dotnet-version: 8.0.x
|
|
- name: Cache NuGet packages
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
|
|
with:
|
|
path: ${{ runner.temp }}\.nuget\packages
|
|
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', 'global.json', '.config/dotnet-tools.json') }}
|
|
restore-keys: |
|
|
nuget-${{ runner.os }}-
|
|
- name: Restore tools
|
|
shell: powershell
|
|
run: |
|
|
$ErrorActionPreference = "Stop"
|
|
Get-Location
|
|
Get-ChildItem .config -File
|
|
Write-Output "USERPROFILE=$env:USERPROFILE"
|
|
Write-Output "DOTNET_CLI_HOME=$env:DOTNET_CLI_HOME"
|
|
Write-Output "DOTNET_ROOT=$env:DOTNET_ROOT"
|
|
Write-Output "NUGET_PACKAGES=$env:NUGET_PACKAGES"
|
|
dotnet --list-sdks
|
|
dotnet tool restore --tool-manifest .config/dotnet-tools.json
|
|
if ($LASTEXITCODE -ne 0) { throw "tool restore failed ($LASTEXITCODE)" }
|
|
dotnet tool list
|
|
Get-ChildItem "$env:USERPROFILE/.dotnet/tools" -Recurse -ErrorAction SilentlyContinue | Select-Object FullName
|
|
- name: Restore
|
|
shell: powershell
|
|
run: dotnet restore src/RgbLedStripController/RgbLedStripController.csproj --configfile NuGet.Config
|
|
- name: Build (Release)
|
|
shell: powershell
|
|
run: dotnet build src/RgbLedStripController/RgbLedStripController.csproj -c Release --no-restore
|
|
- name: Run tests (if any test projects exist)
|
|
shell: powershell
|
|
run: |
|
|
$ErrorActionPreference = "Stop"
|
|
$tests = @(Get-ChildItem -Recurse -Filter "*Tests.csproj" | Where-Object { $_.FullName -notlike "*\obj\*" -and $_.FullName -notlike "*\bin\*" })
|
|
if ($tests.Count -eq 0) {
|
|
Write-Host "No test projects found yet; skipping dotnet test."
|
|
exit 0
|
|
}
|
|
foreach ($t in $tests) {
|
|
dotnet test $t.FullName -c Release
|
|
if ($LASTEXITCODE -ne 0) { throw "dotnet test failed for $($t.FullName)" }
|
|
}
|
|
release:
|
|
needs:
|
|
- build-and-test
|
|
if: startsWith(gitea.ref, 'refs/tags/v')
|
|
runs-on: windows-latest
|
|
timeout-minutes: 30
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
|
with:
|
|
fetch-depth: 1
|
|
- name: Setup .NET 8 SDK
|
|
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9
|
|
with:
|
|
dotnet-version: 8.0.x
|
|
- name: Cache NuGet packages
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
|
|
with:
|
|
path: ${{ runner.temp }}\.nuget\packages
|
|
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', 'global.json', '.config/dotnet-tools.json') }}
|
|
restore-keys: |
|
|
nuget-${{ runner.os }}-
|
|
- name: Restore tools
|
|
shell: powershell
|
|
run: |
|
|
$ErrorActionPreference = "Stop"
|
|
Get-Location
|
|
Get-ChildItem .config -File
|
|
Write-Output "USERPROFILE=$env:USERPROFILE"
|
|
Write-Output "DOTNET_CLI_HOME=$env:DOTNET_CLI_HOME"
|
|
Write-Output "DOTNET_ROOT=$env:DOTNET_ROOT"
|
|
Write-Output "NUGET_PACKAGES=$env:NUGET_PACKAGES"
|
|
dotnet --list-sdks
|
|
dotnet tool restore --tool-manifest .config/dotnet-tools.json
|
|
if ($LASTEXITCODE -ne 0) { throw "tool restore failed ($LASTEXITCODE)" }
|
|
dotnet tool list
|
|
Get-ChildItem "$env:USERPROFILE/.dotnet/tools" -Recurse -ErrorAction SilentlyContinue | Select-Object FullName
|
|
- name: Assert tag matches csproj version
|
|
shell: powershell
|
|
run: |
|
|
$ErrorActionPreference = "Stop"
|
|
$ref = "${{ gitea.ref_name }}"
|
|
$projXml = [xml](Get-Content src/RgbLedStripController/RgbLedStripController.csproj)
|
|
$version = $projXml.Project.PropertyGroup | Where-Object { $_.Version } | Select-Object -First 1 -ExpandProperty Version
|
|
if ("v$version" -ne $ref) { throw "Tag $ref does not match csproj version $version" }
|
|
- name: Package with Velopack (Setup.exe + Portable.zip)
|
|
shell: powershell
|
|
run: |
|
|
$ErrorActionPreference = "Stop"
|
|
& "$env:GITHUB_WORKSPACE/scripts/release/package-velopack.ps1"
|
|
if ($LASTEXITCODE -ne 0) { throw "package-velopack.ps1 failed ($LASTEXITCODE)" }
|
|
$out = Join-Path $env:GITHUB_WORKSPACE "artifacts/velopack/win-x64-stable"
|
|
foreach ($p in @("*.exe", "*.zip", "*.json", "*.nupkg")) {
|
|
if (@(Get-ChildItem -Path (Join-Path $out $p) -File -ErrorAction SilentlyContinue).Count -eq 0) { throw "Velopack output missing pattern $p in $out" }
|
|
}
|
|
- name: Create Gitea Release with assets
|
|
uses: akkuman/gitea-release-action@5a83c90484ef4355121df5eb60558c8ce66e81ac
|
|
with:
|
|
token: ${{ secrets.API_TOKEN }}
|
|
tag_name: ${{ gitea.ref_name }}
|
|
repository: ${{ gitea.repository }}
|
|
files: |
|
|
artifacts/velopack/win-x64-stable/*.exe
|
|
artifacts/velopack/win-x64-stable/*.zip
|
|
artifacts/velopack/win-x64-stable/*.json
|
|
artifacts/velopack/win-x64-stable/*.nupkg
|
|
name: ${{ gitea.ref_name }}
|
|
body: |
|
|
Release ${{ gitea.ref_name }}
|
|
|
|
- RGBLedStripController-Setup-${{ gitea.ref_name }}-x64.exe (Windows Installer)
|
|
- RGBLedStripController-Portable-${{ gitea.ref_name }}-x64.zip (Portable)
|
|
draft: false
|
|
prerelease: false
|