-
Notifications
You must be signed in to change notification settings - Fork 1
849 lines (725 loc) · 26.9 KB
/
jstruct-cli.yml
File metadata and controls
849 lines (725 loc) · 26.9 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
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
name: jstruct CLI
on:
push:
branches: [master, main]
paths:
- 'rust/**'
- '.github/workflows/jstruct-cli.yml'
tags:
- 'jstruct-v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches: [master, main]
paths:
- 'rust/**'
- '.github/workflows/jstruct-cli.yml'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
CLI_NAME: jstruct
jobs:
# Build CLI binaries for all platforms
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
artifact: jstruct
# Linux ARM64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
artifact: jstruct
cross: true
# Windows x86_64
- target: x86_64-pc-windows-msvc
os: windows-latest
artifact: jstruct.exe
# Windows ARM64
- target: aarch64-pc-windows-msvc
os: windows-latest
artifact: jstruct.exe
# macOS x86_64 (Intel)
- target: x86_64-apple-darwin
os: macos-latest
artifact: jstruct
# macOS ARM64 (Apple Silicon)
- target: aarch64-apple-darwin
os: macos-latest
artifact: jstruct
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.cross && matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Cache cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-
- name: Build CLI (native)
if: ${{ !matrix.cross }}
working-directory: rust
run: cargo build --release --features cli --target ${{ matrix.target }}
- name: Build CLI (cross)
if: matrix.cross
working-directory: rust
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
run: cargo build --release --features cli --target ${{ matrix.target }}
- name: Upload binary
uses: actions/upload-artifact@v6
with:
name: ${{ env.CLI_NAME }}-${{ matrix.target }}
path: rust/target/${{ matrix.target }}/release/${{ matrix.artifact }}
if-no-files-found: error
# Run CLI tests
test-cli:
name: Test CLI
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Run CLI tests
working-directory: rust
run: cargo test --features cli --test cli_tests
# Smoke test the generated binaries
test-binaries:
name: Test Binary ${{ matrix.target }}
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Native tests (can run directly)
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
artifact: jstruct
- target: x86_64-pc-windows-msvc
os: windows-latest
artifact: jstruct.exe
- target: x86_64-apple-darwin
os: macos-15
artifact: jstruct
- target: aarch64-apple-darwin
os: macos-latest
artifact: jstruct
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Download binary
uses: actions/download-artifact@v7
with:
name: ${{ env.CLI_NAME }}-${{ matrix.target }}
path: bin
- name: Make binary executable (Unix)
if: runner.os != 'Windows'
run: chmod +x bin/${{ matrix.artifact }}
- name: Test --version
run: bin/${{ matrix.artifact }} --version
- name: Test --help
run: bin/${{ matrix.artifact }} --help
- name: Test check --help
run: bin/${{ matrix.artifact }} check --help
- name: Test validate --help
run: bin/${{ matrix.artifact }} validate --help
- name: Test check valid schema
run: bin/${{ matrix.artifact }} check test-assets/schemas/validation/numeric-minimum-with-uses.struct.json
- name: Test check invalid schema (expect exit 1)
shell: bash
run: |
if bin/${{ matrix.artifact }} check test-assets/schemas/invalid/missing-type.struct.json; then
echo "Expected exit code 1 but got 0"
exit 1
fi
- name: Test validate valid instance
shell: bash
run: |
echo '10' | bin/${{ matrix.artifact }} validate -s test-assets/schemas/validation/numeric-minimum-with-uses.struct.json -
- name: Test validate invalid instance (expect exit 1)
shell: bash
run: |
# Use a string where int32 is expected - type mismatch should fail
if echo '"not-a-number"' | bin/${{ matrix.artifact }} validate -s test-assets/schemas/validation/numeric-minimum-with-uses.struct.json -; then
echo "Expected exit code 1 but got 0"
exit 1
fi
- name: Test JSON output format
shell: bash
run: |
OUTPUT=$(bin/${{ matrix.artifact }} check --format json test-assets/schemas/validation/numeric-minimum-with-uses.struct.json)
echo "$OUTPUT" | grep -q '"valid": true' || (echo "JSON output missing valid field"; exit 1)
- name: Test TAP output format
shell: bash
run: |
OUTPUT=$(bin/${{ matrix.artifact }} check --format tap test-assets/schemas/validation/numeric-minimum-with-uses.struct.json)
echo "$OUTPUT" | grep -q '^ok 1' || (echo "TAP output missing ok line"; exit 1)
- name: Test multiple files
run: bin/${{ matrix.artifact }} check test-assets/schemas/validation/numeric-minimum-with-uses.struct.json test-assets/schemas/validation/string-pattern-with-uses.struct.json
- name: Test quiet mode
run: bin/${{ matrix.artifact }} check -q test-assets/schemas/validation/numeric-minimum-with-uses.struct.json
# Create DEB package for Debian/Ubuntu
package-deb:
name: Package DEB
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
include:
- arch: amd64
target: x86_64-unknown-linux-gnu
- arch: arm64
target: aarch64-unknown-linux-gnu
steps:
- uses: actions/checkout@v6
- name: Download binary
uses: actions/download-artifact@v7
with:
name: ${{ env.CLI_NAME }}-${{ matrix.target }}
path: binary
- name: Extract version
id: version
run: |
if [[ "$GITHUB_REF" == refs/tags/jstruct-v* ]]; then
VERSION=${GITHUB_REF#refs/tags/jstruct-v}
else
VERSION="0.1.0-dev"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Create DEB package structure
run: |
mkdir -p pkg/DEBIAN
mkdir -p pkg/usr/bin
mkdir -p pkg/usr/share/doc/jstruct
mkdir -p pkg/usr/share/man/man1
# Copy binary
cp binary/jstruct pkg/usr/bin/
chmod 755 pkg/usr/bin/jstruct
# Create control file
cat > pkg/DEBIAN/control << EOF
Package: jstruct
Version: ${{ steps.version.outputs.VERSION }}
Section: utils
Priority: optional
Architecture: ${{ matrix.arch }}
Maintainer: JSON Structure Contributors <info@json-structure.org>
Homepage: https://json-structure.org
Description: JSON Structure schema validation CLI
A command-line tool for validating JSON Structure schemas and
validating JSON instances against JSON Structure schemas.
.
Features:
- Schema validation against the JSON Structure meta-schema
- Instance validation against user schemas
- Multiple output formats: text, JSON, TAP
EOF
# Create copyright file
cat > pkg/usr/share/doc/jstruct/copyright << EOF
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: jstruct
Source: https://github.com/json-structure/sdk
Files: *
Copyright: 2024 JSON Structure Contributors
License: MIT
EOF
# Build package
dpkg-deb --build pkg jstruct_${{ steps.version.outputs.VERSION }}_${{ matrix.arch }}.deb
- name: Upload DEB package
uses: actions/upload-artifact@v6
with:
name: jstruct-deb-${{ matrix.arch }}
path: "*.deb"
# Create RPM package for Fedora/RHEL
package-rpm:
name: Package RPM
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
arch: [x86_64, aarch64]
include:
- arch: x86_64
target: x86_64-unknown-linux-gnu
- arch: aarch64
target: aarch64-unknown-linux-gnu
steps:
- uses: actions/checkout@v6
- name: Download binary
uses: actions/download-artifact@v7
with:
name: ${{ env.CLI_NAME }}-${{ matrix.target }}
path: binary
- name: Install RPM tools
run: sudo apt-get update && sudo apt-get install -y rpm
- name: Extract version
id: version
run: |
if [[ "$GITHUB_REF" == refs/tags/jstruct-v* ]]; then
VERSION=${GITHUB_REF#refs/tags/jstruct-v}
else
VERSION="0.1.0"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Create RPM package
run: |
mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
mkdir -p rpmbuild/BUILDROOT/jstruct-${{ steps.version.outputs.VERSION }}-1.${{ matrix.arch }}/usr/bin
# Copy binary
cp binary/jstruct rpmbuild/BUILDROOT/jstruct-${{ steps.version.outputs.VERSION }}-1.${{ matrix.arch }}/usr/bin/
chmod 755 rpmbuild/BUILDROOT/jstruct-${{ steps.version.outputs.VERSION }}-1.${{ matrix.arch }}/usr/bin/jstruct
# Create spec file
cat > rpmbuild/SPECS/jstruct.spec << 'EOF'
Name: jstruct
Version: ${{ steps.version.outputs.VERSION }}
Release: 1
Summary: JSON Structure schema validation CLI
License: MIT
URL: https://json-structure.org
%description
A command-line tool for validating JSON Structure schemas and
validating JSON instances against JSON Structure schemas.
Features:
- Schema validation against the JSON Structure meta-schema
- Instance validation against user schemas
- Multiple output formats: text, JSON, TAP
%files
%attr(755, root, root) /usr/bin/jstruct
EOF
# Build RPM
rpmbuild --define "_topdir $(pwd)/rpmbuild" \
--define "_rpmdir $(pwd)" \
--target ${{ matrix.arch }} \
-bb rpmbuild/SPECS/jstruct.spec
- name: Upload RPM package
uses: actions/upload-artifact@v6
with:
name: jstruct-rpm-${{ matrix.arch }}
path: "**/*.rpm"
# Create MSIX package for Windows
package-msix:
name: Package MSIX
needs: build
runs-on: windows-latest
strategy:
matrix:
arch: [x64, arm64]
include:
- arch: x64
target: x86_64-pc-windows-msvc
- arch: arm64
target: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@v6
- name: Download binary
uses: actions/download-artifact@v7
with:
name: ${{ env.CLI_NAME }}-${{ matrix.target }}
path: binary
- name: Extract version
id: version
shell: pwsh
run: |
if ($env:GITHUB_REF -match 'refs/tags/jstruct-v(.+)') {
$version = $matches[1]
} else {
$version = "0.1.0.0"
}
# Ensure 4-part version for MSIX
$parts = $version -split '\.'
while ($parts.Count -lt 4) { $parts += "0" }
$version = ($parts[0..3] -join '.')
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
- name: Create MSIX package structure
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path msix
Copy-Item binary/jstruct.exe msix/
# Create AppxManifest.xml
@"
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
IgnorableNamespaces="uap uap3 desktop">
<Identity
Name="JSONStructure.jstruct"
Publisher="CN=JSON Structure Contributors"
Version="${{ steps.version.outputs.VERSION }}"
ProcessorArchitecture="${{ matrix.arch }}" />
<Properties>
<DisplayName>jstruct</DisplayName>
<PublisherDisplayName>JSON Structure Contributors</PublisherDisplayName>
<Description>JSON Structure schema validation CLI</Description>
<Logo>assets\logo.png</Logo>
</Properties>
<Resources>
<Resource Language="en-us" />
</Resources>
<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.22621.0" />
</Dependencies>
<Applications>
<Application Id="jstruct" Executable="jstruct.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements
DisplayName="jstruct"
Description="JSON Structure CLI"
BackgroundColor="transparent"
Square150x150Logo="assets\logo.png"
Square44x44Logo="assets\logo.png">
</uap:VisualElements>
<Extensions>
<uap3:Extension Category="windows.appExecutionAlias">
<uap3:AppExecutionAlias>
<desktop:ExecutionAlias Alias="jstruct.exe" />
</uap3:AppExecutionAlias>
</uap3:Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" />
</Capabilities>
</Package>
"@ | Out-File -Encoding utf8 msix/AppxManifest.xml
# Create placeholder logo (44x44 and 150x150 PNG required)
New-Item -ItemType Directory -Force -Path msix/assets
# Create a simple placeholder PNG using PowerShell
Add-Type -AssemblyName System.Drawing
$bmp = New-Object System.Drawing.Bitmap(150, 150)
$graphics = [System.Drawing.Graphics]::FromImage($bmp)
$graphics.Clear([System.Drawing.Color]::FromArgb(0, 120, 212))
$font = New-Object System.Drawing.Font("Arial", 48, [System.Drawing.FontStyle]::Bold)
$brush = [System.Drawing.Brushes]::White
$graphics.DrawString("JS", $font, $brush, 30, 40)
$bmp.Save("msix/assets/logo.png", [System.Drawing.Imaging.ImageFormat]::Png)
$graphics.Dispose()
$bmp.Dispose()
- name: Create MSIX package
shell: pwsh
run: |
# Use makeappx to create the package
$sdkPath = Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\makeappx.exe" |
Sort-Object { [version]($_.Directory.Parent.Name) } -Descending |
Select-Object -First 1
if (-not $sdkPath) {
Write-Error "makeappx.exe not found"
exit 1
}
& $sdkPath.FullName pack /d msix /p jstruct-${{ steps.version.outputs.VERSION }}-${{ matrix.arch }}.msix /o
- name: Upload MSIX package
uses: actions/upload-artifact@v6
with:
name: jstruct-msix-${{ matrix.arch }}
path: "*.msix"
# Create macOS packages (DMG with signed binary, and pkg installer)
package-macos:
name: Package macOS
needs: build
runs-on: macos-latest
strategy:
matrix:
arch: [x86_64, arm64]
include:
- arch: x86_64
target: x86_64-apple-darwin
- arch: arm64
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v6
- name: Download binary
uses: actions/download-artifact@v7
with:
name: ${{ env.CLI_NAME }}-${{ matrix.target }}
path: binary
- name: Extract version
id: version
run: |
if [[ "$GITHUB_REF" == refs/tags/jstruct-v* ]]; then
VERSION=${GITHUB_REF#refs/tags/jstruct-v}
else
VERSION="0.1.0"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Create PKG installer
run: |
chmod +x binary/jstruct
# Create pkg structure
mkdir -p pkg-root/usr/local/bin
cp binary/jstruct pkg-root/usr/local/bin/
# Create component plist
cat > component.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>BundleHasStrictIdentifier</key>
<false/>
<key>BundleIsRelocatable</key>
<false/>
<key>BundleIsVersionChecked</key>
<false/>
<key>BundleOverwriteAction</key>
<string>upgrade</string>
<key>RootRelativeBundlePath</key>
<string>usr/local/bin/jstruct</string>
</dict>
</array>
</plist>
EOF
# Build pkg
pkgbuild --root pkg-root \
--identifier org.json-structure.jstruct \
--version ${{ steps.version.outputs.VERSION }} \
--install-location / \
jstruct-${{ steps.version.outputs.VERSION }}-${{ matrix.arch }}.pkg
- name: Create tarball
run: |
mkdir -p dist
cp binary/jstruct dist/
chmod +x dist/jstruct
tar -czvf jstruct-${{ steps.version.outputs.VERSION }}-darwin-${{ matrix.arch }}.tar.gz -C dist jstruct
- name: Upload PKG
uses: actions/upload-artifact@v6
with:
name: jstruct-pkg-${{ matrix.arch }}
path: "*.pkg"
- name: Upload tarball
uses: actions/upload-artifact@v6
with:
name: jstruct-tarball-darwin-${{ matrix.arch }}
path: "*.tar.gz"
# Create universal macOS binary
package-macos-universal:
name: Package macOS Universal
needs: build
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
- name: Download x86_64 binary
uses: actions/download-artifact@v7
with:
name: ${{ env.CLI_NAME }}-x86_64-apple-darwin
path: binary-x86_64
- name: Download ARM64 binary
uses: actions/download-artifact@v7
with:
name: ${{ env.CLI_NAME }}-aarch64-apple-darwin
path: binary-arm64
- name: Extract version
id: version
run: |
if [[ "$GITHUB_REF" == refs/tags/jstruct-v* ]]; then
VERSION=${GITHUB_REF#refs/tags/jstruct-v}
else
VERSION="0.1.0"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Create universal binary
run: |
chmod +x binary-x86_64/jstruct binary-arm64/jstruct
lipo -create -output jstruct binary-x86_64/jstruct binary-arm64/jstruct
chmod +x jstruct
# Verify it's universal
file jstruct
- name: Create universal PKG
run: |
mkdir -p pkg-root/usr/local/bin
cp jstruct pkg-root/usr/local/bin/
pkgbuild --root pkg-root \
--identifier org.json-structure.jstruct \
--version ${{ steps.version.outputs.VERSION }} \
--install-location / \
jstruct-${{ steps.version.outputs.VERSION }}-darwin-universal.pkg
- name: Create universal tarball
run: |
tar -czvf jstruct-${{ steps.version.outputs.VERSION }}-darwin-universal.tar.gz jstruct
- name: Upload universal PKG
uses: actions/upload-artifact@v6
with:
name: jstruct-pkg-universal
path: "*.pkg"
- name: Upload universal tarball
uses: actions/upload-artifact@v6
with:
name: jstruct-tarball-darwin-universal
path: "*.tar.gz"
# Create Linux tarballs
package-linux-tarball:
name: Package Linux tarball
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
arch: [x86_64, aarch64]
include:
- arch: x86_64
target: x86_64-unknown-linux-gnu
- arch: aarch64
target: aarch64-unknown-linux-gnu
steps:
- uses: actions/checkout@v6
- name: Download binary
uses: actions/download-artifact@v7
with:
name: ${{ env.CLI_NAME }}-${{ matrix.target }}
path: binary
- name: Extract version
id: version
run: |
if [[ "$GITHUB_REF" == refs/tags/jstruct-v* ]]; then
VERSION=${GITHUB_REF#refs/tags/jstruct-v}
else
VERSION="0.1.0"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Create tarball
run: |
chmod +x binary/jstruct
mkdir -p dist
cp binary/jstruct dist/
tar -czvf jstruct-${{ steps.version.outputs.VERSION }}-linux-${{ matrix.arch }}.tar.gz -C dist jstruct
- name: Upload tarball
uses: actions/upload-artifact@v6
with:
name: jstruct-tarball-linux-${{ matrix.arch }}
path: "*.tar.gz"
# Create Windows ZIP
package-windows-zip:
name: Package Windows ZIP
needs: build
runs-on: windows-latest
strategy:
matrix:
arch: [x64, arm64]
include:
- arch: x64
target: x86_64-pc-windows-msvc
- arch: arm64
target: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@v6
- name: Download binary
uses: actions/download-artifact@v7
with:
name: ${{ env.CLI_NAME }}-${{ matrix.target }}
path: binary
- name: Extract version
id: version
shell: pwsh
run: |
if ($env:GITHUB_REF -match 'refs/tags/jstruct-v(.+)') {
$version = $matches[1]
} else {
$version = "0.1.0"
}
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
- name: Create ZIP
shell: pwsh
run: |
Compress-Archive -Path binary/jstruct.exe -DestinationPath jstruct-${{ steps.version.outputs.VERSION }}-windows-${{ matrix.arch }}.zip
- name: Upload ZIP
uses: actions/upload-artifact@v6
with:
name: jstruct-zip-windows-${{ matrix.arch }}
path: "*.zip"
# Create GitHub Release with all artifacts
release:
name: Create Release
needs:
- test-cli
- test-binaries
- package-deb
- package-rpm
- package-msix
- package-macos
- package-macos-universal
- package-linux-tarball
- package-windows-zip
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/jstruct-v')
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: artifacts
- name: Extract version
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/jstruct-v}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Prepare release assets
run: |
mkdir -p release
# Collect all packages
find artifacts -type f \( -name "*.deb" -o -name "*.rpm" -o -name "*.msix" -o -name "*.pkg" -o -name "*.tar.gz" -o -name "*.zip" \) -exec cp {} release/ \;
# Generate checksums
cd release
sha256sum * > SHA256SUMS.txt
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: jstruct v${{ steps.version.outputs.VERSION }}
body: |
## jstruct CLI v${{ steps.version.outputs.VERSION }}
JSON Structure schema validation command-line tool.
### Installation
#### Linux (Debian/Ubuntu)
```bash
sudo dpkg -i jstruct_${{ steps.version.outputs.VERSION }}_amd64.deb
```
#### Linux (Fedora/RHEL)
```bash
sudo rpm -i jstruct-${{ steps.version.outputs.VERSION }}-1.x86_64.rpm
```
#### macOS
```bash
# Universal binary (Intel + Apple Silicon)
sudo installer -pkg jstruct-${{ steps.version.outputs.VERSION }}-darwin-universal.pkg -target /
# Or via tarball
tar xzf jstruct-${{ steps.version.outputs.VERSION }}-darwin-universal.tar.gz
sudo mv jstruct /usr/local/bin/
```
#### Windows
Download and extract the ZIP, or install the MSIX package.
### Usage
```bash
# Validate a schema
jstruct check schema.json
# Validate an instance against a schema
jstruct validate --schema schema.json data.json
```
See `jstruct --help` for more options.
files: release/*
draft: false
prerelease: false