Repository navigation
1005 lines (891 loc) · 32 KB
/
Copy pathnode-matrix-pnpm.yaml
File metadata and controls
1005 lines (891 loc) · 32 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
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
name: Build and Test portable executable bundles
on:
workflow_call:
inputs:
#
# Common settings
#
app-name:
description: |
Application name in human-readable form.
As it is supposed to be shown in messages
type: string
required: false
default: ${{ github.repository }}
app-name-slug:
description: |
Application name slug (part of release file name)
type: string
required: true
#
# Checkout settings
#
checkout-submodules:
description: |
'Submodules' mode for 'actions/checkout' action
'', 'false' - disable submodules support
'true' - checkout submodules
'recursive' - checkout submodules recursive
type: string
required: false
default: ""
#
# Changed files
#
changeset-default-branch:
description:
Specify the default branch for changesets to run checks against.
type: string
required: false
default: 'main'
main-metapackage-name:
description:
Specify the name of the main metapackage.
type: string
required: false
default: ''
#
# Environment settings
#
env:
description: |
custom environment variables to set for all jobs in workflow
as JSON-encoded map:
{ "MY_VAR_1": "awesome value",
"VARIABLE_2": "not so awesome :)" }
This input's envs are merged with secrets.env
This input's envs have lower priority compared than secrets.env
type: string
required: false
default: "{}"
#
# Node settings
#
node-version:
description: |
Node version to use
type: string
required: true
#
# Cache control
#
cache-version:
description: |
Simple hack, that allows to 'reset' cache for particular job.
Just change the value of this parameter and the next run will
not find build cache and will have to start from scratch.
type: string
required: false
default: "v1"
cache-hashfiles-search-path:
description: |
Hashfiles search path for pnpm-lock.yaml
type: string
required: false
default: 'pnpm-lock.yaml'
team-id:
description: |
The Team ID to use. This controls the directory where turbo cache entries will be saved
type: string
required: false
default: 'ci'
#
# PNPM settings
#
pnpm-version:
description: |
Version of pnpm to install.
type: string
required: false
default: 'latest'
pnpm-recursive-build:
description: |
Run pnpm build with -r flag.
type: boolean
required: true
pnpm-recursive-tests:
description: |
Run pnpm tests with -r flag.
type: boolean
required: true
pnpm-build-args:
description: |
Additional pnpm build arguments to pass
for none --recursive pnpm invocations.
type: string
required: false
pnpm-tests-args:
description: |
Additional pnpm tests arguments to pass
for none --recursive pnpm invocations.
type: string
required: false
cache-paths:
description: |
Additional paths to be cached after build
type: string
required: false
default: ""
enable-ccache:
description: |
Enable ccache for the build
type: boolean
required: false
default: true
ccache-options:
description: |
Additional options to pass to ccache --set-config.
One per line. Example:
hash_dir=false
max_size=10.0G
sloppiness=time_macros,include_file_mtime,include_file_ctime
type: string
required: false
default: ""
#
# Matrix control
#
pre-calculated-task-list:
description: |
JSON-formatted string listing of the specific subtasks that have been pre-calculated.
This list is used to manage and track the execution of parallel builds in the monorepo.
Example:
[
{"os":"windows-latest", "arch":"amd64", "selector":"@platforma-open/milaboratories.runenv-python-3.12.7"},
]
type: string
required: false
default: '[]'
#
# Build control
#
build-script-name:
description: |
The name of a build script
type: string
required: true
default: "build"
#
# Test control
#
test:
description: |
Run tests
type: boolean
required: false
default: false
test-script-name:
description: |
The name of a test
type: string
required: false
default: 'test'
#
# NPM registry settings
#
npmrc-config:
description: |
Generates a .npmrc file based on provided configuration.
type: string
required: true
#
# Distribution control
#
publish-to-public:
description: |
Whether or not the npm package should be published as public.
type: string
required: false
default: 'false'
create-tag:
description: |
Create a tag after publishing the package.
type: string
required: false
default: 'false'
package-path:
description: |
Relative path to the package.json with package version.
type: string
required: false
default: '.'
aws-region:
description: |
The AWS region
type: string
required: false
default: 'eu-central-1'
aws-login-duration:
description: |
Maximum time AWS credentials will be valid until expiration.
Defaults to 1 hour.
type: number
required: false
default: 3600
#
# Codesign control
#
sign-binaries:
description: |
List of globbing patterns that match files to be signed after build step.
When built, the selected files will be signed with methods appropriate for current operating system.
type: string
required: false
default: ""
notarize-paths:
description: |
List of globbing patterns that match files and directories to be notarized.
Matched files would be notarized for releases.
type: string
required: false
default: ""
mac-sign-entitlements:
description: |
Additional entitlements to be embedded into binaries signature.
The contents of <dict> tag inside .plist file, like:
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
type: string
required: false
default: ""
gcp-sdk-version:
description: |
Version or version constraint of the gcloud SDK to install. If
unspecified, it will accept any installed version of the gcloud SDK. If
set to "latest", it will download the latest available SDK. If set to a
version constraint, it will download the latest available version that
matches the constraint. Examples: "290.0.1" or ">= 197.0.1".
type: string
required: false
default: "latest"
gcp-timestamping-mode:
description: |
Timestamping mode to use when working with certificates and signatures
(i.e. when signing the code)
type: string
required: false
# We do not put version into secrets because it has very short value.
# '1' in secrets may cause '1' to be replaced with '*' everywhere in github workflow logs
gcp-kms-key-version:
description: |
Version of KMS key.
type: string
required: false
default: "1"
gcp-kms-digest-algorithm:
description: |
The algorithm to digest the input.
Must be one of: sha256, sha384, sha512.
type: string
required: false
default: "sha256"
#
# Docker settings
#
docker-quay-push:
description: |
Whether or not to push images to quay.io registry.
type: boolean
required: false
default: true
docker-ga-push:
description: |
Whether or not to push images to GA registry.
type: boolean
required: false
default: true
#
# Notifications
#
notify-telegram:
description: |
Enable Telegram notifications
required: false
type: boolean
default: true
notify-build:
description: |
Enable notifications about build status (build ready/failed)
Possible values are:
- 'true' - send all notifications about build status (both success and failed)
- 'failure-only' - send notification about failed builds, don't notify on success
- 'success-only' - send notification about success builds, don't notify on failures
- 'false' - don't send notifications about build results at all.
required: false
type: string
default: "true"
notify-tests:
description: |
Enable notifications about tests status (ready/failed)
Possible values are:
- 'true' - send all notifications about tests status (both success and failed)
- 'failure-only' - send notification about failed tests, don't notify on success
- 'success-only' - send notification about success tests, don't notify on failures
- 'false' - don't send notifications about tests results at all.
required: false
type: string
default: "true"
secrets:
env:
description: |
custom environment variables to set for all jobs in workflow
as JSON-encoded map:
{ "MY_VAR_1": "awesome value",
"VARIABLE_2": "not so awesome :)" }
This input's envs are merged with inputs.env
This input's envs have HIGHER priority compared than inputs.env
required: false
TELEGRAM_NOTIFICATION_TARGET:
description: |
ID of Telegram Channel or User to notify on build results.
required: false
TELEGRAM_API_TOKEN:
description: |
Telegram Bot API authorization token
required: false
MAC_SIGN_CERT_ID:
description: |
The Apple's certificate id. e.g: '5MXXYYZZFF'
required: false
MAC_SIGN_CERT:
description: |
base64-encoded p12 signing certificate file for the macOS
(more info here https://www.electron.build/code-signing)
required: false
MAC_SIGN_CERT_PWD:
description: |
password to decrypt the p12 signing certificate for the macOS
required: false
MAC_NOTR_API_KEY:
description: |
base64-encoded content of an API key file
required: false
MAC_NOTR_API_KEY_ID:
description: |
Key ID found on App Store Connect for the API key file
required: false
MAC_NOTR_API_KEY_ISSUER_ID:
description: |
Issuer ID found on App Store Connect for the API key file
required: false
WIN_SIGN_CERT:
description: |
Unused: Windows binaries are signed with Azure Trusted Signing.
Kept so existing callers that still pass it do not fail.
required: false
WIN_SIGN_CERT_PWD:
description: |
Unused: Windows binaries are signed with Azure Trusted Signing.
Kept so existing callers that still pass it do not fail.
required: false
GCP_TIMESTAMPING_URL:
description: |
Timestamping URL of certificate issuer.
required: false
GCP_KMS_WORKLOAD_IDENTITY_PROVIDER:
description: |
Tha name of the GCP workload identity federation provider.
required: false
GCP_KMS_SERVICE_ACCOUNT:
description: |
The name of the GCP service account
required: false
GCP_KMS_LOCATION:
description: |
KMS key and keyring location
required: false
GCP_KMS_KEYRING:
description: |
KMS keyring name in Google Cloud Platform.
required: false
GCP_KMS_KEY_NAME:
description: |
KMS key name in Google Cloud Platform.
required: false
GH_ZEN_APP_ID:
description: |
Zen Artisian Github AppID
required: false
GH_ZEN_APP_PRIVATE_KEY:
description: |
Zen Artisian Github App PrivateKey
required: false
jobs:
init:
name: Init
runs-on: ubuntu-latest
steps:
- id: context
uses: milaboratory/github-ci/actions/context@v4
outputs:
is-release: ${{ steps.context.outputs.is-release }}
current-version: ${{ steps.context.outputs.current-version }}
metadata:
name: get run metadata
runs-on: ubuntu-latest
needs:
- init
steps:
- uses: actions/checkout@v4
with:
submodules: ${{ inputs.checkout-submodules }}
- id: npm-pkg-metadata
uses: milaboratory/github-ci/actions/shell@v4
env:
PACKAGE_PATH: ${{ inputs.package-path }}
with:
run: |
NPM_PKG_VERSION="$(cat "${GITHUB_WORKSPACE}/${PACKAGE_PATH}/package.json" | jq --raw-output '.version')"
PNPM_VERSION="$(cat "${GITHUB_WORKSPACE}/package.json" | jq --raw-output 'if .packageManager and (.packageManager | length > 0) then .packageManager | split("@")[1] else empty end')"
ghwa_set_output npm-pkg-version "${NPM_PKG_VERSION}"
ghwa_set_output pnpm-version "${PNPM_VERSION}"
outputs:
npm-pkg-version: ${{ fromJSON(steps.npm-pkg-metadata.outputs.data).npm-pkg-version }}
pnpm-version: ${{ fromJSON(steps.npm-pkg-metadata.outputs.data).pnpm-version }}
check-changesets:
name: check for changesets
runs-on: ubuntu-latest
needs:
- metadata
if: github.ref_name == 'main' || github.event_name == 'merge_group'
steps:
- id: context
uses: milaboratory/github-ci/actions/context@v4
- uses: milaboratory/github-ci/actions/env@v4
with:
inputs: ${{ inputs.env }}
secrets: ${{ secrets.env }}
- uses: actions/checkout@v4
with:
submodules: ${{ inputs.checkout-submodules }}
fetch-depth: '0'
- name: Prepare environment for building a NodeJS application
uses: milaboratory/github-ci/actions/node/prepare-pnpm@v4
env:
PNPM_VERSION: ${{ needs.metadata.outputs.pnpm-version }}
with:
node-version: ${{ inputs.node-version }}
cache-version: ${{ inputs.cache-version }}
pnpm-version: ${{ env.PNPM_VERSION || inputs.pnpm-version }}
cache-hashfiles-search-path: ${{ inputs.cache-hashfiles-search-path }}
npmrc-config: ${{ inputs.npmrc-config }}
- name: Install NodeJS packages with pnpm
uses: milaboratory/github-ci/actions/shell@v4
with:
run: |
pnpm install --frozen-lockfile --prefer-offline
- name: Check for Changesets
uses: milaboratory/github-ci/actions/shell@v4
env:
BRANCH_NAME: ${{ inputs.changeset-default-branch }}
with:
run: |
pnpm changeset status --since="origin/${BRANCH_NAME}"
pre-calculated-build:
name: prebuild
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(inputs.pre-calculated-task-list) }}
needs:
- check-changesets
- metadata
if: >
!failure() && !cancelled() &&
(
needs.check-changesets.result == 'success' ||
needs.check-changesets.result == 'skipped'
)
permissions:
id-token: write
contents: read
steps:
- uses: milaboratory/github-ci/actions/env@v4
with:
inputs: ${{ inputs.env }}
secrets: ${{ secrets.env }}
- name: Generate Zen Artisan Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.GH_ZEN_APP_ID }}
private-key: ${{ secrets.GH_ZEN_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
submodules: ${{ inputs.checkout-submodules }}
token: ${{ steps.app-token.outputs.token }}
- name: Install system build tools on Linux
if: runner.os == 'Linux'
uses: milaboratory/github-ci/actions/shell@v4
with:
dump-stdout: false
run: |
sudo apt-get update
sudo apt-get install -y build-essential gfortran libopenblas-dev liblapack-dev cmake pkg-config
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_CI_IAM_MONOREPO_SIMPLE_ROLE }}
role-duration-seconds: ${{ inputs.aws-login-duration }}
aws-region: ${{ inputs.aws-region }}
- name: Login to Quay.io
if: inputs.docker-quay-push && runner.os == 'Linux'
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ env.QUAY_USERNAME }}
password: ${{ env.QUAY_ROBOT_TOKEN }}
- name: Login to Docker GA
if: inputs.docker-ga-push && runner.os == 'Linux'
uses: docker/login-action@v3
with:
registry: containers.pl-open.science
username: ${{ env.QUAY_USERNAME }}
password: ${{ env.QUAY_ROBOT_TOKEN }}
- uses: milaboratory/github-ci/actions/turborepo/cache-s3@v4
with:
storage-provider: 's3'
storage-path: ${{ env.AWS_CI_TURBOREPO_S3_BUCKET }}
team-id: ${{ inputs.team-id }}
- name: Install pipx on Linux
shell: bash
if: runner.os == 'Linux'
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
if command -v pipx > /dev/null; then
echo "pipx is already installed"
python3 -m pipx ensurepath
exit 0
fi
python3 -m pip install --user pipx
python3 -m pipx ensurepath
- name: Install pipx on macOS
shell: bash
if: runner.os == 'macOS'
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
if command -v pipx > /dev/null; then
echo "pipx is already installed"
pipx ensurepath
exit 0
fi
brew install pipx
pipx ensurepath
# Activate vcvars on Windows runners so any subsequent step that
# builds a C / C++ extension from source (e.g. `pip wheel` against
# a setuptools/distutils sdist) finds `cl.exe` and the SDK headers.
# The action also sets `DISTUTILS_USE_SDK=1`, which tells
# setuptools' MSVC compiler shim to skip its own VS lookup. No-op
# on non-Windows runners.
- name: Setup MSVC Dev Cmd
if: runner.os == 'Windows'
uses: milaboratory/github-ci/actions/setup-msvc-dev-cmd@v4
with:
arch: ${{ matrix.arch == 'arm64' && 'arm64' || 'amd64' }}
- name: Configure ccache
if: inputs.enable-ccache
uses: milaboratory/github-ci/actions/ccache@v4
with:
options: ${{ inputs.ccache-options }}
- name: Cache additional paths
uses: actions/cache@v4
if: inputs.cache-paths != ''
with:
path: ${{ inputs.cache-paths }}
key: ${{ runner.os }}-${{ runner.arch }}-cache-additional-${{ inputs.cache-version }}
- name: Prepare environment for building a NodeJS application
uses: milaboratory/github-ci/actions/node/prepare-pnpm@v4
env:
PNPM_VERSION: ${{ needs.metadata.outputs.pnpm-version }}
with:
node-version: ${{ inputs.node-version }}
cache-version: ${{ inputs.cache-version }}
pnpm-version: ${{ env.PNPM_VERSION || inputs.pnpm-version }}
cache-hashfiles-search-path: ${{ inputs.cache-hashfiles-search-path }}
npmrc-config: ${{ inputs.npmrc-config }}
- name: Install NodeJS packages with pnpm
uses: milaboratory/github-ci/actions/shell@v4
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPMJS_TOKEN: ${{ env.NPMJS_TOKEN }}
with:
dump-stdout: false
run: |
pnpm install --frozen-lockfile --prefer-offline
- name: Run build for - ${{ matrix.selector }}
shell: bash
env:
PRE_CALCULATED_STEP: ${{ matrix.selector }}
run: |
pnpm run build --filter="${PRE_CALCULATED_STEP}"
- name: CodeSign binary on macOS
uses: milaboratory/github-ci/blocks/signing-tools/macos-sign@v4
if: runner.os == 'macOS'
&& inputs.sign-binaries != ''
with:
binaries: ${{ inputs.sign-binaries }}
entitlements: ${{ inputs.mac-sign-entitlements }}
mac-cert-id: ${{ secrets.MAC_SIGN_CERT_ID }}
mac-cert-base64: ${{ secrets.MAC_SIGN_CERT }}
mac-cert-passwd: ${{ secrets.MAC_SIGN_CERT_PWD }}
- name: Notarize binary on macOS
uses: milaboratory/github-ci/blocks/signing-tools/macos-notarize@v4
if: runner.os == 'macOS'
&& inputs.sign-binaries != ''
with:
paths: ${{ inputs.notarize-paths }}
mac-api-key-base64: ${{ secrets.MAC_NOTR_API_KEY }}
mac-api-key-id: ${{ secrets.MAC_NOTR_API_KEY_ID }}
mac-api-key-issuer-id: ${{ secrets.MAC_NOTR_API_KEY_ISSUER_ID }}
- name: CodeSign binary on Windows
if: runner.os == 'Windows'
&& inputs.sign-binaries != ''
uses: milaboratory/github-ci/blocks/signing-tools/windows-sign@v4
with:
binaries: ${{ inputs.sign-binaries }}
- name: Run after-prebuild for - ${{ matrix.selector }}
id: after-prebuild
shell: bash
env:
PRE_CALCULATED_STEP: ${{ matrix.selector }}
run: |
pnpm run --if-present after-prebuild --filter="${PRE_CALCULATED_STEP}"
- name: Generate archive name
id: archive-name
shell: bash
env:
M_SELECTOR: ${{ matrix.selector }}
M_OS: ${{ matrix.os }}
M_ARCH: ${{ matrix.arch }}
run: |
M_SELECTOR=$(echo "${M_SELECTOR}" | tr \''/.!@#$%^&*(){}[]<>:;"' '_') # cut special symbols from file name
echo "name=prebuild-results-${M_OS}-${M_ARCH}-${M_SELECTOR}" # report resulting artifact name
echo "name=prebuild-results-${M_OS}-${M_ARCH}-${M_SELECTOR}" >> $GITHUB_OUTPUT
- name: Save prebuild results for transfer to final build
uses: milaboratory/github-ci/actions/artifact/save@v4
with:
name: ${{ steps.archive-name.outputs.name }}
path: '*/dist/'
build-publish:
name: unified (build publish)
runs-on: ubuntu-latest
needs:
- check-changesets
- metadata
- pre-calculated-build
permissions:
id-token: write
packages: write
contents: write
pull-requests: write
issues: read
steps:
- id: context
uses: milaboratory/github-ci/actions/context@v4
- uses: milaboratory/github-ci/actions/env@v4
with:
inputs: ${{ inputs.env }}
secrets: ${{ secrets.env }}
- name: Generate Zen Artisan Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.GH_ZEN_APP_ID }}
private-key: ${{ secrets.GH_ZEN_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
submodules: ${{ inputs.checkout-submodules }}
token: ${{ steps.app-token.outputs.token }}
fetch-depth: '0'
- name: Install system build tools on Linux
if: runner.os == 'Linux'
uses: milaboratory/github-ci/actions/shell@v4
with:
dump-stdout: false
run: |
sudo apt-get update
sudo apt-get install -y build-essential gfortran libopenblas-dev liblapack-dev cmake pkg-config
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_CI_IAM_MONOREPO_SIMPLE_ROLE }}
role-duration-seconds: ${{ inputs.aws-login-duration }}
aws-region: ${{ inputs.aws-region }}
- name: Login to Quay.io
if: inputs.docker-quay-push
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ env.QUAY_USERNAME }}
password: ${{ env.QUAY_ROBOT_TOKEN }}
- name: Login to Docker GA
if: inputs.docker-quay-push
uses: docker/login-action@v3
with:
registry: containers.pl-open.science
username: ${{ env.QUAY_USERNAME }}
password: ${{ env.QUAY_ROBOT_TOKEN }}
- name: Prepare environment for building a NodeJS application
uses: milaboratory/github-ci/actions/node/prepare-pnpm@v4
env:
PNPM_VERSION: ${{ needs.metadata.outputs.pnpm-version }}
with:
node-version: ${{ inputs.node-version }}
cache-version: ${{ inputs.cache-version }}
pnpm-version: ${{ env.PNPM_VERSION || inputs.pnpm-version }}
cache-hashfiles-search-path: ${{ inputs.cache-hashfiles-search-path }}
npmrc-config: ${{ inputs.npmrc-config }}
- uses: milaboratory/github-ci/actions/turborepo/cache-s3@v4
with:
storage-provider: 's3'
storage-path: ${{ env.AWS_CI_TURBOREPO_S3_BUCKET }}
team-id: ${{ inputs.team-id }}
- name: Install NodeJS packages with pnpm
uses: milaboratory/github-ci/actions/shell@v4
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPMJS_TOKEN: ${{ env.NPMJS_TOKEN }}
with:
dump-stdout: false
run: |
pnpm install --frozen-lockfile --prefer-offline
- name: Run changeset version
if: ( github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'pull_request' || github.event_name == 'merge_group'
uses: milaboratory/github-ci/actions/shell@v4
with:
run: |
pnpm run version-packages
- name: Get changed files staged and unstaged
if: github.event_name == 'push'
&& github.ref_name == 'main'
id: check-changes
shell: bash
run: |
# Check for tracked files
TRACKED_FILES=$(git diff --diff-filter=ACMUXTR --name-only)
# Check for untracked files
UNTRACKED_FILES=$(git ls-files --others --exclude-standard)
# Check for unstaged deleted files
UNSTAGED_DELETED_FILES=$(git ls-files --deleted)
if [ -n "${TRACKED_FILES}" ] || [ -n "${UNTRACKED_FILES}" ] || [ -n "${UNSTAGED_DELETED_FILES}" ]; then
echo "Local changes detected but not committed."
echo "has-changes=1" >> $GITHUB_OUTPUT
echo "Tracked files:"
echo "${TRACKED_FILES}"
echo "Untracked files:"
echo "${UNTRACKED_FILES}"
echo "Unstaged deleted files:"
echo "${UNSTAGED_DELETED_FILES}"
else
echo "No local changes detected."
echo "has-changes=0" >> $GITHUB_OUTPUT
fi
- name: Restore prebuild results
uses: milaboratory/github-ci/actions/artifact/restore@v4
with:
pattern: prebuild-results-*
- name: Perform security scan checks before publication
uses: milaboratory/github-ci/actions/docker/scan-pnpm-repo@v4
- name: Run build - main metapackage
uses: milaboratory/github-ci/actions/shell@v4
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPMJS_TOKEN: ${{ env.NPMJS_TOKEN }}
MAIN_METAPACKAGE_NAME: ${{ inputs.main-metapackage-name }}
with:
dump-stdout: false
run: |
pnpm run --if-present before-publish
pnpm run build --filter="${MAIN_METAPACKAGE_NAME}"
- name: Get GitHub App User ID
if: steps.check-changes.outputs.has-changes == '1'
id: get-user-id
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
- name: Commit changed files to main
uses: milaboratory/github-ci/actions/shell@v4
if: steps.check-changes.outputs.has-changes == '1'
env:
USER_ID: ${{ steps.get-user-id.outputs.user-id }}
APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
with:
run: |
git config --global user.name "${APP_SLUG}[bot]"
git config --global user.email "${USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com>"
git checkout main
git add .
git commit -m "Auto-generated changes"
git push
# npm trusted publishing (OIDC). This job runs on a GitHub-hosted runner
# with id-token: write, so pack and upload run back to back: pack runs
# prepublishOnly/prepublish and `pnpm pack` for each unpublished
# package, upload publishes the tarballs. Each package needs a trusted
# publisher naming the caller's repository and workflow file.
- name: Pack unpublished npm packages
id: npm-pack
if: github.ref_name == 'main'
&& steps.check-changes.outputs.has-changes == '0'
uses: milaboratory/github-ci/actions/node/pack-unpublished@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPMJS_TOKEN: ${{ env.NPMJS_TOKEN }}
- name: Publish npm packages
if: steps.npm-pack.outputs.count != '' && steps.npm-pack.outputs.count != '0'
uses: milaboratory/github-ci/actions/node/publish-tarballs@v4
with:
dir: ${{ steps.npm-pack.outputs.dir }}
access-public: ${{ inputs.publish-to-public }}
npm-auth-token: ${{ secrets.GITHUB_TOKEN }}
- name: Create release with tag
if: github.ref_name == 'main'
&& steps.check-changes.outputs.has-changes == '0'
&& inputs.create-tag == 'true'
uses: milaboratory/github-ci/actions/release/create-with-tag@v4
env:
NPM_PKG_VERSION: ${{ needs.metadata.outputs.npm-pkg-version }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ format('v{0}', env.NPM_PKG_VERSION) }}
tag: ${{ format('v{0}', env.NPM_PKG_VERSION) }}
commit: ${{ github.sha }}
skipIfReleaseExists: true
draft: false
prerelease: false
outputs:
# Even constant outputs become initialized only after job start.
# All outputs of skipped jobs are always empty.
started: 'true'
notify-release:
name: notify release
runs-on: ubuntu-latest
if: always()
needs:
- init
- metadata
- check-changesets
- build-publish
- pre-calculated-build
steps:
- id: search-tags
if: always()
uses: milaboratory/github-ci/actions/strings/json-list@v4
with:
input: |
release
- uses: milaboratory/github-ci/blocks/notify/release@v4
env:
NPM_PKG_VERSION: ${{ needs.metadata.outputs.npm-pkg-version }}
with:
telegram-target: ${{ secrets.TELEGRAM_NOTIFICATION_TARGET }}
telegram-token: ${{ secrets.TELEGRAM_API_TOKEN }}
job-status: |
${{ needs.pre-calculated-build.result }}
${{ needs.build-publish.result }}