Files
rgb-led-strip-controller/.gitea/workflows/ci.yml
T
fristy 3a268dcaf1
CI / test (push) Successful in 55s
CI / release (push) Canceled after 0s
CI / build (push) Canceled after 2m33s
ci: add dotnet tools caching to speed up tool restore (was 32 min)
2026-09-05 14:31:49 +03:00

210 lines
6.5 KiB
YAML

name: CI
on:
push:
branches:
- main
tags:
- "v*"
pull_request:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
env:
NUGET_PACKAGES: ${{ runner.temp }}/.nuget/packages
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPT_OUT: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup .NET 8 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.424
env:
DOTNET_INSTALL_DIR: ${{ runner.temp }}\dotnet
- name: Cache NuGet packages
id: nuget-cache
uses: actions/cache@v3
continue-on-error: true
with:
path: ${{ runner.temp }}/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '.config/dotnet-tools.json') }}
restore-keys: |
nuget-${{ runner.os }}-
- name: Cache dotnet tools
id: tools-cache
uses: actions/cache@v3
continue-on-error: true
with:
path: ${{ runner.temp }}/.dotnet/tools
key: tools-${{ runner.os }}-${{ hashFiles('.config/dotnet-tools.json') }}
restore-keys: |
tools-${{ runner.os }}-
- name: Cache status
if: always()
shell: powershell
run: |
Write-Host "NuGet cache hit: ${{ steps.nuget-cache.outputs.cache-hit }}"
Write-Host "Tools cache hit: ${{ steps.tools-cache.outputs.cache-hit }}"
- name: Restore tools
shell: powershell
run: dotnet tool restore
- name: Restore
shell: powershell
run: dotnet restore src/RgbLedStripController/RgbLedStripController.csproj --configfile NuGet.Config
- name: Build (Release)
run: dotnet build src/RgbLedStripController/RgbLedStripController.csproj -c Release --no-restore
test:
runs-on: windows-latest
env:
NUGET_PACKAGES: ${{ runner.temp }}/.nuget/packages
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPT_OUT: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup .NET 8 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.424
env:
DOTNET_INSTALL_DIR: ${{ runner.temp }}\dotnet
- name: Cache NuGet packages
id: nuget-cache
uses: actions/cache@v3
continue-on-error: true
with:
path: ${{ runner.temp }}/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '.config/dotnet-tools.json') }}
restore-keys: |
nuget-${{ runner.os }}-
- name: Cache dotnet tools
id: tools-cache
uses: actions/cache@v3
continue-on-error: true
with:
path: ${{ runner.temp }}/.dotnet/tools
key: tools-${{ runner.os }}-${{ hashFiles('.config/dotnet-tools.json') }}
restore-keys: |
tools-${{ runner.os }}-
- name: Cache status
if: always()
shell: powershell
run: |
Write-Host "NuGet cache hit: ${{ steps.nuget-cache.outputs.cache-hit }}"
Write-Host "Tools cache hit: ${{ steps.tools-cache.outputs.cache-hit }}"
- 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
- test
if: startsWith(gitea.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
runs-on: windows-latest
env:
NUGET_PACKAGES: ${{ runner.temp }}/.nuget/packages
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPT_OUT: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup .NET 8 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.424
env:
DOTNET_INSTALL_DIR: ${{ runner.temp }}\dotnet
- name: Cache NuGet packages
id: nuget-cache
uses: actions/cache@v3
continue-on-error: true
with:
path: ${{ runner.temp }}/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '.config/dotnet-tools.json') }}
restore-keys: |
nuget-${{ runner.os }}-
- name: Cache dotnet tools
id: tools-cache
uses: actions/cache@v3
continue-on-error: true
with:
path: ${{ runner.temp }}/.dotnet/tools
key: tools-${{ runner.os }}-${{ hashFiles('.config/dotnet-tools.json') }}
restore-keys: |
tools-${{ runner.os }}-
- name: Cache status
if: always()
shell: powershell
run: |
Write-Host "NuGet cache hit: ${{ steps.nuget-cache.outputs.cache-hit }}"
Write-Host "Tools cache hit: ${{ steps.tools-cache.outputs.cache-hit }}"
- name: Restore tools
shell: powershell
run: dotnet tool restore
- name: Package with Velopack (Setup.exe + Portable.zip)
shell: powershell
run: |
$ErrorActionPreference = "Stop"
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/release/package-velopack.ps1
- name: Create Gitea Release with assets
uses: akkuman/gitea-release-action@v1
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