aam-rs 2.0.2

A Rust implementation of the Abstract Alias Mapping (AAM) framework for aliasing and maping aam files.
Documentation
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
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
name: Release & Publish

on:
  push:
    branches:
      - main

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: write
  pull-requests: write
  id-token: write
  attestations: write
  packages: write

jobs:
  generate-credits:
    name: Generate Licenses (CREDITS)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Install cargo-binstall
        uses: cargo-bins/cargo-binstall@main
      - name: Install cargo-about
        run: cargo binstall cargo-about -y
      - name: Generate CREDITS.html
        run: cargo about generate about.hbs > CREDITS.html
      - name: Upload CREDITS
        uses: actions/upload-artifact@v7
        with:
          name: credits-html
          path: CREDITS.html
          retention-days: 1

  validate:
    name: Tests, Formatting & Security
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - name: Setup Rust cache
        uses: Swatinem/rust-cache@v2
      - name: Check formatting
        run: cargo fmt --all -- --check
      - name: Run tests
        run: |
          cargo test --all-targets
          cargo test --all-targets --features serde
          cargo test --all-targets --features aot
      - name: Security audit (cargo-deny)
        uses: EmbarkStudios/cargo-deny-action@v2
        with:
          command: check bans licenses

  validate-go:
    name: Go Bindings — Build & Test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Setup Rust cache
        uses: Swatinem/rust-cache@v2
      - name: Build Rust library with FFI
        run: cargo build --release --features ffi
      - name: Set up Go
        uses: actions/setup-go@v6
        with:
          go-version: "stable"
          cache-dependency-path: go/go.sum
      - name: Test Go bindings
        working-directory: ./go
        run: go test -v ./...
        env:
          LD_LIBRARY_PATH: ${{ github.workspace }}/target/release

  validate-js:
    name: Node.js Bindings — Build & Test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Setup Rust cache
        uses: Swatinem/rust-cache@v2
      - name: Set up Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 22
      - name: Install Node.js dependencies
        working-directory: ./js
        run: npm install
      - name: Build Node.js bindings
        working-directory: ./js
        run: npm run build
      - name: Run Node.js tests
        working-directory: ./js
        run: npm test

  validate-csharp:
    name: C# Bindings — Build & Test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Setup Rust cache
        uses: Swatinem/rust-cache@v2
      - name: Build Rust library with FFI
        run: cargo build --release --features ffi,csharp
      - name: Setup .NET
        uses: actions/setup-dotnet@v5
        with:
          dotnet-version: "10.0.x"
      - name: Restore C# dependencies
        working-directory: ./csharp
        run: dotnet restore AamCsharp.sln
      - name: Build C# project
        working-directory: ./csharp
        run: dotnet build AamCsharp.sln --configuration Release --no-restore
      - name: Run C# tests
        working-directory: ./csharp/
        run: dotnet test AamCsharp.sln --configuration Release --no-build -v normal
        env:
          LD_LIBRARY_PATH: ${{ github.workspace }}/target/release

  validate-wasm:
    name: WASM Bindings - Build & Test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: wasm32-unknown-unknown
      - name: Install wasm-pack
        run: cargo install wasm-pack --locked
      - name: Build WASM package
        working-directory: ./wasm
        run: wasm-pack build --release --target nodejs --out-dir pkg
      - name: Run WASM tests
        working-directory: ./wasm
        run: |
          cargo test
          wasm-pack test --node

  validate-ruby:
    name: Ruby Bindings - Build & Test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.3"
      - name: Build Ruby extension
        run: cargo build --manifest-path ruby/ext/aam_rs/Cargo.toml --release
        env:
          CARGO_NET_GIT_FETCH_WITH_CLI: "true"
      - name: Run Rust tests for Ruby extension
        run: cargo test --manifest-path ruby/ext/aam_rs/Cargo.toml
      - name: Fix Ruby Extension Naming (Patching)
        run: |
          # Убираем системный префикс lib, чтобы Ruby нашел точку входа Init_aam_ruby
          mv ruby/ext/aam_rs/target/release/libaam_ruby.so ruby/ext/aam_rs/target/release/aam_ruby.so 2>/dev/null || true
          mv ruby/ext/aam_rs/target/release/libaam_rs_ruby.so ruby/ext/aam_rs/target/release/aam_rs_ruby.so 2>/dev/null || true
          # Патчим импорт в рубишном файле на лету
          sed -i 's/libaam_ruby/aam_ruby/g' ruby/lib/aam_rb.rb 2>/dev/null || true
          sed -i 's/libaam_rs_ruby/aam_rs_ruby/g' ruby/lib/aam_rb.rb 2>/dev/null || true
      - name: Run Ruby smoke test
        run: ruby ruby/tests/test_aam_rs.rb

  validate-php:
    name: PHP Bindings - Build & Test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: "8.3"
          coverage: none
          ini-values: ffi.enable=1
      - name: Build Rust library with FFI
        run: cargo build --release --features ffi
      - name: Run PHP smoke test
        env:
          AAM_RS_LIB: ${{ github.workspace }}/target/release/libaam_rs.so
        run: php php/tests/smoke.php

  release-please:
    needs:
      [
        validate,
        validate-go,
        validate-js,
        validate-csharp,
        validate-wasm,
        validate-ruby,
        validate-php,
      ]
    runs-on: ubuntu-latest
    outputs:
      release_created: ${{ steps.release.outputs.release_created }}
      tag_name: ${{ steps.release.outputs.tag_name }}
    steps:
      - name: Run Release Please
        id: release
        uses: googleapis/release-please-action@v4
        with:
          config-file: release-please-config.json
          manifest-file: release-please-manifest.json

  publish-cargo:
    needs: release-please
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo publish --token ${{ secrets.CRATES_TOKEN }} --no-verify

  build-node-bindings:
    name: Build Node.js Native Addons
    needs: [ release-please, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            artifact: node-binding-linux-x64-gnu
            binary: aam_rs_node.linux-x64-gnu.node
          - os: macos-15-intel
            artifact: node-binding-darwin-x64
            binary: aam_rs_node.darwin-x64.node
          - os: macos-latest
            artifact: node-binding-darwin-arm64
            binary: aam_rs_node.darwin-arm64.node
          - os: windows-latest
            artifact: node-binding-win32-x64-msvc
            binary: aam_rs_node.win32-x64-msvc.node
    runs-on: ${{ matrix.os }}
    defaults:
      run:
        shell: bash
    steps:
      - uses: actions/checkout@v6
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Setup Rust cache
        uses: Swatinem/rust-cache@v2
      - name: Set up Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 24
      - name: Install Node.js dependencies
        working-directory: ./js
        run: npm install
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Copy licenses
        run: cp LICENSE-MIT LICENSE-APACHE CREDITS.html js/
      - name: Build release addon
        working-directory: ./js
        run: npm run build
      - name: Upload addon artifact
        uses: actions/upload-artifact@v7
        with:
          name: ${{ matrix.artifact }}
          path: js/${{ matrix.binary }}
          retention-days: 1

  upload-node-to-release:
    name: Upload Node.js Addons to Release
    needs: [ release-please, build-node-bindings ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - name: Download Node.js addon artifacts
        uses: actions/download-artifact@v8
        with:
          pattern: node-binding-*
          merge-multiple: true
          path: node-artifacts
      - name: Upload Node.js addons to Release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ needs.release-please.outputs.tag_name }}
          files: node-artifacts/*.node

  build-wasm-bindings:
    name: Build & Test WASM Bindings
    needs: [ release-please, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: wasm32-unknown-unknown
      - name: Install wasm-pack
        run: cargo install wasm-pack --locked
      - name: Build WASM package
        working-directory: ./wasm
        run: wasm-pack build --release --target nodejs --out-dir pkg
      - name: Run WASM tests
        working-directory: ./wasm
        run: |
          cargo test
          wasm-pack test --node
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Copy licenses
        run: cp LICENSE-MIT LICENSE-APACHE CREDITS.html wasm/pkg/
      - name: Upload WASM artifact
        uses: actions/upload-artifact@v7
        with:
          name: wasm-pkg
          path: wasm/pkg
          retention-days: 1

  upload-wasm-to-release:
    name: Upload WASM Package to Release
    needs: [ release-please, build-wasm-bindings ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - name: Download WASM package
        uses: actions/download-artifact@v8
        with:
          name: wasm-pkg
          path: wasm-pkg
      - name: Zip WASM package
        run: |
          cd wasm-pkg
          zip -r ../aam-wasm-package.zip ./*
      - name: Upload WASM package to Release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ needs.release-please.outputs.tag_name }}
          files: aam-wasm-package.zip

  build-ruby-bindings:
    name: Build & Test Ruby Bindings
    needs: [ release-please, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.3"
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Build Ruby extension
        run: cargo build --manifest-path ruby/ext/aam_rs/Cargo.toml --release
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Copy licenses
        run: cp LICENSE-MIT LICENSE-APACHE CREDITS.html ruby/
      - name: Fix Ruby Naming and Prepare Payload
        run: |
          # Фикс имени для сборки гема + патч файла
          cp ruby/ext/aam_rs/target/release/libaam_ruby.so ruby/lib/aam_ruby.so 2>/dev/null || true
          cp ruby/ext/aam_rs/target/release/libaam_rs_ruby.so ruby/lib/aam_rs_ruby.so 2>/dev/null || true
          sed -i 's/libaam_ruby/aam_ruby/g' ruby/lib/aam_rb.rb 2>/dev/null || true
          sed -i 's/libaam_rs_ruby/aam_rs_ruby/g' ruby/lib/aam_rb.rb 2>/dev/null || true
          cd ruby
          gem build aam-ruby.gemspec --output ../aam-ruby.gem
      - name: Upload Ruby artifact
        uses: actions/upload-artifact@v7
        with:
          name: ruby-gem
          path: aam-ruby.gem
          retention-days: 1

  upload-ruby-to-release:
    name: Upload Ruby Gem to Release
    needs: [ release-please, build-ruby-bindings ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - name: Download Ruby artifact
        uses: actions/download-artifact@v8
        with:
          name: ruby-gem
          path: ruby-artifacts
      - name: Upload Ruby package to Release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ needs.release-please.outputs.tag_name }}
          files: ruby-artifacts/aam-ruby.gem

  publish-ruby:
    name: Publish Ruby Gem (RubyGems + GitHub Packages)
    needs: [ release-please, build-ruby-bindings ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - name: Download Ruby artifact
        uses: actions/download-artifact@v8
        with:
          name: ruby-gem
          path: ruby-artifacts
      - name: Publish to RubyGems
        env:
          GEM_HOST_API_KEY: ${{ secrets.RUBY_GEMS_TOKEN }}
        run: gem push ruby-artifacts/aam-ruby.gem
      - name: Publish to GitHub Packages (RubyGems)
        env:
          GEM_HOST_API_KEY: ${{ secrets.GITHUB_TOKEN }}
        run: |
          OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
          gem push --host "https://rubygems.pkg.github.com/$OWNER" ruby-artifacts/aam-ruby.gem

  build-php-bindings:
    name: Build & Test PHP Bindings
    needs: [ release-please, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: "8.3"
          coverage: none
          ini-values: ffi.enable=1
      - name: Build native library for PHP FFI
        run: cargo build --release --features ffi
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Copy licenses
        run: |
          mkdir -p php-pkg
          cp LICENSE-MIT LICENSE-APACHE CREDITS.html php-pkg/
      - name: Package PHP artifacts
        run: |
          mkdir -p php-pkg/src php-pkg/tests php-pkg/native
          cp php/src/AamPhp.php php-pkg/src/
          cp php/tests/smoke.php php-pkg/tests/
          cp php/README.md php-pkg/ 2>/dev/null || true
          cp php/composer.json php-pkg/ 2>/dev/null || true 
          cp target/release/libaam_rs.so php-pkg/native/
          cd php-pkg
          zip -r ../aam-php-package.zip ./*
      - name: Upload PHP artifact
        uses: actions/upload-artifact@v7
        with:
          name: php-package
          path: aam-php-package.zip
          retention-days: 1

  upload-php-to-release:
    name: Upload PHP Package to Release
    needs: [ release-please, build-php-bindings ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - name: Download PHP package
        uses: actions/download-artifact@v8
        with:
          name: php-package
          path: .
      - name: Upload PHP package to Release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ needs.release-please.outputs.tag_name }}
          files: aam-php-package.zip

  publish-php-mirror:
    name: Publish PHP Package to Mirror Repo (Packagist)
    needs: [ release-please, build-php-bindings ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - name: Download PHP package artifact
        uses: actions/download-artifact@v8
        with:
          name: php-package
          path: php-artifact
      - name: Push to PHP Mirror Repository
        env:
          TAG_NAME: ${{ needs.release-please.outputs.tag_name }}
          TARGET_REPO: "ininids/aam-php"
          MIRROR_TOKEN: ${{ secrets.PHP_MIRROR_TOKEN }}
        run: |
          mkdir php-repo
          cd php-repo
          unzip ../php-artifact/aam-php-package.zip
          git init 
          git branch -M main
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git add .
          git commit -m "Release $TAG_NAME"
          git tag "$TAG_NAME"
          git remote add origin "https://x-access-token:${MIRROR_TOKEN}@github.com/${TARGET_REPO}.git"
          git push origin main --force
          git push origin "$TAG_NAME" --force

  publish-npm:
    name: Publish to npm
    needs: [ release-please, build-node-bindings, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    defaults:
      run:
        shell: bash
    steps:
      - uses: actions/checkout@v6
      - name: Set up Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 24
          registry-url: https://registry.npmjs.org
      - name: Download Node.js addon artifacts
        uses: actions/download-artifact@v8
        with:
          pattern: node-binding-*
          merge-multiple: true
          path: node-artifacts
      - name: Install Node.js dependencies
        working-directory: ./js
        run: npm install
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Copy licenses
        run: cp LICENSE-MIT LICENSE-APACHE CREDITS.html js/
      - name: Populate platform packages
        run: |
          cp node-artifacts/aam_rs_node.linux-x64-gnu.node js/npm/linux-x64-gnu/
          cp node-artifacts/aam_rs_node.darwin-x64.node js/npm/darwin-x64/
          cp node-artifacts/aam_rs_node.darwin-arm64.node js/npm/darwin-arm64/
          cp node-artifacts/aam_rs_node.win32-x64-msvc.node js/npm/win32-x64-msvc/
      - name: Publish platform packages
        working-directory: ./js
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN || secrets.NPM_TOKEN }}
        run: |
          npm publish ./npm/linux-x64-gnu --access public --provenance
          npm publish ./npm/darwin-x64 --access public --provenance
          npm publish ./npm/darwin-arm64 --access public --provenance
          npm publish ./npm/win32-x64-msvc --access public --provenance
      - name: Publish main package
        working-directory: ./js
        run: npm publish --access public --provenance
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN || secrets.NPM_TOKEN }}

  publish-npm-github:
    name: Publish Node package to GitHub Packages
    needs: [ release-please, build-node-bindings, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Set up Node.js for GitHub Packages
        uses: actions/setup-node@v6
        with:
          node-version: 24
          registry-url: https://npm.pkg.github.com
      - name: Install Node.js dependencies
        working-directory: ./js
        run: npm install
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Copy licenses
        run: cp LICENSE-MIT LICENSE-APACHE CREDITS.html js/
      - name: Publish scoped package to GitHub Packages
        working-directory: ./js
        env:
          NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
          npm pkg set name="@${OWNER}/aam-nodejs"
          npm publish

  publish-wasm-npm:
    name: Publish WASM package to npm
    needs: [ release-please, build-wasm-bindings ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - name: Download WASM package artifact
        uses: actions/download-artifact@v8
        with:
          name: wasm-pkg
          path: wasm-pkg
      - name: Set up Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 24
          registry-url: https://registry.npmjs.org
      - name: Publish WASM package to npm
        working-directory: ./wasm-pkg
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN || secrets.NPM_TOKEN }}
        run: npm publish --access public --provenance

  build-c-libs:
    needs: [ release-please, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            artifact_name: aam-c-linux-x86_64
            lib_name: aam-c.so
          - os: macos-latest
            artifact_name: aam-c-macos-x86_64
            lib_name: aam-c.dylib
          - os: windows-latest
            artifact_name: aam-c-windows-x86_64
            lib_name: aam-c.dll
    runs-on: ${{ matrix.os }}
    defaults:
      run:
        shell: bash
    steps:
      - uses: actions/checkout@v6
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Install cargo-binstall
        uses: cargo-bins/cargo-binstall@main
      - name: Install cbindgen
        run: cargo binstall cbindgen -y
      - name: Build release library
        run: cargo build --release
      - name: Prepare C/C++ Package Structure
        run: |
          mkdir -p package/include package/lib/cmake/aam-c package/bin package/examples
          cbindgen --config cbindgen.toml --output package/include/aam-c.h
          cp LICENSE package/ 2>/dev/null || true
          cp examples/c/*.c package/examples/ 2>/dev/null || true
          cp examples/c/*.aam package/examples/ 2>/dev/null || true
          cp examples/c/Makefile package/examples/ 2>/dev/null || true
          cp examples/c/CMakeLists.txt package/examples/ 2>/dev/null || true
          cp aam-cConfig.cmake package/lib/cmake/aam-c/ 2>/dev/null || true
          if [ "${{ runner.os }}" == "Windows" ]; then
            cp target/release/aam_rs.dll package/bin/aam-c.dll
            cp target/release/aam_rs.dll.lib package/lib/aam-c.lib
          elif [ "${{ runner.os }}" == "macOS" ]; then
            cp target/release/libaam_rs.dylib package/lib/libaam-c.dylib
          else
            cp target/release/libaam_rs.so package/lib/libaam-c.so
          fi
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Copy licenses
        run: cp LICENSE-MIT LICENSE-APACHE CREDITS.html package/
      - name: Zip Package
        if: runner.os != 'Windows'
        run: |
          cd package
          zip -r ../${{ matrix.artifact_name }}.zip ./*
      - name: Zip Package (Windows)
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          Compress-Archive -Path package\* -DestinationPath "${{ matrix.artifact_name }}.zip" -Force
      - name: Upload Release Artifact
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ needs.release-please.outputs.tag_name }}
          files: ${{ matrix.artifact_name }}.zip

  build-csharp-libs:
    name: Build C# Native Libraries
    needs: release-please
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact: csharp-linux-x64
            file: libaam_rs.so
          - os: macos-15-intel
            target: x86_64-apple-darwin
            artifact: csharp-osx-x64
            file: libaam_rs.dylib
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact: csharp-osx-arm64
            file: libaam_rs.dylib
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact: csharp-win-x64
            file: aam_rs.dll
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v6
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - name: Setup Rust cache
        uses: Swatinem/rust-cache@v2
      - name: Build release library for FFI
        run: cargo build --release --features ffi --target ${{ matrix.target }}
      - name: Upload C# native artifact
        uses: actions/upload-artifact@v7
        with:
          name: ${{ matrix.artifact }}
          path: target/${{ matrix.target }}/release/${{ matrix.file }}
          retention-days: 1

  linux:
    needs: [ release-please, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ${{ matrix.platform.runner }}
    strategy:
      matrix:
        platform:
          - runner: ubuntu-22.04
            target: x86_64
          - runner: ubuntu-22.04
            target: x86
          - runner: ubuntu-22.04
            target: aarch64
          - runner: ubuntu-22.04
            target: armv7
          - runner: ubuntu-22.04
            target: s390x
          - runner: ubuntu-22.04
            target: ppc64le
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          python-version: 3.x
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.platform.target }}
          args: --release --out dist
          sccache: false
          manylinux: auto
      - name: Build free-threaded wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.platform.target }}
          args: --release --out dist -i python3.14t
          sccache: false
          manylinux: auto
      - name: Upload wheels
        uses: actions/upload-artifact@v7
        with:
          name: wheels-linux-${{ matrix.platform.target }}
          path: dist

  musllinux:
    needs: [ release-please, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ${{ matrix.platform.runner }}
    strategy:
      matrix:
        platform:
          - runner: ubuntu-22.04
            target: x86_64
          - runner: ubuntu-22.04
            target: x86
          - runner: ubuntu-22.04
            target: aarch64
          - runner: ubuntu-22.04
            target: armv7
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          python-version: 3.x
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.platform.target }}
          args: --release --out dist
          sccache: false
          manylinux: musllinux_1_2
      - name: Build free-threaded wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.platform.target }}
          args: --release --out dist -i python3.14t
          sccache: false
          manylinux: musllinux_1_2
      - name: Upload wheels
        uses: actions/upload-artifact@v7
        with:
          name: wheels-musllinux-${{ matrix.platform.target }}
          path: dist

  windows:
    needs: [ release-please, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ${{ matrix.platform.runner }}
    strategy:
      matrix:
        platform:
          - runner: windows-latest
            target: x64
            python_arch: x64
          - runner: windows-latest
            target: x86
            python_arch: x86
          - runner: windows-11-arm
            target: aarch64
            python_arch: arm64
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          python-version: 3.13
          architecture: ${{ matrix.platform.python_arch }}
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.platform.target }}
          args: --release --out dist
          sccache: false
      - uses: actions/setup-python@v6
        with:
          python-version: 3.14t
          architecture: ${{ matrix.platform.python_arch }}
      - name: Build free-threaded wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.platform.target }}
          args: --release --out dist -i python3.14t
          sccache: false
      - name: Upload wheels
        uses: actions/upload-artifact@v7
        with:
          name: wheels-windows-${{ matrix.platform.target }}
          path: dist

  macos:
    needs: [ release-please, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ${{ matrix.platform.runner }}
    strategy:
      matrix:
        platform:
          - runner: macos-15-intel
            target: x86_64
          - runner: macos-latest
            target: aarch64
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v6
        with:
          python-version: 3.x
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.platform.target }}
          args: --release --out dist
          sccache: false
      - name: Build free-threaded wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.platform.target }}
          args: --release --out dist -i python3.14t
          sccache: false
      - name: Upload wheels
        uses: actions/upload-artifact@v7
        with:
          name: wheels-macos-${{ matrix.platform.target }}
          path: dist

  sdist:
    needs: [ release-please, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Build sdist
        uses: PyO3/maturin-action@v1
        with:
          command: sdist
          args: --out dist
      - name: Upload sdist
        uses: actions/upload-artifact@v7
        with:
          name: wheels-sdist
          path: dist

  upload-wheels-to-release:
    name: Upload Python Wheels to Release
    needs: [ release-please, linux, musllinux, windows, macos, sdist ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - name: Download all wheels
        uses: actions/download-artifact@v8
        with:
          pattern: wheels-*
          merge-multiple: true
          path: dist
      - name: Upload Wheels and sdist to Release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ needs.release-please.outputs.tag_name }}
          files: dist/*

  publish-pypi:
    name: Publish to PyPI
    needs: [ release-please, linux, musllinux, windows, macos, sdist ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v8
        with:
          pattern: wheels-*
          merge-multiple: true
          path: dist
      - name: Generate artifact attestation
        uses: actions/attest-build-provenance@v3
        with:
          subject-path: "dist/*"
      - name: Install uv
        uses: astral-sh/setup-uv@v7
      - name: Publish to PyPI
        run: uv publish dist/*
        env:
          UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}

  build-jni-libs:
    name: Build JNI Native Libraries
    needs: release-please
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact: jni-linux-x86_64
            file: libaam_rs.so
          - os: macos-15-intel
            target: x86_64-apple-darwin
            artifact: jni-macos-x86_64
            file: libaam_rs.dylib
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact: jni-macos-aarch64
            file: libaam_rs.dylib
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact: jni-windows-x86_64
            file: aam_rs.dll
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v6
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - name: Build JNI release library
        run: cargo build --release --target ${{ matrix.target }}
      - name: Upload JNI artifact
        uses: actions/upload-artifact@v7
        with:
          name: ${{ matrix.artifact }}
          path: target/${{ matrix.target }}/release/${{ matrix.file }}
          retention-days: 1

  upload-jni-to-release:
    name: Upload JNI to GitHub Release
    needs: [ release-please, build-jni-libs ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v6
      - name: Download all JNI artifacts
        uses: actions/download-artifact@v8
        with:
          pattern: jni-*
          path: jni-artifacts
          merge-multiple: true
      - name: Upload to GitHub Release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          TAG_NAME: ${{ needs.release-please.outputs.tag_name }}
        run: |
          gh release upload "$TAG_NAME" jni-artifacts/*

  build-go-libs:
    name: Build Go Native Libs
    needs: [ release-please, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact: aam-go-linux-x86_64
          - os: macos-15-intel
            target: x86_64-apple-darwin
            artifact: aam-go-macos-x86_64
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact: aam-go-macos-aarch64
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact: aam-go-windows-x86_64
    runs-on: ${{ matrix.os }}
    defaults:
      run:
        shell: bash
    steps:
      - uses: actions/checkout@v6
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - name: Build Rust library with FFI (static + dynamic)
        run: cargo build --release --features ffi --target ${{ matrix.target }}
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Copy licenses
        run: |
          mkdir -p go-pkg
          cp LICENSE-MIT LICENSE-APACHE CREDITS.html go-pkg/
      - name: Package Go bindings
        if: runner.os != 'Windows'
        run: |
          mkdir -p go-pkg/lib go-pkg/include go-pkg/src
          cp include/aam.h go-pkg/include/
          cp -r go/ go-pkg/src/
          if [ "${{ runner.os }}" == "Windows" ]; then
            cp target/${{ matrix.target }}/release/aam_rs.dll     go-pkg/lib/ 2>/dev/null || true
            cp target/${{ matrix.target }}/release/aam_rs.dll.lib go-pkg/lib/aam_rs.lib 2>/dev/null || true
          elif [ "${{ runner.os }}" == "macOS" ]; then
            cp target/${{ matrix.target }}/release/libaam_rs.a     go-pkg/lib/ 2>/dev/null || true
            cp target/${{ matrix.target }}/release/libaam_rs.dylib go-pkg/lib/ 2>/dev/null || true
          else
            cp target/${{ matrix.target }}/release/libaam_rs.a  go-pkg/lib/ 2>/dev/null || true
            cp target/${{ matrix.target }}/release/libaam_rs.so go-pkg/lib/ 2>/dev/null || true
          fi
          cd go-pkg && zip -r ../${{ matrix.artifact }}.zip ./*
      - name: Package Go bindings (Windows)
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          New-Item -ItemType Directory -Path go-pkg/lib,go-pkg/include,go-pkg/src -Force | Out-Null
          Copy-Item include/aam.h go-pkg/include/
          Copy-Item go go-pkg/src -Recurse
          Copy-Item "target/${{ matrix.target }}/release/aam_rs.dll" go-pkg/lib/ -ErrorAction SilentlyContinue
          Copy-Item "target/${{ matrix.target }}/release/aam_rs.dll.lib" go-pkg/lib/aam_rs.lib -ErrorAction SilentlyContinue
          Compress-Archive -Path go-pkg\* -DestinationPath "${{ matrix.artifact }}.zip" -Force
      - name: Upload Go package to Release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ needs.release-please.outputs.tag_name }}
          files: ${{ matrix.artifact }}.zip

  publish-java:
    name: Publish Fat JAR & Upload to Release
    needs: [ release-please, build-jni-libs, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Set up JDK 17
        uses: actions/setup-java@v5
        with:
          distribution: "temurin"
          java-version: "17"
          cache: "gradle"
      - uses: actions/download-artifact@v8
        with:
          name: jni-linux-x86_64
          path: java/src/main/resources/natives/linux-x86_64
      - uses: actions/download-artifact@v8
        with:
          name: jni-macos-x86_64
          path: java/src/main/resources/natives/macos-x86_64
      - uses: actions/download-artifact@v8
        with:
          name: jni-macos-aarch64
          path: java/src/main/resources/natives/macos-aarch64
      - uses: actions/download-artifact@v8
        with:
          name: jni-windows-x86_64
          path: java/src/main/resources/natives/windows-x86_64
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Copy licenses
        run: |
          mkdir -p java/src/main/resources/META-INF
          cp LICENSE-MIT LICENSE-APACHE CREDITS.html java/src/main/resources/META-INF/
      - name: Build and Publish locally
        working-directory: ./java
        run: ./gradlew build publish
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
          ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSPHRASE }}
      - name: Create Zip Bundle for Central Portal
        working-directory: ./java
        run: |
          cd build/staging-repo 
          zip -r ../bundle.zip .
      - name: Upload Bundle to Maven Central
        working-directory: ./java
        env:
          CENTRAL_USERNAME: ${{ secrets.MAVEN_USERNAME }}
          CENTRAL_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
        run: |
          echo "Uploading bundle to Maven Central Portal..."
          curl --request POST \
            --url 'https://central.sonatype.com/api/v1/publisher/upload?publishingType=AUTOMATIC' \
            -u "$CENTRAL_USERNAME:$CENTRAL_PASSWORD" \
            --header 'Accept: application/json' \
            --form bundle=@build/bundle.zip \
            --fail
      - name: Upload JAR to Release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ needs.release-please.outputs.tag_name }}
          files: java/build/libs/*.jar

  publish-csharp:
    name: Publish C# Package to NuGet
    needs: [ release-please, build-csharp-libs, generate-credits ]
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Setup .NET
        uses: actions/setup-dotnet@v5
        with:
          dotnet-version: "10.0.x"
      - uses: actions/download-artifact@v8
        with:
          name: csharp-linux-x64
          path: csharp/runtimes/linux-x64/native
      - uses: actions/download-artifact@v8
        with:
          name: csharp-osx-x64
          path: csharp/runtimes/osx-x64/native
      - uses: actions/download-artifact@v8
        with:
          name: csharp-osx-arm64
          path: csharp/runtimes/osx-arm64/native
      - uses: actions/download-artifact@v8
        with:
          name: csharp-win-x64
          path: csharp/runtimes/win-x64/native
      - name: Resolve package version
        id: csharp_version
        shell: bash
        run: |
          TAG="${{ needs.release-please.outputs.tag_name }}"
          VERSION="${TAG##*-v}"
          if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
            echo "Could not parse semantic version from tag: $TAG"
            exit 1
          fi
          echo "version=$VERSION" >> "$GITHUB_OUTPUT"
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Download CREDITS.html
        uses: actions/download-artifact@v4
        with:
          name: credits-html
          path: ./
      - name: Copy licenses
        run: cp LICENSE-MIT LICENSE-APACHE CREDITS.html csharp/
      - name: Pack NuGet package
        working-directory: ./csharp
        run: dotnet pack AamCsharp.sln -c Release -p:Version=${{ steps.csharp_version.outputs.version }} -o artifacts
      - name: Publish NuGet package
        working-directory: ./csharp
        run: dotnet nuget push "artifacts/*.nupkg" --source "https://api.nuget.org/v3/index.json" --api-key "${{ secrets.NUGET_API_KEY }}" --skip-duplicate
      - name: Publish NuGet package to GitHub Packages
        working-directory: ./csharp
        run: |
          dotnet nuget add source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
            --name github \
            --username "${{ github.repository_owner }}" \
            --password "${{ secrets.GITHUB_TOKEN }}" \
            --store-password-in-clear-text
          dotnet nuget push "artifacts/*.nupkg" --source github --api-key "${{ secrets.GITHUB_TOKEN }}" --skip-duplicate
      - name: Upload NuGet package to Release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ needs.release-please.outputs.tag_name }}
          files: csharp/artifacts/*.nupkg