Skip to content

Commit dfa285a

Browse files
committed
Update CI workflows to .NET 10.0 and enhance caching for NuGet packages
1 parent 980b571 commit dfa285a

2 files changed

Lines changed: 80 additions & 38 deletions

File tree

.github/workflows/ci.yml

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,42 @@ on:
55
branches: [ "master" ]
66
pull_request:
77
branches: [ "master" ]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
816

917
jobs:
1018
build:
11-
1219
runs-on: ubuntu-latest
1320

1421
steps:
15-
- uses: actions/checkout@v3
16-
with:
17-
fetch-depth: 0
18-
- name: Setup .NET
19-
uses: actions/setup-dotnet@v2
20-
with:
21-
dotnet-version: 8.0.x
22-
- name: Restore dependencies
23-
run: dotnet restore
24-
- name: Build
25-
run: dotnet build --no-restore
26-
- name: Test
27-
run: dotnet test --no-build --verbosity normal
22+
- uses: actions/checkout@v5
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Setup .NET
27+
uses: actions/setup-dotnet@v4
28+
with:
29+
dotnet-version: 10.0.x
30+
31+
- name: Cache NuGet packages
32+
uses: actions/cache@v4
33+
with:
34+
path: ~/.nuget/packages
35+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Packages.props') }}
36+
restore-keys: |
37+
${{ runner.os }}-nuget-
38+
39+
- name: Restore
40+
run: dotnet restore
41+
42+
- name: Build
43+
run: dotnet build --configuration Release --no-restore
44+
45+
- name: Test
46+
run: dotnet test --configuration Release --no-build --verbosity normal

.github/workflows/publish.yml

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,65 @@
11
name: Create Release
22

3-
on: [workflow_dispatch]
4-
jobs:
5-
build:
3+
on:
4+
workflow_dispatch:
5+
6+
concurrency:
7+
group: publish-${{ github.ref }}
8+
cancel-in-progress: false
69

10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
publish:
715
runs-on: ubuntu-latest
816

917
steps:
10-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v5
1119
with:
1220
fetch-depth: 0
1321

14-
- name: Nerdbank.GitVersioning
15-
uses: dotnet/nbgv@v0.4.0
16-
1722
- name: Setup .NET
18-
uses: actions/setup-dotnet@v2
23+
uses: actions/setup-dotnet@v4
1924
with:
20-
dotnet-version: 8.0.x
25+
dotnet-version: 10.0.x
2126

22-
- uses: dotnet/nbgv@master
27+
- name: Cache NuGet packages
28+
uses: actions/cache@v4
29+
with:
30+
path: ~/.nuget/packages
31+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Packages.props') }}
32+
restore-keys: |
33+
${{ runner.os }}-nuget-
34+
35+
- name: Nerdbank.GitVersioning
2336
id: nbgv
24-
- run: echo 'SemVer2=${{ steps.nbgv.outputs.SemVer2 }}'
37+
uses: dotnet/nbgv@v0.4.2
38+
39+
- name: Restore
40+
run: dotnet restore
2541

26-
- name: Dotnet Pack
27-
working-directory: src/TabBlazor.FluentValidation
28-
run: dotnet pack -c Release
42+
- name: Build
43+
run: dotnet build --configuration Release --no-restore
44+
45+
- name: Pack
46+
run: dotnet pack src/TabBlazor.FluentValidation/TabBlazor.FluentValidation.csproj --configuration Release --no-build --output ./artifacts
47+
48+
- name: Upload package artifact
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: nupkg
52+
path: ./artifacts/*.nupkg
2953

30-
- name: Dotnet Nuget Push
31-
working-directory: src/TabBlazor.FluentValidation/bin/Release
32-
run: dotnet nuget push TabBlazor.FluentValidation.*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
54+
- name: Push to NuGet
55+
run: dotnet nuget push "./artifacts/*.nupkg" --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
3356

34-
- name: Create Release
35-
uses: actions/create-release@master
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
- name: Create GitHub Release
58+
uses: softprops/action-gh-release@v2
3859
with:
39-
tag_name: ${{ steps.nbgv.outputs.SemVer2 }}
40-
release_name: Release ${{ steps.nbgv.outputs.SemVer2 }}
60+
tag_name: v${{ steps.nbgv.outputs.SemVer2 }}
61+
name: Release ${{ steps.nbgv.outputs.SemVer2 }}
4162
draft: false
42-
prerelease: true
63+
prerelease: ${{ contains(steps.nbgv.outputs.SemVer2, '-') }}
64+
generate_release_notes: true
65+
files: ./artifacts/*.nupkg

0 commit comments

Comments
 (0)