-
Notifications
You must be signed in to change notification settings - Fork 13
228 lines (177 loc) · 6.26 KB
/
Copy pathbuild.yml
File metadata and controls
228 lines (177 loc) · 6.26 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
name: "Build & release"
on:
push:
branches:
- main
- dev
tags:
- v*
paths-ignore:
- docs/**
- LICENSE
- "**.md"
pull_request:
branches:
- "*"
paths-ignore:
- docs/**
- LICENSE
- "**.md"
jobs:
format:
name: "Check code format"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: ./.github/workflows/actions/setup-tools
- name: Format
run: just format --verify-no-changes
build_debug:
name: "Debug build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: ./.github/workflows/actions/setup-tools
- name: Restore
run: just restore
- name: Build
run: just build --configuration Debug --no-restore
- name: Install Playwright
run: just install-playwright
- name: Test
run: |
just unit-tests --configuration Debug --no-build
just integration-tests --configuration Debug --no-build
build_release:
name: "Release build & package"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # required for minver to create the right version number
filter: tree:0
- uses: ./.github/workflows/actions/setup-tools
- name: Restore
run: just restore
- name: Format
run: just format --verify-no-changes
- name: Build
run: just build --configuration Release --no-restore
- name: Install Playwright
run: just install-playwright
- name: Test
run: |
just unit-tests --configuration Release --no-build
just integration-tests --configuration Release --no-build
- name: Assign package build metadata
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: |
echo "MINVERBUILDMETADATA=build.${{ github.run_id }}.${{ github.run_attempt}}" >> $GITHUB_ENV
- name: Update package README GitHub link
run: |
if [[ "${{ github.ref }}" == "refs/tags/v"* ]]; then
REF="${{ github.ref_name }}"
else
REF="${{ github.sha }}"
fi
README_PATH="src/GovUk.Frontend.AspNetCore/Package/README.md"
ORIGINAL_URL="https://github.com/${{ github.repository }}/blob/main/"
NEW_URL="https://github.com/${{ github.repository }}/blob/${REF}/"
if ! grep -q "$ORIGINAL_URL" "$README_PATH"; then
echo "::error::Expected URL pattern '$ORIGINAL_URL' not found in $README_PATH"
exit 1
fi
sed -i "s|${ORIGINAL_URL}|${NEW_URL}|g" "$README_PATH"
echo "Updated README link to reference: ${REF}"
- name: Pack
run: just pack --configuration Release
- name: Publish package artifact
uses: actions/upload-artifact@v7
with:
name: GovUk.Frontend.AspNetCore.nupkg
path: packages/*.nupkg
package_tests:
name: "Package tests"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # required for minver to create the right version number
filter: tree:0
- uses: ./.github/workflows/actions/setup-tools
- name: Restore
run: just restore
# These pack the library and build throwaway projects against the package, so they only need
# running once; nothing in the targets varies by configuration.
- name: Test
run: just package-tests --configuration Release
build_samples:
name: "Build samples"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
filter: tree:0
- uses: ./.github/workflows/actions/setup-tools
- name: Build samples
run: just build-samples --configuration Release
docs:
name: "Check docs"
runs-on: ubuntu-latest
needs: [build_release]
steps:
- uses: actions/checkout@v7
- uses: ./.github/workflows/actions/setup-tools
- name: Check component documentation
run: |
just publish-docs --configuration Release
changes=$(git status --porcelain docs ':!docs/images' | cut -c 4-)
if [ -n "$changes" ]
then
echo "::error ::Documentation is stale"
exit 1
fi
- name: Check GOV.UK Design System version
run: |
# Extract version from Directory.Build.props
props_version=$(grep -oP '<GovUkFrontendVersion>\K[^<]+' Directory.Build.props)
if [ -z "$props_version" ]; then
echo "::error ::Failed to extract version from Directory.Build.props"
exit 1
fi
echo "Version in Directory.Build.props: $props_version"
# Extract version from README badge (supports semantic versioning including pre-release versions)
readme_version=$(grep -oP 'GOV\.UK%20Design%20System-\K[0-9]+\.[0-9]+\.[0-9]+(?:-[a-zA-Z0-9.]+)?(?=-)' README.md)
if [ -z "$readme_version" ]; then
echo "::error ::Failed to extract version from README.md badge"
exit 1
fi
echo "Version in README.md: $readme_version"
# Compare versions
if [ "$props_version" != "$readme_version" ]; then
echo "::error ::GOV.UK Design System version mismatch: Directory.Build.props has $props_version but README.md has $readme_version"
exit 1
fi
echo "✓ Versions match: $props_version"
release:
name: "Publish package to NuGet"
runs-on: ubuntu-latest
needs: [format, build_release, build_samples, package_tests, docs]
if: startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write
steps:
- uses: actions/checkout@v7
- uses: ./.github/workflows/actions/setup-tools
- name: Download package artifact
uses: actions/download-artifact@v8
with:
name: GovUk.Frontend.AspNetCore.nupkg
- name: NuGet login
uses: NuGet/login@v1
id: login
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish package to NuGet
run: dotnet nuget push **/*.nupkg --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json