forked from ipaddress-gem/ipaddress
-
Notifications
You must be signed in to change notification settings - Fork 5
462 lines (409 loc) · 14.4 KB
/
Copy pathbuild.yaml
File metadata and controls
462 lines (409 loc) · 14.4 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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: build
on:
push:
# branches:
# - main
jobs:
cpp:
runs-on: ['ubuntu-latest']
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: boost
run: sudo apt-get update && sudo apt-get install -yq libboost-all-dev
- name: "build cpp"
run: |
cd cpp && echo "build cpp"
# Pinned explicitly: clang-format's formatting output differs
# between major versions (e.g. reference/pointer spacing in
# `operator<<` signatures changed between 16/17 and 18), and
# the unversioned `clang-format` alias on this runner image is
# ambiguous between the 16/17/18 it has installed.
find src test -type f \( -name "*.cpp" -o -name "*.hpp" -o -name "*.h" \) -print0 | xargs -0 clang-format-18 --dry-run --Werror
cmake -DCMAKE_BUILD_TYPE=Release .
make
for i in ./test/Release/*/test_*
do
echo $i
$i
done
cs:
runs-on: ['ubuntu-latest']
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: "build cs"
run: |
cd cs/ipaddress && echo "build cs"
dotnet restore
dotnet format ipaddress.csproj --verify-no-changes
dotnet format test/ipaddress.Tests.csproj --verify-no-changes
dotnet build
dotnet test test/ipaddress.Tests.csproj
dotnet build -c Release
- name: resolve publish version
# A cs@vX.Y.Z tag publishes just this package; a plain vX.Y.Z tag
# (no "@") publishes every language at once with the same version.
id: version
run: |
REF="${GITHUB_REF}"
if [[ "$REF" == refs/tags/cs@v* ]]; then
echo "should_publish=true" >> "$GITHUB_OUTPUT"
echo "version=${REF#refs/tags/cs@v}" >> "$GITHUB_OUTPUT"
elif [[ "$REF" == refs/tags/v* && "$REF" != *@* ]]; then
echo "should_publish=true" >> "$GITHUB_OUTPUT"
echo "version=${REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
else
echo "should_publish=false" >> "$GITHUB_OUTPUT"
fi
- name: set version from tag
if: steps.version.outputs.should_publish == 'true'
working-directory: cs/ipaddress
run: |
version="${{ steps.version.outputs.version }}"
echo "publishing version $version"
sed -i "s|<Version>.*</Version>|<Version>$version</Version>|" ipaddress.csproj
grep '<Version>' ipaddress.csproj
- name: pack
working-directory: cs/ipaddress
run: dotnet pack ipaddress.csproj -c Release -o nupkg
- name: NuGet login (OIDC -> temp API key)
# Trusted Publishing - no long-lived secret needed, just the
# nuget.org username for this OIDC exchange. Requires the
# com.adviser.ipaddress package on nuget.org to have this
# repo+workflow registered as a trusted publisher beforehand.
if: steps.version.outputs.should_publish == 'true'
id: nuget-login
uses: NuGet/login@v1
with:
user: ${{ secrets.NUGET_USER }}
- name: publish
if: steps.version.outputs.should_publish == 'true'
working-directory: cs/ipaddress
run: dotnet nuget push "nupkg/*.nupkg" --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json
dart:
runs-on: ['ubuntu-latest']
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: dart-lang/setup-dart@v1
- name: "build dart"
run: |
cd dart/ipaddress && echo "build dart"
dart pub get
dart format --output=none --set-exit-if-changed .
dart test
dart-publish:
needs: dart
# pub.dev's automated-publishing tag pattern is a single fixed
# pattern (configured on pub.dev as "v{{version}}") with no OR
# logic, so - unlike the other languages - there's no separate
# dart@vX.Y.Z single-package tag: this only fires from the plain
# vX.Y.Z "publish everything" tag. Also unlike the other
# languages, pub.dev requires pubspec.yaml's version to already
# match the tag before it's pushed (no version injection at
# publish time), so bump dart/ipaddress/pubspec.yaml yourself
# before tagging a release.
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '@')
permissions:
id-token: write
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
with:
working-directory: dart/ipaddress
go:
runs-on: ['ubuntu-latest']
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: "build go"
run: |
cd go/ipaddress && echo "build go"
go version
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "gofmt found unformatted files:"
echo "$unformatted"
exit 1
fi
go test -v
java:
runs-on: ['ubuntu-latest']
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: "build java"
run: |
cd java && echo "build java"
mvn test -B -Dmaven.javadoc.skip=true
js:
runs-on: ['ubuntu-latest']
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: "build js"
run: |
cd js && echo "build js"
npm install
npx prettier . --check
npm run build
npm run test
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: "verify js on deno"
working-directory: js
run: |
deno check --unstable-sloppy-imports src/index.ts test/*.ts
deno run -A npm:vitest run
- name: resolve publish version
# A js@vX.Y.Z tag publishes just this package; a plain vX.Y.Z tag
# (no "@") publishes every language at once with the same version.
id: version
run: |
REF="${GITHUB_REF}"
if [[ "$REF" == refs/tags/js@v* ]]; then
echo "should_publish=true" >> "$GITHUB_OUTPUT"
echo "version=${REF#refs/tags/js@v}" >> "$GITHUB_OUTPUT"
elif [[ "$REF" == refs/tags/v* && "$REF" != *@* ]]; then
echo "should_publish=true" >> "$GITHUB_OUTPUT"
echo "version=${REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
else
echo "should_publish=false" >> "$GITHUB_OUTPUT"
fi
- name: publish
# npm Trusted Publishing (OIDC) - no NPM_TOKEN secret needed.
# Requires the npm package to have this repo+workflow registered
# as a "Trusted Publisher" on npmjs.com beforehand.
if: steps.version.outputs.should_publish == 'true'
working-directory: js
run: |
npm install -g npm@latest
npm --version
npm version "${{ steps.version.outputs.version }}"
grep version package.json
npm publish --access public --provenance
- name: dry-publish
if: steps.version.outputs.should_publish != 'true'
working-directory: js
run: |
npm version 0.0.0-snap
grep version package.json
npm publish --access public --dry-run --tag snapshot
jsr:
needs: js
runs-on: ['ubuntu-latest']
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: resolve publish version
# A js@vX.Y.Z tag publishes just this package; a plain vX.Y.Z tag
# (no "@") publishes every language at once with the same version.
id: version
run: |
REF="${GITHUB_REF}"
if [[ "$REF" == refs/tags/js@v* ]]; then
echo "should_publish=true" >> "$GITHUB_OUTPUT"
echo "version=${REF#refs/tags/js@v}" >> "$GITHUB_OUTPUT"
elif [[ "$REF" == refs/tags/v* && "$REF" != *@* ]]; then
echo "should_publish=true" >> "$GITHUB_OUTPUT"
echo "version=${REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
else
echo "should_publish=false" >> "$GITHUB_OUTPUT"
fi
- name: publish
# JSR OIDC publishing - no token needed. Requires @mabels/ipaddress
# on jsr.io to have "Publishing from GitHub Actions" linked to this
# repo+workflow beforehand.
if: steps.version.outputs.should_publish == 'true'
working-directory: js
run: |
version="${{ steps.version.outputs.version }}"
echo "publishing jsr version $version"
sed -i "s/\"version\": \".*\"/\"version\": \"$version\"/" jsr.json
cat jsr.json
npx -y jsr publish --allow-slow-types --allow-dirty
- name: dry-publish
if: steps.version.outputs.should_publish != 'true'
working-directory: js
run: |
npx -y jsr publish --allow-slow-types --dry-run --allow-dirty
kotlin:
runs-on: ['ubuntu-latest']
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: fwilhe2/setup-kotlin@main
- name: "build kotlin"
run: |
cd kotlin && echo "build kotlin"
./gradlew ktlintCheck
./gradlew build
./gradlew test
python:
runs-on: ['ubuntu-latest']
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: "build python"
run: |
cd python && echo "build python"
python -m pip install --upgrade pip build
pip install -e ".[dev]"
black --check --diff src tests
pytest -q
- name: resolve publish version
# A python@vX.Y.Z tag publishes just this package; a plain
# vX.Y.Z tag (no "@") publishes every language at once with the
# same version.
id: version
run: |
REF="${GITHUB_REF}"
if [[ "$REF" == refs/tags/python@v* ]]; then
echo "should_publish=true" >> "$GITHUB_OUTPUT"
echo "version=${REF#refs/tags/python@v}" >> "$GITHUB_OUTPUT"
elif [[ "$REF" == refs/tags/v* && "$REF" != *@* ]]; then
echo "should_publish=true" >> "$GITHUB_OUTPUT"
echo "version=${REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
else
echo "should_publish=false" >> "$GITHUB_OUTPUT"
fi
- name: set version from tag
if: steps.version.outputs.should_publish == 'true'
working-directory: python
run: |
version="${{ steps.version.outputs.version }}"
echo "publishing version $version"
sed -i "s/^version = .*/version = \"$version\"/" pyproject.toml
grep '^version' pyproject.toml
- name: build dist
working-directory: python
run: python -m build
- name: publish
# PyPI Trusted Publishing (OIDC) - no token needed. Requires the
# mabels-ipaddress project on pypi.org to have this repo+workflow+job
# registered as a "trusted publisher" beforehand.
if: steps.version.outputs.should_publish == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: python/dist
- name: dry-publish check
if: steps.version.outputs.should_publish != 'true'
working-directory: python
run: |
python -m pip install --upgrade twine
twine check dist/*
ruby:
runs-on: ['ubuntu-latest']
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
- name: "build ruby"
run: |
cd ruby && echo "build ruby"
gem install jeweler
gem install test-unit
gem install standard
standardrb --no-fix lib test
rake test
rust:
runs-on: ['ubuntu-latest']
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: "build rust"
run: |
cd rust && echo "build rust"
cargo fmt --check
cargo test --release
- name: resolve publish version
# A rust@vX.Y.Z tag publishes just this package; a plain vX.Y.Z
# tag (no "@") publishes every language at once with the same
# version.
id: version
run: |
REF="${GITHUB_REF}"
if [[ "$REF" == refs/tags/rust@v* ]]; then
echo "should_publish=true" >> "$GITHUB_OUTPUT"
echo "version=${REF#refs/tags/rust@v}" >> "$GITHUB_OUTPUT"
elif [[ "$REF" == refs/tags/v* && "$REF" != *@* ]]; then
echo "should_publish=true" >> "$GITHUB_OUTPUT"
echo "version=${REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
else
echo "should_publish=false" >> "$GITHUB_OUTPUT"
fi
- name: set version from tag
if: steps.version.outputs.should_publish == 'true'
working-directory: rust
run: |
version="${{ steps.version.outputs.version }}"
echo "publishing version $version"
sed -i "s/^version = .*/version = \"$version\"/" Cargo.toml
grep '^version' Cargo.toml
- name: crates.io auth
# Trusted Publishing (OIDC) - no token secret needed. Requires
# the ipaddress crate on crates.io to have this repo+workflow
# registered as a trusted publisher beforehand.
if: steps.version.outputs.should_publish == 'true'
id: crates-io-auth
uses: rust-lang/crates-io-auth-action@v1
- name: publish
if: steps.version.outputs.should_publish == 'true'
working-directory: rust
env:
CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }}
run: cargo publish --allow-dirty
- name: dry-publish
if: steps.version.outputs.should_publish != 'true'
working-directory: rust
run: cargo publish --dry-run --allow-dirty
swift:
runs-on: ['ubuntu-latest']
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: "build swift"
run: |
cd swift && echo "build swift"
# swift-format's "lint" rules also enforce lowerCamelCase naming,
# which conflicts with this project's intentionally identical
# (non-camelCase) method names across every language port. Only
# check that format(-i) is a no-op, i.e. whitespace/style only.
swift format format -i -r Sources Tests Package.swift
git diff --exit-code -- Sources Tests Package.swift
swift build
swift test