@@ -21,12 +21,19 @@ name: productionize
2121
2222# Workflow triggers:
2323on :
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 :
2525 push :
26+ branches :
27+ - main
2628
2729 # Allow the workflow to be manually run:
2830 workflow_dispatch :
2931
32+ # Concurrency group to prevent multiple concurrent executions:
33+ concurrency :
34+ group : productionize
35+ cancel-in-progress : true
36+ 3037# Workflow jobs:
3138jobs :
3239
@@ -168,8 +175,8 @@ jobs:
168175 # Define the type of virtual host machine on which to run the job:
169176 runs-on : ubuntu-latest
170177
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
173180
174181 # Define the sequence of job steps...
175182 steps :
@@ -309,21 +316,12 @@ jobs:
309316 git add -A
310317 git commit -m "Auto-generated commit"
311318
312- # Push changes to `deno` branch or create new branch tag :
313- - name : ' Push changes to `deno` branch or create new branch tag '
319+ # Push changes to `deno` branch:
320+ - name : ' Push changes to `deno` branch'
314321 run : |
315322 SLUG=${{ github.repository }}
316- VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/1円/p')
317- if [ -z "$VERSION" ]; then
318- echo "Workflow job was not triggered by a new tag...."
319- echo "Pushing changes to $SLUG..."
320- git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno
321- else
322- echo "Workflow job was triggered by a new tag: $VERSION"
323- echo "Creating new bundle branch tag of the form $VERSION-deno"
324- git tag -a $VERSION-deno -m "$VERSION-deno"
325- git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno
326- fi
323+ echo "Pushing changes to $SLUG..."
324+ git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno
327325
328326 # Send status to Slack channel if job fails:
329327 - name : ' Send status to Slack channel in case of failure'
@@ -343,8 +341,8 @@ jobs:
343341 # Define the type of virtual host machine on which to run the job:
344342 runs-on : ubuntu-latest
345343
346- # Indicate that this job depends on the prior job finishing:
347- needs : productionize
344+ # Indicate that this job depends on the test job finishing:
345+ needs : test
348346
349347 # Define the sequence of job steps...
350348 steps :
@@ -482,21 +480,12 @@ jobs:
482480 git add -A
483481 git commit -m "Auto-generated commit"
484482
485- # Push changes to `umd` branch or create new branch tag :
486- - name : ' Push changes to `umd` branch or create new branch tag '
483+ # Push changes to `umd` branch:
484+ - name : ' Push changes to `umd` branch'
487485 run : |
488486 SLUG=${{ github.repository }}
489- VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/1円/p')
490- if [ -z "$VERSION" ]; then
491- echo "Workflow job was not triggered by a new tag...."
492- echo "Pushing changes to $SLUG..."
493- git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" umd
494- else
495- echo "Workflow job was triggered by a new tag: $VERSION"
496- echo "Creating new bundle branch tag of the form $VERSION-umd"
497- git tag -a $VERSION-umd -m "$VERSION-umd"
498- git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-umd
499- fi
487+ echo "Pushing changes to $SLUG..."
488+ git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" umd
500489
501490 # Send status to Slack channel if job fails:
502491 - name : ' Send status to Slack channel in case of failure'
@@ -516,8 +505,8 @@ jobs:
516505 # Define the type of virtual host machine on which to run the job:
517506 runs-on : ubuntu-latest
518507
519- # Indicate that this job depends on the prior job finishing:
520- needs : productionize
508+ # Indicate that this job depends on the test job finishing:
509+ needs : test
521510
522511 # Define the sequence of job steps...
523512 steps :
@@ -661,21 +650,12 @@ jobs:
661650 git add -A
662651 git commit -m "Auto-generated commit"
663652
664- # Push changes to `esm` branch or create new branch tag :
665- - name : ' Push changes to `esm` branch or create new branch tag '
653+ # Push changes to `esm` branch:
654+ - name : ' Push changes to `esm` branch'
666655 run : |
667656 SLUG=${{ github.repository }}
668- VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/1円/p')
669- if [ -z "$VERSION" ]; then
670- echo "Workflow job was not triggered by a new tag...."
671- echo "Pushing changes to $SLUG..."
672- git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" esm
673- else
674- echo "Workflow job was triggered by a new tag: $VERSION"
675- echo "Creating new bundle branch tag of the form $VERSION-esm"
676- git tag -a $VERSION-esm -m "$VERSION-esm"
677- git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-esm
678- fi
657+ echo "Pushing changes to $SLUG..."
658+ git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" esm
679659
680660 # Send status to Slack channel if job fails:
681661 - name : ' Send status to Slack channel in case of failure'
@@ -685,3 +665,96 @@ jobs:
685665 steps : ${{ toJson(steps) }}
686666 channel : ' #npm-ci'
687667 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\n1円 = 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\n1円 = 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