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