diff --git a/bin/build-changelog.sh b/bin/build-changelog.sh
index 1f01ead7d..32e8dddef 100755
--- a/bin/build-changelog.sh
+++ b/bin/build-changelog.sh
@@ -1,8 +1,17 @@
#!/usr/bin/env bash
+# Run `sed` in a way that's compatible with both macOS (BSD) and Linux (GNU)
+sedi() {
+ if [[ "$OSTYPE" == "darwin"* ]]; then
+ sed -i '' "$@"
+ else
+ sed -i "$@"
+ fi
+}
+
cd docs
cp ../CHANGELOG.md source/tutorials/changelog.md
-sed -i \
+sedi \
-e 's/{%/{% raw %}{%{% endraw %}/g' \
-e 's/{{/{% raw %}{{{% endraw %}/g' \
-e '1 s/"/\"/g' \
@@ -11,5 +20,7 @@ sed -i \
source/tutorials/changelog.md
cp source/tutorials/changelog.md source/zh-cn/tutorials/changelog.md
-sed -i '1i ---\ntitle: Changelog\nauto: true\n---\n' source/tutorials/changelog.md
-sed -i '1i ---\ntitle: 更新日志\nauto: true\n---\n' source/zh-cn/tutorials/changelog.md
+sedi -e '1i\
+ ---\ntitle: Changelog\nauto: true\n---\n' source/tutorials/changelog.md
+sedi -e '1i\
+ ---\ntitle: 更新日志\nauto: true\n---\n' source/zh-cn/tutorials/changelog.md
diff --git a/bin/build-contributors.sh b/bin/build-contributors.sh
index 036b43bda..bceae5e21 100755
--- a/bin/build-contributors.sh
+++ b/bin/build-contributors.sh
@@ -1,10 +1,19 @@
#!/usr/bin/env bash
+# Run `sed` in a way that's compatible with both macOS (BSD) and Linux (GNU)
+sedi() {
+ if [[ "$OSTYPE" == "darwin"* ]]; then
+ sed -i '' "$@"
+ else
+ sed -i "$@"
+ fi
+}
+
cp .all-contributorsrc docs/.all-contributorsrc
-sed -i \
- -e 's/README.md/docs\/themes\/navy\/layout\/partial\/all-contributors.swig/g' \
- -e 's/"contributorsPerLine": 7/"contributorsPerLine": 65535/g' \
- docs/.all-contributorsrc
+sedi \
+ -e 's/README.md/docs\/themes\/navy\/layout\/partial\/all-contributors.swig/g' \
+ -e 's/"contributorsPerLine": 7/"contributorsPerLine": 65535/g' \
+ docs/.all-contributorsrc
all-contributors --config docs/.all-contributorsrc generate
-sed -i 's/
.*<\/td>/<\/a><\/td>/g' docs/themes/navy/layout/partial/all-contributors.swig
+sedi 's/
.*<\/td>/<\/a><\/td>/g' docs/themes/navy/layout/partial/all-contributors.swig