Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Aug 1, 2022
1 parent 1c323c6 commit 1ee4767
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .github/.keepalive
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2022-07-01T01:06:30.423Z
2022-08-01T01:09:43.701Z
209 changes: 144 additions & 65 deletions .github/workflows/productionize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@ name: productionize

# Workflow triggers:
on:
# Run workflow when a new commit is pushed to the repository:
# Run workflow when a new commit is pushed to the main branch:
push:
branches:
- main

# Allow the workflow to be manually run:
workflow_dispatch:

# Concurrency group to prevent multiple concurrent executions:
concurrency:
group: productionize
cancel-in-progress: true

# Workflow jobs:
jobs:

Expand Down Expand Up @@ -168,8 +175,8 @@ jobs:
# Define the type of virtual host machine on which to run the job:
runs-on: ubuntu-latest

# Indicate that this job depends on the prior job finishing:
needs: productionize
# Indicate that this job depends on the test job finishing:
needs: test

# Define the sequence of job steps...
steps:
Expand Down Expand Up @@ -202,13 +209,15 @@ jobs:
run: |
git checkout -b deno origin/deno
find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm
find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf
find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm
find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf
git add -A
git commit -m "Remove files"
git commit -m "Remove files" --allow-empty
git merge -s recursive -X theirs origin/production --allow-unrelated-histories
git config merge.theirs.name 'simulate `-s theirs`'
git config merge.theirs.driver 'cat %B > %A'
GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories
# If `deno` does not exist, create `deno` branch:
- name: 'If `deno` does not exist, create `deno` branch'
Expand Down Expand Up @@ -292,8 +301,8 @@ jobs:
# Delete everything in current directory aside from deno folder:
- name: 'Delete everything in current directory aside from deno folder'
run: |
find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm
find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf
find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm
find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf
# Move deno directory to root:
- name: 'Move deno directory to root'
Expand All @@ -307,21 +316,12 @@ jobs:
git add -A
git commit -m "Auto-generated commit"
# Push changes to `deno` branch or create new branch tag:
- name: 'Push changes to `deno` branch or create new branch tag'
# Push changes to `deno` branch:
- name: 'Push changes to `deno` branch'
run: |
SLUG=${{ github.repository }}
VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p')
if [ -z "$VERSION" ]; then
echo "Workflow job was not triggered by a new tag...."
echo "Pushing changes to $SLUG..."
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" deno
else
echo "Workflow job was triggered by a new tag: $VERSION"
echo "Creating new bundle branch tag of the form $VERSION-deno"
git tag -a $VERSION-deno -m "$VERSION-deno"
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" $VERSION-deno
fi
echo "Pushing changes to $SLUG..."
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" deno
# Send status to Slack channel if job fails:
- name: 'Send status to Slack channel in case of failure'
Expand All @@ -341,8 +341,8 @@ jobs:
# Define the type of virtual host machine on which to run the job:
runs-on: ubuntu-latest

# Indicate that this job depends on the prior job finishing:
needs: productionize
# Indicate that this job depends on the test job finishing:
needs: test

# Define the sequence of job steps...
steps:
Expand Down Expand Up @@ -375,13 +375,15 @@ jobs:
run: |
git checkout -b umd origin/umd
find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm
find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf
find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm
find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf
git add -A
git commit -m "Remove files"
git commit -m "Remove files" --allow-empty
git merge -s recursive -X theirs origin/production --allow-unrelated-histories
git config merge.theirs.name 'simulate `-s theirs`'
git config merge.theirs.driver 'cat %B > %A'
GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories
# If `umd` does not exist, create `umd` branch:
- name: 'If `umd` does not exist, create `umd` branch'
Expand Down Expand Up @@ -458,13 +460,13 @@ jobs:
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"
# Create package.json file for umd branch:
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
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
# Delete everything in current directory aside from umd folder:
- name: 'Delete everything in current directory aside from umd folder'
run: |
find . -type 'f' | grep -v -e "umd" -e ".git/" | xargs rm
find . -mindepth 1 -type 'd' | grep -v -e "umd" -e ".git" | xargs rm -rf
find . -type 'f' | grep -v -e "umd" -e ".git/" | xargs -r rm
find . -mindepth 1 -type 'd' | grep -v -e "umd" -e ".git" | xargs -r rm -rf
# Move umd directory to root:
- name: 'Move umd directory to root'
Expand All @@ -478,21 +480,12 @@ jobs:
git add -A
git commit -m "Auto-generated commit"
# Push changes to `umd` branch or create new branch tag:
- name: 'Push changes to `umd` branch or create new branch tag'
# Push changes to `umd` branch:
- name: 'Push changes to `umd` branch'
run: |
SLUG=${{ github.repository }}
VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p')
if [ -z "$VERSION" ]; then
echo "Workflow job was not triggered by a new tag...."
echo "Pushing changes to $SLUG..."
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" umd
else
echo "Workflow job was triggered by a new tag: $VERSION"
echo "Creating new bundle branch tag of the form $VERSION-umd"
git tag -a $VERSION-umd -m "$VERSION-umd"
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" $VERSION-umd
fi
echo "Pushing changes to $SLUG..."
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" umd
# Send status to Slack channel if job fails:
- name: 'Send status to Slack channel in case of failure'
Expand All @@ -512,8 +505,8 @@ jobs:
# Define the type of virtual host machine on which to run the job:
runs-on: ubuntu-latest

# Indicate that this job depends on the prior job finishing:
needs: productionize
# Indicate that this job depends on the test job finishing:
needs: test

# Define the sequence of job steps...
steps:
Expand Down Expand Up @@ -546,13 +539,15 @@ jobs:
run: |
git checkout -b esm origin/esm
find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm
find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf
find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm
find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf
git add -A
git commit -m "Remove files"
git commit -m "Remove files" --allow-empty
git merge -s recursive -X theirs origin/production --allow-unrelated-histories
git config merge.theirs.name 'simulate `-s theirs`'
git config merge.theirs.driver 'cat %B > %A'
GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories
# If `esm` does not exist, create `esm` branch:
- name: 'If `esm` does not exist, create `esm` branch'
Expand Down Expand Up @@ -640,8 +635,8 @@ jobs:
# Delete everything in current directory aside from esm folder:
- name: 'Delete everything in current directory aside from esm folder'
run: |
find . -type 'f' | grep -v -e "esm" -e ".git/" | xargs rm
find . -mindepth 1 -type 'd' | grep -v -e "esm" -e ".git" | xargs rm -rf
find . -type 'f' | grep -v -e "esm" -e ".git/" | xargs -r rm
find . -mindepth 1 -type 'd' | grep -v -e "esm" -e ".git" | xargs -r rm -rf
# Move esm directory to root:
- name: 'Move esm directory to root'
Expand All @@ -655,21 +650,12 @@ jobs:
git add -A
git commit -m "Auto-generated commit"
# Push changes to `esm` branch or create new branch tag:
- name: 'Push changes to `esm` branch or create new branch tag'
# Push changes to `esm` branch:
- name: 'Push changes to `esm` branch'
run: |
SLUG=${{ github.repository }}
VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p')
if [ -z "$VERSION" ]; then
echo "Workflow job was not triggered by a new tag...."
echo "Pushing changes to $SLUG..."
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" esm
else
echo "Workflow job was triggered by a new tag: $VERSION"
echo "Creating new bundle branch tag of the form $VERSION-esm"
git tag -a $VERSION-esm -m "$VERSION-esm"
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" $VERSION-esm
fi
echo "Pushing changes to $SLUG..."
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" esm
# Send status to Slack channel if job fails:
- name: 'Send status to Slack channel in case of failure'
Expand All @@ -679,3 +665,96 @@ jobs:
steps: ${{ toJson(steps) }}
channel: '#npm-ci'
if: failure()

# Define job that succeeds if all bundles were successfully built:
create-tag-bundles:

# Define display name:
name: 'Create tag bundles'

# Define the type of virtual host machine on which to run the job:
runs-on: ubuntu-latest

# Indicate that this job depends on the bundle jobs finishing:
needs: [ deno, umd, esm ]

# Define the steps to be executed:
steps:

# Checkout the repository:
- name: 'Checkout repository'
uses: actions/checkout@v3
with:
fetch-depth: 2

# Check if workflow run was triggered by a patch, minor, or major version bump:
- name: 'Check if workflow run was triggered by a patch, minor, or major version bump'
id: check-if-bump
continue-on-error: true
run: |
VERSION_CHANGE_PKG_JSON=$(git diff HEAD~1 HEAD package.json | grep '"version":')
if [ -z "$VERSION_CHANGE_PKG_JSON" ]; then
echo "This workflow was not triggered by a version bump."
echo "::set-output name=bump::false"
else
echo "This workflow was triggered by a version bump."
echo "::set-output name=bump::true"
fi
# Configure git:
- name: 'Configure git'
if: steps.check-if-bump.outputs.bump
run: |
git config --local user.email "[email protected]"
git config --local user.name "stdlib-bot"
git fetch --all
# Create bundle tags:
- name: 'Create bundle tags'
if: steps.check-if-bump.outputs.bump
run: |
SLUG=${{ github.repository }}
ESCAPED=$(echo $SLUG | sed -E 's/\//\\\//g')
VERSION="v$(jq --raw-output '.version' package.json)"
git checkout -b deno origin/deno
sed -i -E "s/$ESCAPED@deno/$ESCAPED@$VERSION-deno/g" README.md
git add README.md
git commit -m "Update README.md for Deno bundle $VERSION"
git tag -a $VERSION-deno -m "$VERSION-deno"
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" $VERSION-deno
sed -i -E "s/$ESCAPED@$VERSION-deno/$ESCAPED@deno/g" README.md
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
git add README.md
git commit -m "Auto-generated commit"
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" deno
git checkout -b umd origin/umd
sed -i -E "s/$ESCAPED@umd/$ESCAPED@$VERSION-umd/g" README.md
git add README.md
git commit -m "Update README.md for UMD bundle $VERSION"
git tag -a $VERSION-umd -m "$VERSION-umd"
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" $VERSION-umd
sed -i -E "s/$ESCAPED@$VERSION-umd/$ESCAPED@umd/g" README.md
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
git add README.md
git commit -m "Auto-generated commit"
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" umd
git checkout -b esm origin/esm
sed -i -E "s/$ESCAPED@esm/$ESCAPED@$VERSION-esm/g" README.md
git add README.md
git commit -m "Update README.md for ESM bundle $VERSION"
git tag -a $VERSION-esm -m "$VERSION-esm"
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" $VERSION-esm
sed -i -E "s/$ESCAPED@$VERSION-esm/$ESCAPED@esm/g" README.md
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
git add README.md
git commit -m "Auto-generated commit"
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" esm
40 changes: 0 additions & 40 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,46 +91,6 @@ jobs:
channel: '#npm-ci'
if: failure()

# Define job to increment semver version and commit the changes to main branch...
increment:

# Define the type of virtual host machine on which to run the job:
runs-on: ubuntu-latest

# Define the sequence of job steps...
steps:

# Checkout main branch of repository:
- name: 'Checkout main branch'
uses: actions/checkout@v3
with:
ref: main

# Increment version:
- name: 'Increment version in `package.json` to the version number of the tag'
run: |
VERSION=$(echo ${{ github.ref }} | sed -E 's/refs\/tags\/v?([0-9]+.[0-9]+.[0-9]+).*/\1/')
sed -Ei "s/\"version\": \"[^\"]+\"/\"version\": \"$VERSION\"/g" package.json
# Configure git:
- name: 'Configure git'
run: |
git config --local user.email "[email protected]"
git config --local user.name "stdlib-bot"
# Commit changes:
- name: 'Commit changes'
run: |
git add package.json
git commit -m "Auto-generated commit"
# Push changes:
- name: 'Push changes'
run: |
SLUG=${{ github.repository }}
echo "Pushing changes to $SLUG..."
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" main
# Define job to cancel any running or queued workflow runs...
cancel:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ on:
# Allow the workflow to be manually run:
workflow_dispatch:

# Run workflow on each push:
# Run workflow on each push to the main branch:
push:

# Workflow jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# Upload coverage report to Codecov:
- name: 'Upload coverage to Codecov'
id: upload
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
directory: reports/coverage
flags: unittests
Expand Down
Loading

0 comments on commit 1ee4767

Please sign in to comment.