@@ -21,12 +21,19 @@ name: productionize
21
21
22
22
# Workflow triggers:
23
23
on :
24
- # Run workflow when a new commit is pushed to the repository :
24
+ # Run workflow when a new commit is pushed to the main branch :
25
25
push :
26
+ branches :
27
+ - main
26
28
27
29
# Allow the workflow to be manually run:
28
30
workflow_dispatch :
29
31
32
+ # Concurrency group to prevent multiple concurrent executions:
33
+ concurrency :
34
+ group : productionize
35
+ cancel-in-progress : true
36
+
30
37
# Workflow jobs:
31
38
jobs :
32
39
@@ -168,8 +175,8 @@ jobs:
168
175
# Define the type of virtual host machine on which to run the job:
169
176
runs-on : ubuntu-latest
170
177
171
- # Indicate that this job depends on the prior job finishing:
172
- needs : productionize
178
+ # Indicate that this job depends on the test job finishing:
179
+ needs : test
173
180
174
181
# Define the sequence of job steps...
175
182
steps :
@@ -202,13 +209,15 @@ jobs:
202
209
run : |
203
210
git checkout -b deno origin/deno
204
211
205
- find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm
206
- find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf
212
+ find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm
213
+ find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf
207
214
208
215
git add -A
209
- git commit -m "Remove files"
216
+ git commit -m "Remove files" --allow-empty
210
217
211
- git merge -s recursive -X theirs origin/production --allow-unrelated-histories
218
+ git config merge.theirs.name 'simulate `-s theirs`'
219
+ git config merge.theirs.driver 'cat %B > %A'
220
+ GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories
212
221
213
222
# If `deno` does not exist, create `deno` branch:
214
223
- name : ' If `deno` does not exist, create `deno` branch'
@@ -292,8 +301,8 @@ jobs:
292
301
# Delete everything in current directory aside from deno folder:
293
302
- name : ' Delete everything in current directory aside from deno folder'
294
303
run : |
295
- find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm
296
- find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf
304
+ find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm
305
+ find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf
297
306
298
307
# Move deno directory to root:
299
308
- name : ' Move deno directory to root'
@@ -307,21 +316,12 @@ jobs:
307
316
git add -A
308
317
git commit -m "Auto-generated commit"
309
318
310
- # Push changes to `deno` branch or create new branch tag :
311
- - name : ' Push changes to `deno` branch or create new branch tag '
319
+ # Push changes to `deno` branch:
320
+ - name : ' Push changes to `deno` branch'
312
321
run : |
313
322
SLUG=${{ github.repository }}
314
- VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p')
315
- if [ -z "$VERSION" ]; then
316
- echo "Workflow job was not triggered by a new tag...."
317
- echo "Pushing changes to $SLUG..."
318
- git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno
319
- else
320
- echo "Workflow job was triggered by a new tag: $VERSION"
321
- echo "Creating new bundle branch tag of the form $VERSION-deno"
322
- git tag -a $VERSION-deno -m "$VERSION-deno"
323
- git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno
324
- fi
323
+ echo "Pushing changes to $SLUG..."
324
+ git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno
325
325
326
326
# Send status to Slack channel if job fails:
327
327
- name : ' Send status to Slack channel in case of failure'
@@ -341,8 +341,8 @@ jobs:
341
341
# Define the type of virtual host machine on which to run the job:
342
342
runs-on : ubuntu-latest
343
343
344
- # Indicate that this job depends on the prior job finishing:
345
- needs : productionize
344
+ # Indicate that this job depends on the test job finishing:
345
+ needs : test
346
346
347
347
# Define the sequence of job steps...
348
348
steps :
@@ -375,13 +375,15 @@ jobs:
375
375
run : |
376
376
git checkout -b umd origin/umd
377
377
378
- find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm
379
- find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf
378
+ find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm
379
+ find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf
380
380
381
381
git add -A
382
- git commit -m "Remove files"
382
+ git commit -m "Remove files" --allow-empty
383
383
384
- git merge -s recursive -X theirs origin/production --allow-unrelated-histories
384
+ git config merge.theirs.name 'simulate `-s theirs`'
385
+ git config merge.theirs.driver 'cat %B > %A'
386
+ GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories
385
387
386
388
# If `umd` does not exist, create `umd` branch:
387
389
- name : ' If `umd` does not exist, create `umd` branch'
@@ -458,13 +460,13 @@ jobs:
458
460
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<script type=\"text\/javascript\">([\s\S]+?)<\/script>/<script type=\"text\/javascript\">\n\(function \(\) {\1}\)\(\);\n<\/script>/g"
459
461
460
462
# Create package.json file for umd branch:
461
- jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "main": "./browser .js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./umd/package.json
463
+ jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "main": "./index .js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./umd/package.json
462
464
463
465
# Delete everything in current directory aside from umd folder:
464
466
- name : ' Delete everything in current directory aside from umd folder'
465
467
run : |
466
- find . -type 'f' | grep -v -e "umd" -e ".git/" | xargs rm
467
- find . -mindepth 1 -type 'd' | grep -v -e "umd" -e ".git" | xargs rm -rf
468
+ find . -type 'f' | grep -v -e "umd" -e ".git/" | xargs -r rm
469
+ find . -mindepth 1 -type 'd' | grep -v -e "umd" -e ".git" | xargs -r rm -rf
468
470
469
471
# Move umd directory to root:
470
472
- name : ' Move umd directory to root'
@@ -478,21 +480,12 @@ jobs:
478
480
git add -A
479
481
git commit -m "Auto-generated commit"
480
482
481
- # Push changes to `umd` branch or create new branch tag :
482
- - name : ' Push changes to `umd` branch or create new branch tag '
483
+ # Push changes to `umd` branch:
484
+ - name : ' Push changes to `umd` branch'
483
485
run : |
484
486
SLUG=${{ github.repository }}
485
- VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p')
486
- if [ -z "$VERSION" ]; then
487
- echo "Workflow job was not triggered by a new tag...."
488
- echo "Pushing changes to $SLUG..."
489
- git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" umd
490
- else
491
- echo "Workflow job was triggered by a new tag: $VERSION"
492
- echo "Creating new bundle branch tag of the form $VERSION-umd"
493
- git tag -a $VERSION-umd -m "$VERSION-umd"
494
- git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-umd
495
- fi
487
+ echo "Pushing changes to $SLUG..."
488
+ git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" umd
496
489
497
490
# Send status to Slack channel if job fails:
498
491
- name : ' Send status to Slack channel in case of failure'
@@ -512,8 +505,8 @@ jobs:
512
505
# Define the type of virtual host machine on which to run the job:
513
506
runs-on : ubuntu-latest
514
507
515
- # Indicate that this job depends on the prior job finishing:
516
- needs : productionize
508
+ # Indicate that this job depends on the test job finishing:
509
+ needs : test
517
510
518
511
# Define the sequence of job steps...
519
512
steps :
@@ -546,13 +539,15 @@ jobs:
546
539
run : |
547
540
git checkout -b esm origin/esm
548
541
549
- find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm
550
- find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf
542
+ find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm
543
+ find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf
551
544
552
545
git add -A
553
- git commit -m "Remove files"
546
+ git commit -m "Remove files" --allow-empty
554
547
555
- git merge -s recursive -X theirs origin/production --allow-unrelated-histories
548
+ git config merge.theirs.name 'simulate `-s theirs`'
549
+ git config merge.theirs.driver 'cat %B > %A'
550
+ GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories
556
551
557
552
# If `esm` does not exist, create `esm` branch:
558
553
- name : ' If `esm` does not exist, create `esm` branch'
@@ -640,8 +635,8 @@ jobs:
640
635
# Delete everything in current directory aside from esm folder:
641
636
- name : ' Delete everything in current directory aside from esm folder'
642
637
run : |
643
- find . -type 'f' | grep -v -e "esm" -e ".git/" | xargs rm
644
- find . -mindepth 1 -type 'd' | grep -v -e "esm" -e ".git" | xargs rm -rf
638
+ find . -type 'f' | grep -v -e "esm" -e ".git/" | xargs -r rm
639
+ find . -mindepth 1 -type 'd' | grep -v -e "esm" -e ".git" | xargs -r rm -rf
645
640
646
641
# Move esm directory to root:
647
642
- name : ' Move esm directory to root'
@@ -655,21 +650,12 @@ jobs:
655
650
git add -A
656
651
git commit -m "Auto-generated commit"
657
652
658
- # Push changes to `esm` branch or create new branch tag :
659
- - name : ' Push changes to `esm` branch or create new branch tag '
653
+ # Push changes to `esm` branch:
654
+ - name : ' Push changes to `esm` branch'
660
655
run : |
661
656
SLUG=${{ github.repository }}
662
- VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p')
663
- if [ -z "$VERSION" ]; then
664
- echo "Workflow job was not triggered by a new tag...."
665
- echo "Pushing changes to $SLUG..."
666
- git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" esm
667
- else
668
- echo "Workflow job was triggered by a new tag: $VERSION"
669
- echo "Creating new bundle branch tag of the form $VERSION-esm"
670
- git tag -a $VERSION-esm -m "$VERSION-esm"
671
- git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-esm
672
- fi
657
+ echo "Pushing changes to $SLUG..."
658
+ git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" esm
673
659
674
660
# Send status to Slack channel if job fails:
675
661
- name : ' Send status to Slack channel in case of failure'
@@ -679,3 +665,96 @@ jobs:
679
665
steps : ${{ toJson(steps) }}
680
666
channel : ' #npm-ci'
681
667
if : failure()
668
+
669
+ # Define job that succeeds if all bundles were successfully built:
670
+ create-tag-bundles :
671
+
672
+ # Define display name:
673
+ name : ' Create tag bundles'
674
+
675
+ # Define the type of virtual host machine on which to run the job:
676
+ runs-on : ubuntu-latest
677
+
678
+ # Indicate that this job depends on the bundle jobs finishing:
679
+ needs : [ deno, umd, esm ]
680
+
681
+ # Define the steps to be executed:
682
+ steps :
683
+
684
+ # Checkout the repository:
685
+ - name : ' Checkout repository'
686
+ uses : actions/checkout@v3
687
+ with :
688
+ fetch-depth : 2
689
+
690
+ # Check if workflow run was triggered by a patch, minor, or major version bump:
691
+ - name : ' Check if workflow run was triggered by a patch, minor, or major version bump'
692
+ id : check-if-bump
693
+ continue-on-error : true
694
+ run : |
695
+ VERSION_CHANGE_PKG_JSON=$(git diff HEAD~1 HEAD package.json | grep '"version":')
696
+ if [ -z "$VERSION_CHANGE_PKG_JSON" ]; then
697
+ echo "This workflow was not triggered by a version bump."
698
+ echo "::set-output name=bump::false"
699
+ else
700
+ echo "This workflow was triggered by a version bump."
701
+ echo "::set-output name=bump::true"
702
+ fi
703
+
704
+ # Configure git:
705
+ - name : ' Configure git'
706
+ if : steps.check-if-bump.outputs.bump
707
+ run : |
708
+ git config --local user.email "noreply@stdlib.io"
709
+ git config --local user.name "stdlib-bot"
710
+ git fetch --all
711
+
712
+ # Create bundle tags:
713
+ - name : ' Create bundle tags'
714
+ if : steps.check-if-bump.outputs.bump
715
+ run : |
716
+ SLUG=${{ github.repository }}
717
+ ESCAPED=$(echo $SLUG | sed -E 's/\//\\\//g')
718
+ VERSION="v$(jq --raw-output '.version' package.json)"
719
+
720
+ git checkout -b deno origin/deno
721
+ sed -i -E "s/$ESCAPED@deno/$ESCAPED@$VERSION-deno/g" README.md
722
+ git add README.md
723
+ git commit -m "Update README.md for Deno bundle $VERSION"
724
+ git tag -a $VERSION-deno -m "$VERSION-deno"
725
+ git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno
726
+ sed -i -E "s/$ESCAPED@$VERSION-deno/$ESCAPED@deno/g" README.md
727
+
728
+ perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\The previous example will load the latest bundled code from the deno branch. Alternatively, you may load a specific version by loading the file from one of the \[tagged bundles\]\(https:\/\/github.com\/$ESCAPED\/tags\). For example,\n\n\`\`\`javascript\nimport \1 from 'https:\/\/cdn\.jsdelivr\.net\/gh\/$ESCAPED\@$VERSION-deno\/mod\.js';\n\`\`\`/" README.md
729
+
730
+ git add README.md
731
+ git commit -m "Auto-generated commit"
732
+ git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno
733
+
734
+ git checkout -b umd origin/umd
735
+ sed -i -E "s/$ESCAPED@umd/$ESCAPED@$VERSION-umd/g" README.md
736
+ git add README.md
737
+ git commit -m "Update README.md for UMD bundle $VERSION"
738
+ git tag -a $VERSION-umd -m "$VERSION-umd"
739
+ git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-umd
740
+ sed -i -E "s/$ESCAPED@$VERSION-umd/$ESCAPED@umd/g" README.md
741
+
742
+ perl -0777 -i -pe "s/\`\`\`javascript\n([a-zA-Z0-9_]+)\s+=\s*require\(\s*'([^']+)'\s*\)\n\`\`\`/\`\`\`javascript\n\1 = require\( '\2' \)\n\`\`\`\n\The previous example will load the latest bundled code from the umd branch. Alternatively, you may load a specific version by loading the file from one of the \[tagged bundles\]\(https:\/\/github.com\/$ESCAPED\/tags\). For example,\n\n\`\`\`javascript\n\1 = require\( 'https:\/\/cdn\.jsdelivr\.net\/gh\/$ESCAPED\@$VERSION-umd\/browser\.js' \)\n\`\`\`/" README.md
743
+
744
+ git add README.md
745
+ git commit -m "Auto-generated commit"
746
+ git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" umd
747
+
748
+ git checkout -b esm origin/esm
749
+ sed -i -E "s/$ESCAPED@esm/$ESCAPED@$VERSION-esm/g" README.md
750
+ git add README.md
751
+ git commit -m "Update README.md for ESM bundle $VERSION"
752
+ git tag -a $VERSION-esm -m "$VERSION-esm"
753
+ git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-esm
754
+ sed -i -E "s/$ESCAPED@$VERSION-esm/$ESCAPED@esm/g" README.md
755
+
756
+ perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the \[tagged bundles\]\(https:\/\/github.com\/$ESCAPED\/tags\). For example,\n\n\`\`\`javascript\nimport \1 from 'https:\/\/cdn\.jsdelivr\.net\/gh\/$ESCAPED\@$VERSION-esm\/index\.mjs';\n\`\`\`/" README.md
757
+
758
+ git add README.md
759
+ git commit -m "Auto-generated commit"
760
+ git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" esm
0 commit comments