-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (70 loc) · 2.55 KB
/
build.yml
File metadata and controls
85 lines (70 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Build
on:
push:
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4
with:
versionSpec: "6.4.0"
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v4
with:
configFilePath: "GitVersion.yml"
# Cache packages for faster subsequent runs
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', 'nuget.config') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore
working-directory: ./src
run: dotnet restore ./CenterEdge.Async.sln
- name: Build
working-directory: ./src
run: dotnet build --no-restore -c Release /p:Version=${{ steps.gitversion.outputs.semVer }} ./CenterEdge.Async.sln
- name: Test
working-directory: ./src
run: dotnet test --no-build -c Release -f net8.0 -l "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" ./CenterEdge.Async.sln
- name: Pack
working-directory: ./src
run: dotnet pack --no-build -c Release /p:PackageVersion=${{ steps.gitversion.outputs.fullSemVer }} ./CenterEdge.Async.sln
- name: Push
working-directory: ./src
# Publish CI packages from PRs and tagged releases
if: ${{ startsWith(github.ref, 'refs/tags/') || (startsWith(github.ref, 'refs/pull/')) && !github.event.pull_request.head.repo.fork }}
run: |
dotnet nuget add source --name github https://nuget.pkg.github.com/CenterEdge/index.json &&
dotnet nuget push **/*.${{ steps.gitversion.outputs.fullSemVer }}.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s github
- name: NuGet login (OIDC → temp API key)
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: NuGet/login@v1
id: login
with:
user: ${{ vars.NUGET_USER }}
- name: Push to NuGet.org
working-directory: ./src
# Publish tagged releases to NuGet.org
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: dotnet nuget push **/*.${{ steps.gitversion.outputs.fullSemVer }}.nupkg -k ${{ steps.login.outputs.NUGET_API_KEY }} -s nuget.org