Files
rgb-led-strip-controller/.gitea/workflows/ci.yml
T
fristy dbc51a8d43
CI / Code Health (pull_request) Successful in 12s
CI / build-and-test (pull_request) Successful in 58s
CI / release (pull_request) Skipped
docs: README, AGPL-3.0 LICENSE, Code Health CI + scorecard
2026-09-12 01:33:51 +03:00

150 lines
5.8 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"
dotnet tool restore --tool-manifest .config/dotnet-tools.json
if ($LASTEXITCODE -ne 0) { throw "tool restore failed ($LASTEXITCODE)" }
- 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)" }
}
health:
name: Code Health
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Scan with desloppify (CI profile, objective only)
continue-on-error: true
run: pipx run --spec desloppify desloppify scan --profile ci --path src
- name: Upload scorecard
uses: actions/upload-artifact@v3
with:
name: desloppify-scorecard
path: scorecard.png
if-no-files-found: ignore
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"
dotnet tool restore --tool-manifest .config/dotnet-tools.json
if ($LASTEXITCODE -ne 0) { throw "tool restore failed ($LASTEXITCODE)" }
- 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