Skip to content

Commit 2bce43b

Browse files
authored
refactor(ci): avoid use variable & use parallel
1 parent bc0ce5d commit 2bce43b

3 files changed

Lines changed: 36 additions & 25 deletions

File tree

.github/workflows/copilot-setup-steps.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,22 @@ env:
1919
jobs:
2020
copilot-setup-steps:
2121
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
2224
steps:
2325
- uses: actions/checkout@v7.0.0
2426

2527
- name: Setup .NET SDK
2628
uses: actions/setup-dotnet@v5.4.0
2729
with:
28-
dotnet-version: ${{ vars.DOTNET_SDK_VERSIONS }}
30+
dotnet-version: |
31+
10.x
32+
9.x
33+
8.x
2934
cache: true
3035
cache-dependency-path: Directory.Packages.props
3136

37+
- name: Restore .NET tools
38+
run: dotnet tool restore
3239
- name: Restore NuGet packages
3340
run: dotnet restore

.github/workflows/dotnet.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
contents: read
2121
steps:
2222
- uses: actions/checkout@v7.0.0
23-
- name: Setup .NET SDK # detected from global.json
23+
- name: Setup .NET SDK # detect version from global.json
2424
uses: actions/setup-dotnet@v5.4.0
2525
- name: Restore .NET tools
2626
run: dotnet tool restore
@@ -57,14 +57,17 @@ jobs:
5757
- name: Setup .NET SDK
5858
uses: actions/setup-dotnet@v5.4.0
5959
with:
60-
dotnet-version: ${{ vars.DOTNET_SDK_VERSIONS }}
60+
dotnet-version: |
61+
10.x
62+
9.x
63+
8.x
6164
cache: true
6265
cache-dependency-path: Directory.Packages.props
6366

6467
- name: Build
6568
run: dotnet build
6669
- name: Test
67-
run: dotnet test --no-build --coverage --coverage-output-format cobertura --coverage-output "${{ vars.COVERAGE_REPORT_FILE }}"
70+
run: dotnet test --no-build --coverage --coverage-output-format cobertura --coverage-output "coverage.cobertura.xml"
6871

6972
- name: Upload coverage to Codecov
7073
uses: codecov/codecov-action@v7.0.0
@@ -74,6 +77,6 @@ jobs:
7477
flags: ${{ runner.os }},${{ runner.arch }}
7578
disable_search: true
7679
files: |
77-
${{ format(vars.TEST_ASSET_FOLDERS, 'net10.0', vars.COVERAGE_REPORT_FILE) }},
78-
${{ format(vars.TEST_ASSET_FOLDERS, 'net9.0', vars.COVERAGE_REPORT_FILE) }},
79-
${{ format(vars.TEST_ASSET_FOLDERS, 'net8.0', vars.COVERAGE_REPORT_FILE) }}
80+
${{ format(vars.TEST_ASSET_FOLDERS, 'net10.0', 'coverage.cobertura.xml') }},
81+
${{ format(vars.TEST_ASSET_FOLDERS, 'net9.0', 'coverage.cobertura.xml') }},
82+
${{ format(vars.TEST_ASSET_FOLDERS, 'net8.0', 'coverage.cobertura.xml') }}

.github/workflows/release.yml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,34 @@ jobs:
2525
- name: Setup .NET SDK
2626
uses: actions/setup-dotnet@v5.4.0
2727
with:
28-
dotnet-version: ${{ vars.DOTNET_SDK_VERSIONS }}
28+
dotnet-version: |
29+
10.x
30+
9.x
31+
8.x
2932
cache: true
3033
cache-dependency-path: Directory.Packages.props
3134

3235
- name: Login to NuGet (with OIDC)
33-
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 #v1.2.0
36+
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
3437
id: login
3538
with:
3639
user: ${{ vars.NUGET_USER_NAME }}
3740

38-
- name: Restore
39-
run: dotnet restore --locked-mode
4041
- name: Release Build & Pack
41-
run: dotnet pack --configuration Release --no-restore --output nupkgs -p:Version=${TAG_VERSION:1}
42+
run: dotnet pack --configuration Release --output nupkgs -p:Version=${TAG_VERSION:1}
4243
env:
4344
TAG_VERSION: ${{ github.event.release.tag_name }} # v0.0.0-abc
4445

45-
- name: Generate Attestation for packages
46-
uses: actions/attest@v4.1.1
47-
with:
48-
subject-path: "nupkgs/*.nupkg"
49-
50-
- name: Publish to NuGet
51-
run: dotnet nuget push "nupkgs/*.nupkg" --source https://api.nuget.org/v3/index.json --api-key ${{ steps.login.outputs.NUGET_API_KEY }}
52-
- name: Upload Packages
53-
uses: actions/upload-artifact@v7.0.1
54-
with:
55-
name: packages
56-
path: nupkgs/
57-
include-hidden-files: true
46+
- parallel:
47+
- name: Generate Attestation for packages
48+
uses: actions/attest@v4.1.1
49+
with:
50+
subject-path: "nupkgs/*.nupkg"
51+
- name: Publish to NuGet
52+
run: dotnet nuget push "nupkgs/*.nupkg" --source https://api.nuget.org/v3/index.json --api-key ${{ steps.login.outputs.NUGET_API_KEY }}
53+
- name: Upload Packages
54+
uses: actions/upload-artifact@v7.0.1
55+
with:
56+
name: packages
57+
path: nupkgs/
58+
include-hidden-files: true

0 commit comments

Comments
 (0)