Skip to content

Commit 2daec48

Browse files
committed
Auto-generated commit
1 parent 5508bc0 commit 2daec48

15 files changed

+489
-326
lines changed

.github/workflows/benchmark.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
benchmark:
2929
runs-on: ubuntu-latest
3030
steps:
31-
- uses: actions/checkout@v2
31+
- uses: actions/checkout@v3
3232
- uses: actions/setup-node@v2
3333
with:
3434
node-version: 16

.github/workflows/bundle.yml

+155-46
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,20 @@ name: bundle
2222
# Workflow triggers:
2323
on:
2424
workflow_dispatch:
25-
push:
26-
branches:
27-
- main
28-
tags_ignore:
29-
- 'v[0-9]+\.[0-9]+\.[0-9]+'
25+
workflow_run:
26+
workflows: ["productionize"]
27+
types: [completed]
3028

3129
# Workflow jobs:
3230
jobs:
3331
deno:
3432
runs-on: ubuntu-latest
3533
steps:
36-
- uses: actions/checkout@v2
34+
- uses: actions/checkout@v3
35+
- name: Checkout production branch
36+
run: |
37+
git fetch --all
38+
git checkout -b production origin/production
3739
- name: Copy files to deno directory
3840
run: |
3941
mkdir -p deno
@@ -85,18 +87,51 @@ jobs:
8587
8688
# Create package.json file for deno branch:
8789
jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json
88-
89-
- name: Publish to deno branch
90-
uses: peaceiris/actions-gh-pages@v3
91-
with:
92-
github_token: ${{ secrets.GITHUB_TOKEN }}
93-
publish_dir: ./deno
94-
publish_branch: deno
95-
keep_files: true
96-
user_name: 'stdlib-bot'
97-
user_email: 'noreply@stdlib.io'
98-
commit_message: 'Auto-generated commit'
99-
enable_jekyll: true
90+
- name: Configure git
91+
run: |
92+
git config --local user.email "noreply@stdlib.io"
93+
git config --local user.name "stdlib-bot"
94+
- name: Check if remote `deno` branch exists
95+
id: deno-branch-exists
96+
continue-on-error: true
97+
run: |
98+
git ls-remote --exit-code --heads origin deno
99+
if [ $? -eq 0 ]; then
100+
echo "::set-output name=remote-exists::true"
101+
else
102+
echo "::set-output name=remote-exists::false"
103+
fi
104+
- name: If `deno` exists, checkout branch and rebase on `main`
105+
if: steps.deno-branch-exists.outputs.remote-exists
106+
continue-on-error: true
107+
run: |
108+
git checkout -b deno origin/deno
109+
git rebase main -s recursive -X ours
110+
while [ $? -ne 0 ]; do
111+
git rebase --skip
112+
done
113+
- name: If `deno` does not exist, checkout `main` and create `deno` branch
114+
if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }}
115+
run: |
116+
git checkout main
117+
git checkout -b deno
118+
- name: Delete everything in current directory aside from deno folder
119+
run: |
120+
find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm
121+
find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf
122+
- name: Move deno directory to root
123+
run: |
124+
mv ./deno/* .
125+
rmdir ./deno
126+
- name: Commit changes
127+
run: |
128+
git add -A
129+
git commit -m "Auto-generated commit"
130+
- name: Push changes
131+
run: |
132+
SLUG=${{ github.repository }}
133+
echo "Pushing changes to $SLUG..."
134+
git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno --force
100135
- name: Send status to Slack channel in case of failure
101136
uses: act10ns/slack@v1
102137
with:
@@ -107,7 +142,11 @@ jobs:
107142
umd:
108143
runs-on: ubuntu-latest
109144
steps:
110-
- uses: actions/checkout@v2
145+
- uses: actions/checkout@v3
146+
- name: Checkout production branch
147+
run: |
148+
git fetch --all
149+
git checkout -b production origin/production
111150
- name: Copy files to umd directory
112151
run: |
113152
mkdir -p umd
@@ -121,7 +160,7 @@ jobs:
121160
run: |
122161
npm install || npm install || npm install
123162
timeout-minutes: 15
124-
- name: Extract Alias
163+
- name: Extract alias
125164
id: extract-alias
126165
run: |
127166
alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/')
@@ -153,22 +192,55 @@ jobs:
153192
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "1 while s/<script type=\"text\/javascript\">\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);?/<script type=\"text\/javascript\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/bundle.js\"><\/script>\n<script type=\"text\/javascript\">/g"
154193
155194
# Wrap contents of `<script type="text/javascript">` tag contents in an IIFE:
156-
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"
195+
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"
157196
158197
# Create package.json file for umd branch:
159198
jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "main": "./bundle.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./umd/package.json
160-
161-
- name: Publish to umd branch
162-
uses: peaceiris/actions-gh-pages@v3
163-
with:
164-
github_token: ${{ secrets.GITHUB_TOKEN }}
165-
publish_dir: ./umd
166-
publish_branch: umd
167-
keep_files: true
168-
user_name: 'stdlib-bot'
169-
user_email: 'noreply@stdlib.io'
170-
commit_message: 'Auto-generated commit'
171-
enable_jekyll: true
199+
- name: Configure git
200+
run: |
201+
git config --local user.email "noreply@stdlib.io"
202+
git config --local user.name "stdlib-bot"
203+
- name: Check if remote `umd` branch exists
204+
id: umd-branch-exists
205+
continue-on-error: true
206+
run: |
207+
git ls-remote --exit-code --heads origin umd
208+
if [ $? -eq 0 ]; then
209+
echo "::set-output name=remote-exists::true"
210+
else
211+
echo "::set-output name=remote-exists::false"
212+
fi
213+
- name: If `umd` exists, checkout branch and rebase on `main`
214+
if: steps.umd-branch-exists.outputs.remote-exists
215+
continue-on-error: true
216+
run: |
217+
git checkout -b umd origin/umd
218+
git rebase main -s recursive -X ours
219+
while [ $? -ne 0 ]; do
220+
git rebase --skip
221+
done
222+
- name: If `umd` does not exist, checkout `main` and create `umd` branch
223+
if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }}
224+
run: |
225+
git checkout main
226+
git checkout -b umd
227+
- name: Delete everything in current directory aside from umd folder
228+
run: |
229+
find . -type 'f' | grep -v -e "umd" -e ".git/" | xargs rm
230+
find . -mindepth 1 -type 'd' | grep -v -e "umd" -e ".git" | xargs rm -rf
231+
- name: Move umd directory to root
232+
run: |
233+
mv ./umd/* .
234+
rmdir ./umd
235+
- name: Commit changes
236+
run: |
237+
git add -A
238+
git commit -m "Auto-generated commit"
239+
- name: Push changes
240+
run: |
241+
SLUG=${{ github.repository }}
242+
echo "Pushing changes to $SLUG..."
243+
git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" umd --force
172244
- name: Send status to Slack channel in case of failure
173245
uses: act10ns/slack@v1
174246
with:
@@ -179,7 +251,11 @@ jobs:
179251
esm:
180252
runs-on: ubuntu-latest
181253
steps:
182-
- uses: actions/checkout@v2
254+
- uses: actions/checkout@v3
255+
- name: Checkout production branch
256+
run: |
257+
git fetch --all
258+
git checkout -b production origin/production
183259
- name: Copy files to umd directory
184260
run: |
185261
mkdir -p esm
@@ -235,18 +311,51 @@ jobs:
235311
236312
# Create package.json file for esm branch:
237313
jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./index.mjs", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./esm/package.json
238-
239-
- name: Publish to esm branch
240-
uses: peaceiris/actions-gh-pages@v3
241-
with:
242-
github_token: ${{ secrets.GITHUB_TOKEN }}
243-
publish_dir: ./esm
244-
publish_branch: esm
245-
keep_files: true
246-
user_name: 'stdlib-bot'
247-
user_email: 'noreply@stdlib.io'
248-
commit_message: 'Auto-generated commit'
249-
enable_jekyll: true
314+
- name: Configure git
315+
run: |
316+
git config --local user.email "noreply@stdlib.io"
317+
git config --local user.name "stdlib-bot"
318+
- name: Check if remote `esm` branch exists
319+
id: esm-branch-exists
320+
continue-on-error: true
321+
run: |
322+
git ls-remote --exit-code --heads origin esm
323+
if [ $? -eq 0 ]; then
324+
echo "::set-output name=remote-exists::true"
325+
else
326+
echo "::set-output name=remote-exists::false"
327+
fi
328+
- name: If `esm` exists, checkout branch and rebase on `main`
329+
if: steps.esm-branch-exists.outputs.remote-exists
330+
continue-on-error: true
331+
run: |
332+
git checkout -b esm origin/esm
333+
git rebase main -s recursive -X ours
334+
while [ $? -ne 0 ]; do
335+
git rebase --skip
336+
done
337+
- name: If `esm` does not exist, checkout `main` and create `esm` branch
338+
if: ${{ steps.esm-branch-exists.outputs.remote-exists == false }}
339+
run: |
340+
git checkout main
341+
git checkout -b esm
342+
- name: Delete everything in current directory aside from esm folder
343+
run: |
344+
find . -type 'f' | grep -v -e "esm" -e ".git/" | xargs rm
345+
find . -mindepth 1 -type 'd' | grep -v -e "esm" -e ".git" | xargs rm -rf
346+
- name: Move esm directory to root
347+
run: |
348+
mv ./esm/* .
349+
rmdir ./esm
350+
- name: Commit changes
351+
run: |
352+
git add -A
353+
git commit -m "Auto-generated commit"
354+
- name: Push changes
355+
run: |
356+
SLUG=${{ github.repository }}
357+
echo "Pushing changes to $SLUG..."
358+
git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" esm --force
250359
- name: Send status to Slack channel in case of failure
251360
uses: act10ns/slack@v1
252361
with:

.github/workflows/cancel.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#/
1818

1919
# Workflow name:
20-
name: Cancel Workflow Runs
20+
name: cancel
2121

2222
# Workflow triggers:
2323
on:

.github/workflows/close_pull_requests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#/
1818

1919
# Workflow name:
20-
name: Close Pull Requests
20+
name: close_pull_requests
2121

2222
# Workflow triggers:
2323
on:

.github/workflows/examples.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
examples:
2929
runs-on: ubuntu-latest
3030
steps:
31-
- uses: actions/checkout@v2
31+
- uses: actions/checkout@v3
3232
- uses: actions/setup-node@v2
3333
with:
3434
node-version: 16

.github/workflows/productionize.yml

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2022 The Stdlib Authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#/
18+
19+
# Workflow name:
20+
name: productionize
21+
22+
# Workflow triggers:
23+
on:
24+
push:
25+
workflow_dispatch:
26+
27+
# Workflow jobs:
28+
jobs:
29+
productionize:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout main branch
33+
uses: actions/checkout@v3
34+
with:
35+
ref: main
36+
- name: Create new `production` branch
37+
run: |
38+
git checkout -b production
39+
- name: Transform Error Messages
40+
id: transform-error-messages
41+
uses: stdlib-js/transform-errors-action@main
42+
- name: Replace double quotes with single quotes in rewritten format string error messages
43+
run: |
44+
find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \;
45+
- name: Replace double quotes with single quotes in rewritten string literal error messages
46+
run: |
47+
find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \;
48+
- name: Replace double quotes with single quotes in inserted `require` calls
49+
run: |
50+
find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \;
51+
- name: Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency
52+
run: |
53+
if grep -q '"@stdlib/string-format"' package.json; then
54+
sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json
55+
else
56+
sed -i "s/\"dependencies\": {/\"dependencies\": {\\n \"@stdlib\/error-tools-fmtprodmsg\": \"^0.0.x\",/g" package.json
57+
fi
58+
- name: Configure git
59+
run: |
60+
git config --local user.email "noreply@stdlib.io"
61+
git config --local user.name "stdlib-bot"
62+
- name: Commit changes
63+
run: |
64+
git add -A
65+
git commit -m "Transform error messages"
66+
- name: Push changes
67+
run: |
68+
SLUG=${{ github.repository }}
69+
echo "Pushing changes to $SLUG..."
70+
git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force
71+
test:
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v3
75+
with:
76+
ref: production
77+
- uses: actions/setup-node@v2
78+
with:
79+
node-version: 16
80+
timeout-minutes: 5
81+
- name: Install production and development dependencies
82+
id: install
83+
run: |
84+
npm install || npm install || npm install
85+
timeout-minutes: 15
86+
- name: Build native add-on (if present)
87+
run: |
88+
if [ -f "binding.gyp" ]; then
89+
npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild
90+
fi
91+
- name: Run tests
92+
id: tests
93+
run: |
94+
npm test || npm test || npm test

0 commit comments

Comments
 (0)