-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (146 loc) · 5.11 KB
/
Copy pathci.yml
File metadata and controls
171 lines (146 loc) · 5.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
jobs:
version:
name: version
runs-on: ubuntu-latest
outputs:
semver: ${{ steps.pick.outputs.semver }}
steps:
- name: Checkout
uses: actions/checkout@v7
with:
# GitVersion derives the version from tags and branch history; a shallow clone has
# neither.
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
# Deliberately allowed to fail. GitVersion cannot version every git shape — a branch with no
# merge base against a release branch, for one — and "we could not name this build" is not a
# reason to refuse to compile it.
- name: Run GitVersion
id: gitversion
continue-on-error: true
run: |
set -euo pipefail
dotnet tool restore
semver=$(dotnet gitversion /showvariable FullSemVer)
echo "semver=$semver" >> "$GITHUB_OUTPUT"
- name: Pick the version for this run
id: pick
run: |
semver='${{ steps.gitversion.outputs.semver }}'
if [ -z "$semver" ]; then
semver="0.0.0-unversioned.${{ github.run_number }}"
echo "::warning title=GitVersion::Could not derive a version for this ref; building as $semver. Release versions come from semantic-release and are unaffected."
fi
echo "semver=$semver" >> "$GITHUB_OUTPUT"
echo "Building as $semver"
build-test:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: version
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
- name: Restore
run: dotnet restore CanKit.Pro.sln
- name: Build
run: dotnet build CanKit.Pro.sln --configuration Release --no-restore -p:Version=${{ needs.version.outputs.semver }}
- name: Test
run: >
dotnet test CanKit.Pro.sln
--configuration Release
--no-build
-p:Version=${{ needs.version.outputs.semver }}
--logger "trx;LogFileName=test-results.trx"
--collect:"XPlat Code Coverage"
--results-directory artifacts/test-results
# An approval test that has no baseline yet writes what it saw; printing it means the
# baseline can be reviewed and committed straight from the log, without downloading an
# artifact first.
- name: Show generated API approvals
if: failure() && runner.os == 'Linux'
run: |
shopt -s nullglob
for f in tests/CanKit.Pro.Tests/ApiApprovals/*.received.txt; do
echo "----- BEGIN $f"
cat "$f"
echo "----- END $f"
done
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}
path: |
artifacts/test-results/**
tests/CanKit.Pro.Tests/ApiApprovals/*.received.txt
if-no-files-found: warn
pack:
name: pack (dry run)
runs-on: ubuntu-latest
needs: [version, build-test]
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
# Proves the release job's `dotnet pack` will work, and that every package still carries a
# README, a license expression and symbols — before a tag exists to fix it in.
- name: Pack
run: dotnet pack CanKit.Pro.sln --configuration Release -p:Version=${{ needs.version.outputs.semver }} --output artifacts/nuget
- name: List produced packages
run: ls -l artifacts/nuget
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: |
artifacts/nuget/*.nupkg
artifacts/nuget/*.snupkg
if-no-files-found: error
release-config:
name: validate release config
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
- name: Install release tooling
run: npm ci
# Catches a broken .releaserc.json (typo'd plugin, missing dependency, preset/tooling
# mismatch) on the pull request that introduces it, rather than on the merge to main that
# was supposed to publish a release. The full dry run lives in release.yml, where the token
# has the rights the GitHub plugin needs.
- name: Verify release configuration loads
run: node eng/verify-release-config.mjs