ci: fix tool restore, enable cache, pin actions, merge build+test, guard releases
This commit is contained in:
3 files changed
+42
-129
No files matched your search
@@ -6,7 +6,8 @@
|
||||
"version": "0.0.1298",
|
||||
"commands": [
|
||||
"vpk"
|
||||
]
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
-128
@@ -1,5 +1,4 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
@@ -9,112 +8,42 @@ on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
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:
|
||||
build-and-test:
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
NUGET_PACKAGES: ${{ runner.temp }}/.nuget/packages
|
||||
DOTNET_NOLOGO: true
|
||||
DOTNET_CLI_TELEMETRY_OPT_OUT: true
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Setup .NET 8 SDK
|
||||
uses: actions/setup-dotnet@v4
|
||||
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9
|
||||
with:
|
||||
dotnet-version: 8.0.424
|
||||
env:
|
||||
DOTNET_INSTALL_DIR: ${{ runner.temp }}\dotnet
|
||||
|
||||
dotnet-version: 8.0.x
|
||||
- name: Cache NuGet packages
|
||||
id: nuget-cache
|
||||
uses: actions/cache@v3
|
||||
continue-on-error: true
|
||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
|
||||
with:
|
||||
path: ${{ runner.temp }}/.nuget/packages
|
||||
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '.config/dotnet-tools.json') }}
|
||||
path: ${{ runner.temp }}\.nuget\packages
|
||||
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', 'global.json', '.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 }}"
|
||||
|
||||
run: dotnet build src/RgbLedStripController/RgbLedStripController.csproj -c Release --no-restore
|
||||
- name: Run tests (if any test projects exist)
|
||||
shell: powershell
|
||||
run: |
|
||||
@@ -128,69 +57,46 @@ jobs:
|
||||
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'
|
||||
- build-and-test
|
||||
if: startsWith(gitea.ref, 'refs/tags/v')
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
NUGET_PACKAGES: ${{ runner.temp }}/.nuget/packages
|
||||
DOTNET_NOLOGO: true
|
||||
DOTNET_CLI_TELEMETRY_OPT_OUT: true
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Setup .NET 8 SDK
|
||||
uses: actions/setup-dotnet@v4
|
||||
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9
|
||||
with:
|
||||
dotnet-version: 8.0.424
|
||||
env:
|
||||
DOTNET_INSTALL_DIR: ${{ runner.temp }}\dotnet
|
||||
|
||||
dotnet-version: 8.0.x
|
||||
- name: Cache NuGet packages
|
||||
id: nuget-cache
|
||||
uses: actions/cache@v3
|
||||
continue-on-error: true
|
||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
|
||||
with:
|
||||
path: ${{ runner.temp }}/.nuget/packages
|
||||
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '.config/dotnet-tools.json') }}
|
||||
path: ${{ runner.temp }}\.nuget\packages
|
||||
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', 'global.json', '.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: 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"
|
||||
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/release/package-velopack.ps1
|
||||
|
||||
- name: Create Gitea Release with assets
|
||||
uses: akkuman/gitea-release-action@v1
|
||||
uses: akkuman/gitea-release-action@5a83c90484ef4355121df5eb60558c8ce66e81ac
|
||||
with:
|
||||
token: ${{ secrets.API_TOKEN }}
|
||||
tag_name: ${{ gitea.ref_name }}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "8.0.100",
|
||||
"rollForward": "latestFeature"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user