@@ -22,18 +22,20 @@ name: bundle
22
22
# Workflow triggers:
23
23
on :
24
24
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]
30
28
31
29
# Workflow jobs:
32
30
jobs :
33
31
deno :
34
32
runs-on : ubuntu-latest
35
33
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
37
39
- name : Copy files to deno directory
38
40
run : |
39
41
mkdir -p deno
@@ -85,18 +87,51 @@ jobs:
85
87
86
88
# Create package.json file for deno branch:
87
89
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
100
135
- name : Send status to Slack channel in case of failure
101
136
uses : act10ns/slack@v1
102
137
with :
@@ -107,7 +142,11 @@ jobs:
107
142
umd :
108
143
runs-on : ubuntu-latest
109
144
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
111
150
- name : Copy files to umd directory
112
151
run : |
113
152
mkdir -p umd
@@ -121,7 +160,7 @@ jobs:
121
160
run : |
122
161
npm install || npm install || npm install
123
162
timeout-minutes : 15
124
- - name : Extract Alias
163
+ - name : Extract alias
125
164
id : extract-alias
126
165
run : |
127
166
alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/')
@@ -153,22 +192,55 @@ jobs:
153
192
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"
154
193
155
194
# 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"
157
196
158
197
# Create package.json file for umd branch:
159
198
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
172
244
- name : Send status to Slack channel in case of failure
173
245
uses : act10ns/slack@v1
174
246
with :
@@ -179,7 +251,11 @@ jobs:
179
251
esm :
180
252
runs-on : ubuntu-latest
181
253
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
183
259
- name : Copy files to umd directory
184
260
run : |
185
261
mkdir -p esm
@@ -235,18 +311,51 @@ jobs:
235
311
236
312
# Create package.json file for esm branch:
237
313
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
250
359
- name : Send status to Slack channel in case of failure
251
360
uses : act10ns/slack@v1
252
361
with :
0 commit comments