-
Notifications
You must be signed in to change notification settings - Fork 1
107 lines (90 loc) · 3.11 KB
/
Copy pathci-release.yml
File metadata and controls
107 lines (90 loc) · 3.11 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: CI & NuGet Release
on:
push:
branches: [ master ]
tags:
- 'v*' # e.g. v1.2.3 -> triggers release
pull_request:
branches: [ master ]
permissions:
contents: read
jobs:
build_test:
name: Build & Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # improve Source Link and versioning fidelity
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- name: Restore
run: dotnet restore
- name: Build (Release)
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal
- name: Pack (artifact only)
if: startsWith(github.ref, 'refs/tags/v') == false
run: >
dotnet pack ./src/SystemCommandLine.Extensions/SystemCommandLine.Extensions.csproj
--configuration Release --no-build -o ./artifacts
/p:ContinuousIntegrationBuild=true
- name: Upload package artifacts (non-release)
if: startsWith(github.ref, 'refs/tags/v') == false
uses: actions/upload-artifact@v4
with:
name: packages
path: |
./artifacts/*.nupkg
./artifacts/*.snupkg
publish_nuget:
name: Publish to NuGet.org
needs: build_test
if: startsWith(github.ref, 'refs/tags/v') # only on version tags
runs-on: ubuntu-latest
environment:
name: nuget
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # improve Source Link and versioning fidelity
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
# Derive version from tag: v1.2.3 -> 1.2.3
- name: Derive version
id: ver
shell: bash
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore /p:ContinuousIntegrationBuild=true
- name: Pack (tagged version)
run: >
dotnet pack ./src/SystemCommandLine.Extensions/SystemCommandLine.Extensions.csproj
--configuration Release --no-build -o ./artifacts
/p:ContinuousIntegrationBuild=true /p:Version=${{ steps.ver.outputs.VERSION }}
- name: Push to NuGet.org (.nupkg)
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
dotnet nuget push "./artifacts/SystemCommandLine.Extensions.*.nupkg" \
--api-key "$NUGET_API_KEY" \
--source "https://api.nuget.org/v3/index.json" \
--skip-duplicate
- name: Push to NuGet.org (.snupkg symbols)
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
dotnet nuget push "./artifacts/SystemCommandLine.Extensions.*.snupkg" \
--api-key "$NUGET_API_KEY" \
--source "https://api.nuget.org/v3/index.json" \
--skip-duplicate