-
-
Notifications
You must be signed in to change notification settings - Fork 329
82 lines (69 loc) · 2.31 KB
/
Copy pathsdks-publish-csharp.yml
File metadata and controls
82 lines (69 loc) · 2.31 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
name: SDKs — C# publish (NuGet)
# Config only: this workflow builds/tests on every push and, on a version tag,
# packs and pushes to NuGet. Publishing requires the NUGET_API_KEY secret to be
# configured in the repo; without it the push step is skipped (never fails).
#
# Tag gating uses the `csharp-v*` prefix so it never collides with go-ios's own
# `v*` release tags.
on:
push:
branches: [main]
tags: ["csharp-v*"]
paths:
- "sdks/packages/csharp/**"
- "sdks/spec/openapi/**"
- ".github/workflows/sdks-publish-csharp.yml"
pull_request:
paths:
- "sdks/packages/csharp/**"
- ".github/workflows/sdks-publish-csharp.yml"
workflow_dispatch:
defaults:
run:
working-directory: sdks/packages/csharp
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # SourceLink wants full history
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Restore
run: dotnet restore GoIos.Sdk.sln
- name: Build (Release)
run: dotnet build GoIos.Sdk.sln --configuration Release --no-restore
- name: Test
run: dotnet test GoIos.Sdk.sln --configuration Release --no-build --verbosity normal
publish:
# Only on a csharp-v* tag, and after build/test passes.
needs: build-test
if: startsWith(github.ref, 'refs/tags/csharp-v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Pack (Release)
run: dotnet pack src/GoIos.Sdk/GoIos.Sdk.csproj --configuration Release --output ../../artifacts
- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: nupkg
path: sdks/artifacts/*.nupkg
- name: Push to NuGet
# Skipped automatically when the secret is not configured.
if: ${{ env.NUGET_API_KEY != '' }}
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
working-directory: .
run: |
dotnet nuget push "sdks/artifacts/*.nupkg" \
--api-key "$NUGET_API_KEY" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate