Skip to content

Commit 63f390c

Browse files
authored
Create deno.yml
1 parent 11bc7ea commit 63f390c

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

.github/workflows/deno.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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: deno
21+
22+
# Workflow triggers:
23+
on:
24+
workflow_dispatch:
25+
push:
26+
27+
# Workflow jobs:
28+
jobs:
29+
publish-deno:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v2
33+
- name: Copy files to deno directory
34+
run: |
35+
mkdir -p deno
36+
cp README.md LICENSE CONTRIBUTORS NOTICE ./deno
37+
38+
# Copy TypeScript definitions to deno directory:
39+
if [ -d index.d.ts ]; then
40+
cp index.d.ts ./deno/index.d.ts
41+
fi
42+
if [ -e ./docs/types/index.d.ts ]; then
43+
cp ./docs/types/index.d.ts ./deno/mod.d.ts
44+
fi
45+
- name: Bundle package for Deno
46+
id: deno-bundle
47+
uses: stdlib-js/deno-bundle-action@main
48+
- name: Rewrite file contents
49+
run: |
50+
# Replace links to other packages with links to the deno branch:
51+
find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/";
52+
53+
# Replace reference to `@stdlib/types` with deno.land link:
54+
find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ <reference types=\"@stdlib\/types\"\/>/\/\/\/ <reference types=\"https:\/\/deno.land\/x\/stdlib_types\/index.d.ts\"\/>/g"
55+
56+
# Change wording of project description to avoid reference to JavaScript and Node.js:
57+
find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g"
58+
59+
# Rewrite all `require()`s to use jsDelivr links:
60+
find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// {
61+
s/(var|let|const)\s+([^\s]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/
62+
s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/
63+
s/';/@deno\/mod.js';/
64+
}"
65+
66+
# Remove `installation`, `cli`, and `c` sections:
67+
find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"installation\">[^<]+<\/section>//g;"
68+
find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"cli\">[\s\S]+<\!\-\- \/.cli \-\->//g"
69+
find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"c\">[\s\S]+<\!\-\- \/.c \-\->//g"
70+
71+
- name: Publish to deno branch
72+
uses: peaceiris/actions-gh-pages@v3
73+
with:
74+
github_token: ${{ secrets.GITHUB_TOKEN }}
75+
publish_dir: ./deno
76+
publish_branch: deno
77+
keep_files: true
78+
user_name: 'stdlib-bot'
79+
user_email: 'noreply@stdlib.io'
80+
commit_message: 'Auto-generated commit'
81+
enable_jekyll: true

0 commit comments

Comments
 (0)