-
Notifications
You must be signed in to change notification settings - Fork 31
104 lines (87 loc) · 3.03 KB
/
Copy pathci.yml
File metadata and controls
104 lines (87 loc) · 3.03 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
# Publishing uses nuget.org Trusted Publishing (OIDC) instead of a long-lived
# API key. This workflow filename (ci.yml) is part of the trust-policy contract
# on nuget.org -- do not rename it without updating the policy.
#
# Setup (one-time, on nuget.org):
# 1. nuget.org -> user menu -> Trusted Publishing -> create policy.
# 2. Repository Owner: square, Repository: square-dotnet-sdk,
# Workflow File: "ci.yml" (filename only, no path).
# 3. Add a NUGET_USER repo secret containing your nuget.org profile name
# (not your email).
# 4. After the first successful publish, remove the old NUGET_API_KEY secret
# (a stale key can interfere with OIDC login).
name: CI
on:
push:
paths-ignore:
- 'legacy/**'
branches:
- main
- master
tags:
- '*'
- '!*Legacy*' # Exclude tags containing "Legacy"
pull_request:
branches:
- main
- master
paths-ignore:
- 'legacy/**'
env:
CI: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
MSBUILDTERMINALLOGGER: off
jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Install tools
run: dotnet tool restore
- name: Restore dependencies
run: dotnet restore src/Square.sln
- name: Build release
run: dotnet build src/Square.sln -c Release /p:ContinuousIntegrationBuild=true
- name: Run Tests
run: dotnet test src/Square.sln --no-build --no-restore -c Release /p:ContinuousIntegrationBuild=true
continue-on-error: true
env:
TEST_SQUARE_TOKEN: ${{ secrets.TEST_SQUARE_TOKEN }}
TEST_SQUARE_REPORTING: ${{ secrets.TEST_SQUARE_REPORTING }}
publish:
needs: [ci]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: read # Required for checkout
id-token: write # Required for NuGet Trusted Publishing (OIDC)
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Install tools
run: dotnet tool restore
- name: Restore dependencies
run: dotnet restore src/Square.sln
- name: Build release
run: dotnet build src/Square.sln --no-restore -c Release /p:ContinuousIntegrationBuild=true
- name: Pack
run: dotnet pack src/Square.sln --no-build --no-restore -c Release -o dist
- name: NuGet login (OIDC -> temp API key)
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
id: login
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish to nuget.org
env:
NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
run: dotnet nuget push dist/*.nupkg --api-key "$NUGET_API_KEY" --source "nuget.org" --skip-duplicate