Repository navigation
289 lines (253 loc) · 8.92 KB
/
Copy pathpublish-cli.yml
File metadata and controls
289 lines (253 loc) · 8.92 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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
name: Publish Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: read
jobs:
build-native:
name: Build ${{ matrix.rid }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
# Keep both Linux builds on glibc 2.35; newer runners can require a newer glibc.
- rid: linux-x64
os: ubuntu-22.04
binary: clippit
native_lib: libSkiaSharp.so
- rid: linux-arm64
os: ubuntu-22.04-arm
binary: clippit
native_lib: libSkiaSharp.so
- rid: win-x64
os: windows-latest
binary: clippit.exe
native_lib: libSkiaSharp.dll
- rid: win-arm64
os: windows-11-arm
binary: clippit.exe
native_lib: libSkiaSharp.dll
- rid: osx-x64
os: macos-15-intel
binary: clippit
native_lib: libSkiaSharp.dylib
- rid: osx-arm64
os: macos-15
binary: clippit
native_lib: libSkiaSharp.dylib
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup .NET SDK
uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
- name: Install Linux NativeAOT toolchain
if: startsWith(matrix.rid, 'linux-')
run: sudo apt-get update && sudo apt-get install -y clang zlib1g-dev
- name: Select Apple Clang for NativeAOT
if: startsWith(matrix.rid, 'osx-')
run: |
echo "CppCompilerAndLinker=/usr/bin/clang" >> "$GITHUB_ENV"
xcode-select -p
xcodebuild -version
echo "PATH clang:"
command -v clang
clang --version
echo "Pinned Apple clang:"
/usr/bin/clang --version
# Xcode 16's classic linker rejects an unaligned pointer in the x64 GSSAPI archive.
- name: Use modern Xcode linker for osx-x64 NativeAOT
if: matrix.rid == 'osx-x64'
run: echo "UseLdClassicXCodeLinker=false" >> "$GITHUB_ENV"
- name: Publish NativeAOT binary
run: dotnet publish Clippit.Cli/Clippit.Cli.csproj -f net11.0 -c Release -r ${{ matrix.rid }} --self-contained -p:NativeAot=true -o bin/cli/${{ matrix.rid }}
- name: Upload NativeAOT binary
uses: actions/upload-artifact@v7
with:
name: clippit-${{ matrix.rid }}
path: |
bin/cli/${{ matrix.rid }}/${{ matrix.binary }}
bin/cli/${{ matrix.rid }}/${{ matrix.native_lib }}
if-no-files-found: error
- name: Pack RID-specific dotnet tool
run: dotnet pack Clippit.Cli/Clippit.Cli.csproj -c Release -r ${{ matrix.rid }} -p:NativeAot=true -o bin/tool
- name: Upload RID-specific dotnet tool
uses: actions/upload-artifact@v7
with:
name: clippit-tool-${{ matrix.rid }}
path: bin/tool/Clippit.Cli.${{ matrix.rid }}.*.nupkg
if-no-files-found: error
build-and-pack:
name: Build, Test, and Pack NuGet Packages
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup .NET SDK
uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
- name: Build and Pack
run: dotnet fsi build.fsx -- -p build
- name: Upload NuGet packages and release title
uses: actions/upload-artifact@v7
with:
name: nuget-packages
path: |
bin/*.nupkg
bin/RELEASE_TITLE
if-no-files-found: error
publish-npm:
name: Pack and Publish npm Packages
runs-on: ubuntu-latest
needs: [build-native, build-and-pack]
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup .NET SDK
uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '24'
registry-url: https://registry.npmjs.org
package-manager-cache: false
- name: Update npm for Trusted Publishing
run: npm install --global npm@latest && npm --version
- name: Download linux-x64 binary
uses: actions/download-artifact@v8
with:
name: clippit-linux-x64
path: bin/cli/linux-x64
- name: Download linux-arm64 binary
uses: actions/download-artifact@v8
with:
name: clippit-linux-arm64
path: bin/cli/linux-arm64
- name: Download win-x64 binary
uses: actions/download-artifact@v8
with:
name: clippit-win-x64
path: bin/cli/win-x64
- name: Download win-arm64 binary
uses: actions/download-artifact@v8
with:
name: clippit-win-arm64
path: bin/cli/win-arm64
- name: Download osx-x64 binary
uses: actions/download-artifact@v8
with:
name: clippit-osx-x64
path: bin/cli/osx-x64
- name: Download osx-arm64 binary
uses: actions/download-artifact@v8
with:
name: clippit-osx-arm64
path: bin/cli/osx-arm64
- name: Pack npm packages
run: dotnet fsi build.fsx -- -p pack-npm
env:
CLIPPIT_PUBLISH_RIDS: win-x64,win-arm64,osx-x64,osx-arm64,linux-x64,linux-arm64
- name: Upload npm tarballs
uses: actions/upload-artifact@v7
with:
name: clippit-npm-packages
path: bin/npm/*.tgz
if-no-files-found: error
- name: Publish npm packages
run: |
publish_if_missing() {
local tarball="$1"
local metadata name version spec error_file
metadata="$(tar -xOzf "$tarball" package/package.json)"
name="$(node -p 'JSON.parse(process.argv[1]).name' "$metadata")"
version="$(node -p 'JSON.parse(process.argv[1]).version' "$metadata")"
spec="${name}@${version}"
error_file="$(mktemp)"
if npm view "$spec" version >/dev/null 2>"$error_file"; then
echo "$spec is already published; skipping"
rm -f "$error_file"
return 0
fi
if ! grep -Fq 'E404' "$error_file"; then
cat "$error_file" >&2
rm -f "$error_file"
return 1
fi
if npm publish "$tarball" --access public; then
rm -f "$error_file"
return 0
fi
if npm view "$spec" version >/dev/null 2>"$error_file"; then
echo "$spec appeared during publish; treating it as complete"
rm -f "$error_file"
return 0
fi
cat "$error_file" >&2
rm -f "$error_file"
return 1
}
for tarball in \
bin/npm/sergey-tihon-clippit-bin-win32-x64-*.tgz \
bin/npm/sergey-tihon-clippit-bin-darwin-x64-*.tgz \
bin/npm/sergey-tihon-clippit-bin-darwin-arm64-*.tgz \
bin/npm/sergey-tihon-clippit-bin-linux-x64-*.tgz \
bin/npm/sergey-tihon-clippit-bin-linux-arm64-*.tgz \
bin/npm/sergey-tihon-clippit-bin-win32-arm64-*.tgz \
bin/npm/clippit-[0-9]*.tgz; do
publish_if_missing "$tarball"
done
publish:
needs: [build-native, build-and-pack, publish-npm]
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Download NuGet packages and release title
uses: actions/download-artifact@v8
with:
name: nuget-packages
path: bin
- name: Download RID-specific dotnet tool packages
uses: actions/download-artifact@v8
with:
pattern: clippit-tool-*
path: bin
merge-multiple: true
- name: NuGet login (OIDC → temp API key)
uses: NuGet/login@v1
id: login
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish to NuGet
run: |
for rid in win-x64 win-arm64 osx-x64 osx-arm64 linux-x64 linux-arm64 any; do
dotnet nuget push bin/Clippit.Cli.$rid.*.nupkg --api-key ${{ steps.login.outputs.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json --skip-duplicate
done
dotnet nuget push "bin/*.nupkg" --api-key ${{ steps.login.outputs.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ github.ref_name }}" \
--title "$(cat bin/RELEASE_TITLE)" \
--generate-notes