-
-
Notifications
You must be signed in to change notification settings - Fork 372
805 lines (782 loc) · 29.2 KB
/
ash-ci.yml
File metadata and controls
805 lines (782 loc) · 29.2 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
# SPDX-FileCopyrightText: 2019 ash contributors <https://github.com/ash-project/ash/graphs/contributors>
#
# SPDX-License-Identifier: MIT
name: Ash CI
on:
workflow_call:
secrets:
HEX_API_KEY:
required: false
inputs:
release:
type: boolean
default: true
publish-docs:
type: boolean
default: true
spark-formatter:
type: boolean
default: true
codegen:
type: boolean
default: false
doctor:
type: boolean
default: false
conventional-commit:
type: boolean
default: false
spark-cheat-sheets:
type: boolean
default: true
sobelow:
type: boolean
default: true
postgres:
type: boolean
default: false
tenants:
type: boolean
default: true
ash_postgres:
type: boolean
default: true
ecto_postgres:
type: boolean
default: false
postgres-version:
type: string
default: "14"
postgres-image:
type: string
sqlite:
type: boolean
default: false
hex-api-key:
type: string
rustler-precompiled-module:
type: string
sat-solver:
type: string
default: "Picosat"
igniter-upgrade:
type: boolean
default: true
elixir-version:
type: string
default: "default"
erlang-version:
type: string
default: "default"
community-files:
type: boolean
default: true
reuse:
type: boolean
default: false
mysql:
type: boolean
default: false
ash_mysql:
type: boolean
default: false
ecto_mysql:
type: boolean
default: false
mysql-version:
type: string
default: "8.0"
ex-unit-args:
type: string
default: ""
description: "Extra arguments to pass to mix test (e.g. '--include s3_integration')"
env:
PG_VERSION: ${{inputs.postgres-version}}
MYSQL_VERSION: ${{inputs.mysql-version}}
ASH_CI_BUILD: true
permissions:
contents: read
jobs:
# Some kind of 403 permissions bug here
report_mix_deps:
name: "Report Mix Dependencies"
runs-on: ubuntu-latest
# Only run this job when we're on the main branch, not for PRs
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: erlef/mix-dependency-submission@fa3e8f349d00a32bf14eec1c7577d6564abe08d2 # v1.3.1
permissions:
# Give the default GITHUB_TOKEN write permission to call the dependencies API
contents: write
auditor:
name: audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Update Elixir version in .tool-versions
if: inputs.elixir-version != 'default'
run: |
if [ -f .tool-versions ]; then
if grep -q "^elixir " .tool-versions; then
sed -i "s/^elixir .*$/elixir ${{ inputs.elixir-version }}/" .tool-versions
else
echo "elixir ${{ inputs.elixir-version }}" >> .tool-versions
fi
else
echo "elixir ${{ inputs.elixir-version }}" > .tool-versions
fi
- name: Update Erlang version in .tool-versions
if: inputs.erlang-version != 'default'
run: |
if [ -f .tool-versions ]; then
if grep -q "^erlang " .tool-versions; then
sed -i "s/^erlang .*$/erlang ${{ inputs.erlang-version }}/" .tool-versions
else
echo "erlang ${{ inputs.erlang-version }}" >> .tool-versions
fi
else
echo "erlang ${{ inputs.erlang-version }}" > .tool-versions
fi
- uses: team-alembic/staple-actions/actions/mix-hex-audit@59199173e18eee6748b65d01626ef82d51c6e963 # main
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
task: deps.audit
community-files-check:
name: Community Files Check
runs-on: ubuntu-latest
if: ${{ inputs.community-files }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check community files placement and content
run: |
EXIT_CODE=0
# Check if files exist in root and fail if they do
for file in CODE_OF_CONDUCT.md FUNDING.yml; do
if [ -f "$file" ]; then
echo "❌ $file found in root directory. Please move it to .github/ directory."
EXIT_CODE=1
fi
done
# Function to fetch expected content from ash-project/.github
fetch_expected_content() {
local file="$1"
local url="https://raw.githubusercontent.com/ash-project/.github/main/$file"
curl -s -f "$url" || {
echo "❌ Failed to fetch expected content for $file from ash-project/.github"
return 1
}
}
# Check files in .github directory
for file in CODE_OF_CONDUCT.md FUNDING.yml; do
filepath=".github/$file"
if [ -f "$filepath" ]; then
echo "✅ Found $file in .github directory"
expected_content=$(fetch_expected_content "$file")
if [ $? -ne 0 ]; then
EXIT_CODE=1
continue
fi
actual_content=$(cat "$filepath")
if [ "$actual_content" != "$expected_content" ]; then
echo "❌ Content of $filepath does not match expected content from ash-project/.github"
echo " Please update the file content or delete it to use the standard version."
echo " Expected content URL: https://github.com/ash-project/.github/blob/main/$file"
EXIT_CODE=1
else
echo "✅ Content of $filepath matches expected content"
fi
else
echo "ℹ️ $file not found in .github directory (this is optional)"
fi
done
# Check template files
template_files=(
".github/PULL_REQUEST_TEMPLATE.md:PULL_REQUEST_TEMPLATE.md"
".github/ISSUE_TEMPLATE/bug_report.md:.github/ISSUE_TEMPLATE/bug_report.md"
".github/ISSUE_TEMPLATE/proposal.md:.github/ISSUE_TEMPLATE/proposal.md"
)
for template_mapping in "${template_files[@]}"; do
local_path="${template_mapping%:*}"
remote_path="${template_mapping#*:}"
if [ -f "$local_path" ]; then
echo "✅ Found template $local_path"
expected_content=$(fetch_expected_content "$remote_path")
if [ $? -ne 0 ]; then
EXIT_CODE=1
continue
fi
actual_content=$(cat "$local_path")
if [ "$actual_content" != "$expected_content" ]; then
echo "❌ Content of $local_path does not match expected content from ash-project/.github"
echo " Please update the file content or delete it to use the standard version."
echo " Expected content URL: https://github.com/ash-project/.github/blob/main/$remote_path"
EXIT_CODE=1
else
echo "✅ Content of $local_path matches expected content"
fi
else
echo "ℹ️ Template $local_path not found (this is optional)"
fi
done
if [ $EXIT_CODE -eq 0 ]; then
echo "✅ All community files are properly configured"
else
echo ""
echo "Community files check failed. Please:"
echo "1. Move any files from root to .github/ directory"
echo "2. Update file contents to match ash-project/.github or delete them"
echo "3. Reference: https://github.com/ash-project/.github"
fi
exit $EXIT_CODE
build-test:
name: MIX_ENV=test mix.compile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Update Elixir version in .tool-versions
if: inputs.elixir-version != 'default'
run: |
if [ -f .tool-versions ]; then
if grep -q "^elixir " .tool-versions; then
sed -i "s/^elixir .*$/elixir ${{ inputs.elixir-version }}/" .tool-versions
else
echo "elixir ${{ inputs.elixir-version }}" >> .tool-versions
fi
else
echo "elixir ${{ inputs.elixir-version }}" > .tool-versions
fi
- name: Update Erlang version in .tool-versions
if: inputs.erlang-version != 'default'
run: |
if [ -f .tool-versions ]; then
if grep -q "^erlang " .tool-versions; then
sed -i "s/^erlang .*$/erlang ${{ inputs.erlang-version }}/" .tool-versions
else
echo "erlang ${{ inputs.erlang-version }}" >> .tool-versions
fi
else
echo "erlang ${{ inputs.erlang-version }}" > .tool-versions
fi
- uses: team-alembic/staple-actions/actions/install-elixir@59199173e18eee6748b65d01626ef82d51c6e963 # main
- name: Set OS deps compile partition count
run: echo "MIX_OS_DEPS_COMPILE_PARTITION_COUNT=$(($(lscpu -p | grep -v '^#' | sort -u -t, -k 2,4 | wc -l) / 2))" >> $GITHUB_ENV
- uses: team-alembic/staple-actions/actions/mix-compile@04f27881d51ef973841fc40c549aefb7b52db7f7 # main
with:
mix-env: test
args: "--warnings-as-errors"
build-docs:
name: mix docs
runs-on: ubuntu-latest
if: ${{inputs.publish-docs}}
needs:
- build-test
- spark-cheat-sheets
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: team-alembic/staple-actions/actions/mix-docs@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: dev
use-cache: false
- uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
with:
path: doc/
deploy-docs:
name: Deploy docs to GitHub pages.
runs-on: ubuntu-latest
needs:
- build-test
- build-docs
if: ${{inputs.publish-docs && github.ref == 'refs/heads/main'}}
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
conventional-commit:
name: mix git_ops.check_message
runs-on: ubuntu-latest
needs: build-test
if: ${{inputs.conventional-commit}}
steps:
- uses: actions/checkout@v6.0.2
- uses: team-alembic/staple-actions/actions/conventional-commit@main
with:
mix-env: test
formatter:
name: mix format --check-formatted
runs-on: ubuntu-latest
needs:
- build-test
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: team-alembic/staple-actions/actions/mix-format@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
spark-formatter:
name: mix spark.formatter --check
runs-on: ubuntu-latest
needs:
- build-test
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
if: ${{inputs.spark-formatter}}
with:
mix-env: test
task: spark.formatter --check
spark-cheat-sheets:
name: mix spark.cheat_sheets --check
runs-on: ubuntu-latest
needs:
- build-test
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
if: ${{inputs.spark-cheat-sheets}}
with:
mix-env: test
task: spark.cheat_sheets --check
sobelow:
name: mix sobelow
runs-on: ubuntu-latest
needs:
- build-test
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
if: ${{inputs.sobelow}}
with:
mix-env: test
task: sobelow
doctor:
name: mix doctor --full --raise
runs-on: ubuntu-latest
needs: build-test
if: ${{inputs.doctor}}
steps:
- uses: actions/checkout@v6.0.2
- uses: team-alembic/staple-actions/actions/mix-doctor@main
with:
mix-env: test
credo:
name: mix credo --strict
runs-on: ubuntu-latest
needs: build-test
permissions:
security-events: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: team-alembic/staple-actions/actions/mix-credo@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
- name: Run Credo SAST
uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
task: credo --format sarif > results.sarif
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
with:
sarif_file: results.sarif
category: credo
codegen:
name: mix ash.codegen --check
runs-on: ubuntu-latest
needs:
- build-test
if: ${{inputs.codegen}}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: ash.codegen --check
unused-deps:
name: mix deps.unlock --check-unused
runs-on: ubuntu-latest
needs:
- build-test
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: deps.unlock --check-unused
igniter-upgrade:
name: mix igniter.upgrade
runs-on: ubuntu-latest
if: ${{inputs.igniter-upgrade}}
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0
if: github.event.pull_request.user.login == 'dependabot[bot]'
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
if: github.event.pull_request.user.login == 'dependabot[bot]'
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
task: igniter.upgrade --git-ci --yes
if: github.event.pull_request.user.login == 'dependabot[bot]'
- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7.1.0
if: github.event.pull_request.user.login == 'dependabot[bot]'
with:
commit_message: "[dependabot skip] Apply Igniter Upgrades"
commit_user_name: dependabot[bot]
test:
name: mix test
runs-on: ubuntu-latest
needs:
- build-test
services:
postgres:
image: ${{ inputs.postgres-image || format('postgres:{0}', inputs.postgres-version) }}
env:
POSTGRES_HOST_AUTH_METHOD: trust
TZ: "UTC"
PGTZ: "UTC"
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
mysql:
image: mysql:${{inputs.mysql-version}}
env:
MYSQL_ROOT_PASSWORD: root
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
ports:
- 3306:3306
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
if: ${{inputs.postgres && inputs.ash_postgres}}
with:
mix-env: test
task: ash_postgres.generate_migrations --check
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: ash_postgres.create
if: ${{inputs.postgres && inputs.ash_postgres}}
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: ecto.create
if: ${{inputs.postgres && inputs.ecto_postgres}}
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: ash_postgres.migrate
if: ${{inputs.postgres && inputs.ash_postgres}}
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: ash_postgres.migrate --tenants
if: ${{inputs.postgres && inputs.ash_postgres && inputs.tenants}}
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: ecto.migrate
if: ${{inputs.postgres && inputs.ecto_postgres}}
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: ash_sqlite.generate_migrations --check
if: ${{inputs.sqlite}}
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: ash_sqlite.create
if: ${{inputs.sqlite}}
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: ash_sqlite.migrate
if: ${{inputs.sqlite}}
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
if: ${{inputs.mysql && inputs.ash_mysql}}
with:
mix-env: test
task: ash_mysql.generate_migrations --check
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: ash_mysql.create
if: ${{inputs.mysql && inputs.ash_mysql}}
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: ecto.create
if: ${{inputs.mysql && inputs.ecto_mysql}}
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: ash_mysql.migrate
if: ${{inputs.mysql && inputs.ash_mysql}}
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: ash_mysql.migrate
if: ${{inputs.mysql && inputs.ash_mysql}}
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: ecto.migrate
if: ${{inputs.mysql && inputs.ecto_mysql}}
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: test
task: test ${{ inputs.ex-unit-args }}
env:
PGUSER: postgres
PGPASS: postgres
PGHOST: postgres
dialyzer:
name: mix dialyzer
runs-on: ubuntu-latest
needs:
- build-test
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: team-alembic/staple-actions/actions/mix-dialyzer@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: dev
reuse:
name: REUSE compliance
runs-on: ubuntu-latest
if: ${{inputs.reuse}}
steps:
- uses: actions/checkout@v6.0.2
- name: REUSE compliance check
uses: fsfe/reuse-action@v6
build-dev:
name: MIX_ENV=dev mix.compile
runs-on: ubuntu-latest
needs:
- build-test
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: team-alembic/staple-actions/actions/mix-compile@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: dev
build-release:
name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
if: ${{ always() && !failure() && !cancelled() && inputs.rustler-precompiled-module && startsWith(github.ref, 'refs/tags/v') }}
needs:
- credo
- unused-deps
- spark-formatter
- doctor
- conventional-commit
- spark-cheat-sheets
- igniter-upgrade
- sobelow
- formatter
- auditor
- test
- dialyzer
- build-dev
permissions:
contents: write
strategy:
fail-fast: false
matrix:
# we list the oldest OTP version that supports all features needed, have a look at the
# erlang docs for the OTP version to see which NIF version is in which OTP release
# https://github.com/erlang/otp/blob/master/erts/emulator/beam/erl_nif.h
# - "2.15" # OTP 22, OTP 23
# - "2.16" # OTP 24, OTP 25
# - "2.17" # OTP 26
nif: ["2.15"]
job:
# cranelift-codegen panics at 'error when identifying target: "no supported isa found for arch `arm`"'
# - { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04 , use-cross: true }
- { target: aarch64-apple-darwin, os: macos-15 }
- {
target: aarch64-unknown-linux-gnu,
os: ubuntu-22.04,
use-cross: true,
}
- {
target: aarch64-unknown-linux-musl,
os: ubuntu-22.04,
use-cross: true,
}
- {
target: riscv64gc-unknown-linux-gnu,
os: ubuntu-22.04,
use-cross: true,
cargo-args: "--no-default-features",
}
- { target: x86_64-apple-darwin, os: macos-15 }
- { target: x86_64-pc-windows-gnu, os: windows-2022 }
- { target: x86_64-pc-windows-msvc, os: windows-2022 }
- {
target: x86_64-unknown-freebsd,
os: ubuntu-22.04,
use-cross: true,
cross-version: v0.2.5,
}
- { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04 }
- {
target: x86_64-unknown-linux-musl,
os: ubuntu-22.04,
use-cross: true,
}
steps:
- name: Checkout source code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Extract crate information
shell: bash
run: |
# Get the project version from mix.exs
echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV
- name: Add target
shell: bash
run: |
rustup target add ${{ matrix.job.target }}
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
with:
prefix-key: v0-precomp
shared-key: ${{ matrix.job.target }}-${{ matrix.nif }}
workspaces: |
native/igniter_js
- name: Build the project
id: build-crate
uses: philss/rustler-precompiled-action@853ac56183f29a080304df3ff8a194b5bbdc24cc # v1.1.4
with:
project-name: igniter_js
project-version: ${{ env.PROJECT_VERSION }}
target: ${{ matrix.job.target }}
nif-version: ${{ matrix.nif }}
use-cross: ${{ matrix.job.use-cross }}
cross-version: ${{ matrix.job.cross-version || 'v0.2.4' }}
project-dir: "native/igniter_js"
cargo-args: ${{ matrix.job.cargo-args }}
- name: Artifact upload
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: ${{ steps.build-crate.outputs.file-name }}
path: ${{ steps.build-crate.outputs.file-path }}
- name: Publish archives and packages
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
files: |
${{ steps.build-crate.outputs.file-path }}
if: startsWith(github.ref, 'refs/tags/v')
release:
permissions:
contents: write
needs:
- credo
- unused-deps
- spark-formatter
- doctor
- conventional-commit
- build-release
- spark-cheat-sheets
- igniter-upgrade
- sobelow
- formatter
- auditor
- test
- dialyzer
- build-dev
if: ${{ inputs.release && always() && !failure() && !cancelled() && startsWith(github.ref, 'refs/tags/v') }}
runs-on: ubuntu-latest
name: Release
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: team-alembic/staple-actions/actions/mix-task@59199173e18eee6748b65d01626ef82d51c6e963 # main
if: ${{inputs.rustler-precompiled-module}}
with:
task: rustler_precompiled.download ${{inputs.rustler-precompiled-module}} --only-local --all --print
- name: Extract release notes from CHANGELOG.md
id: extract-notes
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
VERSION=${TAG_NAME#v}
# Extract the section for this version from CHANGELOG.md
awk -v version="$VERSION" '
/^## \[v?[0-9]/ {
if (found) exit
if (index($0, "[v" version "]") || index($0, "[" version "]")) {
found = 1
next
}
}
found {
if (/^## \[v?[0-9]/) exit
print
}
' CHANGELOG.md > release_notes.md
# Check if notes were found
if [ -s release_notes.md ]; then
echo "has_notes=true" >> $GITHUB_OUTPUT
echo "Release notes extracted for version $VERSION"
else
echo "has_notes=false" >> $GITHUB_OUTPUT
echo "No release notes found for version $VERSION, will use auto-generated notes"
fi
- name: Create draft prerelease with changelog notes
if: ${{ (contains(github.ref, '-rc') || contains(github.ref, '-beta') || contains(github.ref, '-alpha') || contains(github.ref, '-pre')) && steps.extract-notes.outputs.has_notes == 'true' }}
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release create \
--repo ${{ github.repository }} \
--title ${GITHUB_REF#refs/tags/} \
--prerelease \
--notes-file release_notes.md \
${GITHUB_REF#refs/tags/}
- name: Create draft prerelease with generated notes
if: ${{ (contains(github.ref, '-rc') || contains(github.ref, '-beta') || contains(github.ref, '-alpha') || contains(github.ref, '-pre')) && steps.extract-notes.outputs.has_notes != 'true' }}
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release create \
--repo ${{ github.repository }} \
--title ${GITHUB_REF#refs/tags/} \
--prerelease \
--generate-notes \
${GITHUB_REF#refs/tags/}
- name: Create release with changelog notes
if: ${{ (!contains(github.ref, '-rc') && !contains(github.ref, '-beta') && !contains(github.ref, '-alpha') && !contains(github.ref, '-pre')) && steps.extract-notes.outputs.has_notes == 'true' }}
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release create \
--repo ${{ github.repository }} \
--title ${GITHUB_REF#refs/tags/} \
--notes-file release_notes.md \
${GITHUB_REF#refs/tags/}
- name: Create release with generated notes
if: ${{ (!contains(github.ref, '-rc') && !contains(github.ref, '-beta') && !contains(github.ref, '-alpha') && !contains(github.ref, '-pre')) && steps.extract-notes.outputs.has_notes != 'true' }}
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release create \
--repo ${{ github.repository }} \
--title ${GITHUB_REF#refs/tags/} \
--generate-notes \
${GITHUB_REF#refs/tags/}
- uses: team-alembic/staple-actions/actions/mix-hex-publish@59199173e18eee6748b65d01626ef82d51c6e963 # main
with:
mix-env: dev
hex-api-key: ${{secrets.HEX_API_KEY}}