-
Notifications
You must be signed in to change notification settings - Fork 1
274 lines (238 loc) · 9.53 KB
/
Copy pathci.yml
File metadata and controls
274 lines (238 loc) · 9.53 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
name: CI
on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --no-build --configuration Release --logger trx --results-directory TestResults
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: TestResults/*.trx
- name: Pack NuGet packages
run: |
dotnet pack src/EncDotNet.Iso8211/EncDotNet.Iso8211.csproj --no-build --configuration Release --output nupkgs
dotnet pack src/EncDotNet.S57/EncDotNet.S57.csproj --no-build --configuration Release --output nupkgs
dotnet pack src/EncDotNet.Noaa/EncDotNet.Noaa.csproj --no-build --configuration Release --output nupkgs
- name: Upload NuGet packages
uses: actions/upload-artifact@v4
with:
name: nupkgs
path: nupkgs/*.nupkg
format:
name: Format check
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Restore
run: dotnet restore
- name: Verify formatting (whitespace)
# Fix locally with: dotnet format whitespace EncDotNet.slnx
run: dotnet format whitespace EncDotNet.slnx --no-restore --verify-no-changes
- name: Verify usings (ordering + unused)
# Fix locally with:
# dotnet format style EncDotNet.slnx --diagnostics IDE0005
run: dotnet format style EncDotNet.slnx --diagnostics IDE0005 --severity warn --no-restore --verify-no-changes
publish:
needs: build
strategy:
matrix:
include:
- os: macos-latest
rid: osx-arm64
artifact: ChartViewer-osx-arm64
- os: windows-latest
rid: win-x64
artifact: ChartViewer-win-x64
- os: ubuntu-latest
rid: linux-x64
artifact: ChartViewer-linux-x64
runs-on: ${{ matrix.os }}
permissions:
contents: read
env:
# macOS signing/notarization is expensive (notary upload + polling) and is
# not needed for PR validation — developers can clear the quarantine
# attribute on unsigned PR artifacts if they need to run them. Gate it to
# main CI runs (pushes to main and v* tags), i.e. skip on pull_request.
MACOS_SIGNING_ENABLED: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12 != '' && github.event_name != 'pull_request' }}
steps:
- uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Publish ChartViewer
run: >
dotnet publish src/EncDotNet.ChartViewer/EncDotNet.ChartViewer.csproj
--configuration Release
--runtime ${{ matrix.rid }}
${{ matrix.rid == 'osx-arm64' && '-p:PublishSingleFile=false' || '' }}
- name: Create macOS .app bundle
if: matrix.rid == 'osx-arm64'
run: |
PUBLISH_DIR="src/EncDotNet.ChartViewer/bin/Release/net10.0/osx-arm64/publish"
APP="EncDotNet.ChartViewer.app"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cp src/EncDotNet.ChartViewer/Info.plist "$APP/Contents/"
cp -a "$PUBLISH_DIR"/. "$APP/Contents/MacOS/"
# Remove debug symbols; they are not needed in the release bundle
# and codesign treats them as unsigned code objects.
find "$APP" -name '*.pdb' -delete
- name: Import signing certificate
if: matrix.rid == 'osx-arm64' && env.MACOS_SIGNING_ENABLED == 'true'
env:
P12_BASE64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12 }}
P12_PASSWORD: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
run: |
echo "$P12_BASE64" | base64 --decode > cert.p12
security create-keychain -p "" build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "" build.keychain
security import cert.p12 -k build.keychain -P "$P12_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: -s -k "" build.keychain
- name: Sign macOS .app bundle
if: matrix.rid == 'osx-arm64' && env.MACOS_SIGNING_ENABLED == 'true'
env:
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
run: |
APP="EncDotNet.ChartViewer.app"
ENTITLEMENTS="src/EncDotNet.ChartViewer/entitlements.plist"
MAIN_EXE="EncDotNet.ChartViewer"
# Sign all subcomponents individually before sealing the bundle.
# Exclude the main executable — it will be signed when we sign
# the bundle itself, which also validates all subcomponents.
find "$APP/Contents/MacOS" -type f ! -name "$MAIN_EXE" | while read -r f; do
if file "$f" | grep -q "Mach-O"; then
codesign --force --options runtime --timestamp \
--entitlements "$ENTITLEMENTS" \
--sign "$APPLE_SIGNING_IDENTITY" "$f"
else
codesign --force --timestamp \
--sign "$APPLE_SIGNING_IDENTITY" "$f"
fi
done
# Sign the bundle (signs main executable and seals everything)
codesign --force --options runtime --timestamp \
--entitlements "$ENTITLEMENTS" \
--sign "$APPLE_SIGNING_IDENTITY" \
"$APP"
- name: Notarize macOS .app bundle
if: matrix.rid == 'osx-arm64' && env.MACOS_SIGNING_ENABLED == 'true'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
run: |
ditto -c -k --keepParent \
EncDotNet.ChartViewer.app \
ChartViewer.zip
xcrun notarytool submit ChartViewer.zip \
--apple-id "$APPLE_ID" \
--team-id "$APPLE_TEAM_ID" \
--password "$APPLE_APP_PASSWORD" \
--wait \
--output-format json | tee notarization-result.json
STATUS=$(python3 -c "import json,sys; print(json.load(sys.stdin)['status'])" < notarization-result.json)
if [ "$STATUS" != "Accepted" ]; then
ID=$(python3 -c "import json,sys; print(json.load(sys.stdin)['id'])" < notarization-result.json)
echo "::error::Notarization failed with status: $STATUS"
xcrun notarytool log "$ID" \
--apple-id "$APPLE_ID" \
--team-id "$APPLE_TEAM_ID" \
--password "$APPLE_APP_PASSWORD"
exit 1
fi
- name: Staple notarization ticket
if: matrix.rid == 'osx-arm64' && env.MACOS_SIGNING_ENABLED == 'true'
continue-on-error: true
run: |
# The notarization ticket may not be immediately available in
# CloudKit. Stapling is optional — Gatekeeper will verify the
# notarization online on first launch if the ticket is absent.
for i in 1 2 3 4 5; do
if xcrun stapler staple EncDotNet.ChartViewer.app; then
exit 0
fi
echo "Staple attempt $i failed, waiting 30s..."
sleep 30
done
echo "::warning::Stapling failed after 5 attempts. The app is still notarized; Gatekeeper will verify online."
- name: Archive macOS .app bundle
if: matrix.rid == 'osx-arm64'
run: tar -czf "${{ matrix.artifact }}.tar.gz" EncDotNet.ChartViewer.app
- name: Archive published app
if: matrix.rid != 'osx-arm64'
shell: bash
run: tar -czf "${{ matrix.artifact }}.tar.gz" -C "src/EncDotNet.ChartViewer/bin/Release/net10.0/${{ matrix.rid }}/publish" .
- name: Upload published app
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}.tar.gz
publish-nuget:
if: startsWith(github.ref, 'refs/tags/v')
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Download NuGet packages
uses: actions/download-artifact@v4
with:
name: nupkgs
path: nupkgs
- name: NuGet login
uses: NuGet/login@v1
id: login
with:
user: ${{ secrets.NUGET_USER }}
- name: Push to NuGet.org
run: dotnet nuget push "nupkgs/*.nupkg" --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json
create-release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [build, publish]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
artifacts/nupkgs/*.nupkg
artifacts/ChartViewer-*/*.tar.gz