Skip to content

Commit 8e367dc

Browse files
ci: test no-config build
1 parent ba9a4d7 commit 8e367dc

File tree

4 files changed

+86
-50
lines changed

4 files changed

+86
-50
lines changed

.github/workflows/ci.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ jobs:
7676
- kind: ja-JP
7777
tag: latest
7878
base: "/docs/"
79+
- kind: no-config
80+
tag: v0.14.1
81+
base: "/docs/"
7982
name: |
8083
Build for ${{ matrix.kind }} ${{ matrix.tag }} (base: ${{ matrix.base }})
8184
steps:
@@ -89,11 +92,15 @@ jobs:
8992
if: ${{ matrix.kind == 'ja-JP' }}
9093
run: bun run fetch-docs-ja-jp
9194
- name: Fetch docs assets
92-
if: ${{ matrix.kind == 'official' }}
95+
if: ${{ matrix.kind == 'official' || matrix.kind == 'no-config' }}
9396
shell: bash
9497
run: |
9598
set -euxo pipefail
96-
bash scripts/fetch-docs-assets.sh --tag "${{ matrix.tag }}" --base "${{ matrix.base }}" --dest public
99+
bash scripts/fetch-docs-assets.sh \
100+
--tag "${{ matrix.tag }}" \
101+
--base "${{ matrix.base }}" \
102+
${{ matrix.kind == 'no-config' && '--skip metadata --skip favicon' || '' }} \
103+
--dest public
97104
98105
- name: Run Vite build
99106
run: bun run build

scripts/fetch-docs-assets.sh

Lines changed: 71 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ set -euo pipefail
77

88
print_usage() {
99
cat <<'EOF'
10-
Usage: fetch-docs-assets.sh [--tag TAG] [--base BASE] [--dest DEST] [--origin ORIGIN]
10+
Usage: fetch-docs-assets.sh [--tag TAG] [--base BASE] [options...]
1111
1212
Environment/args:
1313
--tag TAG (required) Release tag to download, e.g. v0.14.0 or latest
1414
--base BASE (required) Base path used by docs, e.g. / or /docs/
1515
--dest DEST (optional) Destination directory to write files (default: public)
1616
--origin ORIGIN (optional) Origin URL for the deployed site, without base path (default: https://example.com/)
17+
--skip FILE (optional) Skip one of the files (docs.json, docs-assets, favicon, metadata), can be specified multiple times
1718
1819
This script performs the following:
19-
- Downloads docs.json from the release tag
20-
- Replaces '/DOCS-BASE/' placeholder in docs.json with the provided base
21-
- Downloads docs-assets.zip and extracts it to destination/assets
22-
- Downloads favicon and writes to destination/favicon.png
23-
- Generates destination/metadata.json with basic deployment metadata
20+
- docs.json:
21+
- Downloads docs.json from the release tag
22+
- Replaces '/DOCS-BASE/' placeholder in docs.json with the provided base
23+
- docs-assets: Downloads docs-assets.zip and extracts it to destination/assets
24+
- favicon: Downloads favicon and writes to destination/favicon.png
25+
- metadata: Generates destination/metadata.json with basic deployment metadata
2426
EOF
2527
}
2628

@@ -30,6 +32,7 @@ DEST="public"
3032
ORIGIN="https://example.com/"
3133
TAG=""
3234
BASE=""
35+
SKIP=()
3336

3437
# Parse args
3538
while [[ $# -gt 0 ]]; do
@@ -50,6 +53,19 @@ while [[ $# -gt 0 ]]; do
5053
ORIGIN="$2"
5154
shift 2
5255
;;
56+
--skip)
57+
case "$2" in
58+
docs.json | docs-assets | favicon | metadata)
59+
SKIP+=("$2")
60+
shift 2
61+
;;
62+
*)
63+
echo "Invalid --skip option: $2" >&2
64+
print_usage
65+
exit 2
66+
;;
67+
esac
68+
;;
5369
--help | -h)
5470
print_usage
5571
exit 0
@@ -80,52 +96,67 @@ fi
8096
RELEASE_BASE_URL="https://github.com/${ORG}/dev-builds/releases/download/docs-${TAG}"
8197

8298
# Download docs.json
83-
DOCS_URL="${RELEASE_BASE_URL}/docs.json"
84-
echo "Fetching docs from ${DOCS_URL}"
85-
if ! curl -sSfL "$DOCS_URL" -o "${DEST}/docs.json"; then
86-
echo "Failed to download docs.json from ${DOCS_URL}" >&2
87-
exit 3
88-
fi
89-
90-
# Replace placeholder '/DOCS-BASE/' with provided base in docs.json
91-
# Use `sd` if available, else fallback to sed
92-
if command -v sd >/dev/null 2>&1; then
93-
sd '/DOCS-BASE/' "$BASE" "${DEST}/docs.json"
99+
if printf '%s\n' "${SKIP[@]}" | grep -qx "docs.json"; then
100+
echo "Skipping docs.json download as per --skip option"
94101
else
95-
# Use portable sed: escape slashes
96-
ESCAPED_BASE=$(printf '%s' "$BASE" | sed 's|/|\\/|g')
97-
sed -i "s/\/DOCS-BASE\//${ESCAPED_BASE}/g" "${DEST}/docs.json"
102+
DOCS_URL="${RELEASE_BASE_URL}/docs.json"
103+
echo "Fetching docs from ${DOCS_URL}"
104+
if ! curl -sSfL "$DOCS_URL" -o "${DEST}/docs.json"; then
105+
echo "Failed to download docs.json from ${DOCS_URL}" >&2
106+
exit 3
107+
fi
108+
109+
# Replace placeholder '/DOCS-BASE/' with provided base in docs.json
110+
# Use `sd` if available, else fallback to sed
111+
if command -v sd >/dev/null 2>&1; then
112+
sd '/DOCS-BASE/' "$BASE" "${DEST}/docs.json"
113+
else
114+
# Use portable sed: escape slashes
115+
ESCAPED_BASE=$(printf '%s' "$BASE" | sed 's|/|\\/|g')
116+
sed -i "s/\/DOCS-BASE\//${ESCAPED_BASE}/g" "${DEST}/docs.json"
117+
fi
98118
fi
99119

100120
# Download assets and extract
101-
ASSETS_URL="${RELEASE_BASE_URL}/docs-assets.zip"
102-
ASSETS_ZIP="docs-assets.zip"
103-
if curl -sSfL "$ASSETS_URL" -o "$ASSETS_ZIP"; then
104-
echo "Extracting ${ASSETS_ZIP} to ${DEST}/assets"
105-
# Clean up existing assets if present
106-
rm -rf "${DEST}/assets"
107-
unzip -q "$ASSETS_ZIP"
108-
if [[ -d assets ]]; then
109-
mv assets "${DEST}/assets"
121+
if printf '%s\n' "${SKIP[@]}" | grep -qx "docs-assets"; then
122+
echo "Skipping docs-assets download as per --skip option"
123+
else
124+
ASSETS_URL="${RELEASE_BASE_URL}/docs-assets.zip"
125+
ASSETS_ZIP="docs-assets.zip"
126+
if curl -sSfL "$ASSETS_URL" -o "$ASSETS_ZIP"; then
127+
echo "Extracting ${ASSETS_ZIP} to ${DEST}/assets"
128+
# Clean up existing assets if present
129+
rm -rf "${DEST}/assets"
130+
unzip -q "$ASSETS_ZIP"
131+
if [[ -d assets ]]; then
132+
mv assets "${DEST}/assets"
133+
else
134+
echo "Downloaded zip did not contain assets/ folder" >&2
135+
# keep build going; not necessarily fatal
136+
fi
137+
rm -f "$ASSETS_ZIP"
110138
else
111-
echo "Downloaded zip did not contain assets/ folder" >&2
112-
# keep build going; not necessarily fatal
139+
echo "No assets ZIP was found at ${ASSETS_URL} (continuing without error)" >&2
113140
fi
114-
rm -f "$ASSETS_ZIP"
115-
else
116-
echo "No assets ZIP was found at ${ASSETS_URL} (continuing without error)" >&2
117141
fi
118142

119143
# Download favicon
120-
FAVICON_URL="https://github.com/${ORG}/org/raw/main/design/typst-community.icon.png"
121-
if curl -sSfL "$FAVICON_URL" -o "${DEST}/favicon.png"; then
122-
echo "Wrote favicon to ${DEST}/favicon.png"
144+
if printf '%s\n' "${SKIP[@]}" | grep -qx "favicon"; then
145+
echo "Skipping favicon download as per --skip option"
123146
else
124-
echo "Failed to download favicon from ${FAVICON_URL} (continuing without error)" >&2
147+
FAVICON_URL="https://github.com/${ORG}/org/raw/main/design/typst-community.icon.png"
148+
if curl -sSfL "$FAVICON_URL" -o "${DEST}/favicon.png"; then
149+
echo "Wrote favicon to ${DEST}/favicon.png"
150+
else
151+
echo "Failed to download favicon from ${FAVICON_URL} (continuing without error)" >&2
152+
fi
125153
fi
126154

127155
# Write metadata.json
128-
cat >"${DEST}/metadata.json" <<EOF
156+
if printf '%s\n' "${SKIP[@]}" | grep -qx "metadata"; then
157+
echo "Skipping metadata generation as per --skip option"
158+
else
159+
cat >"${DEST}/metadata.json" <<EOF
129160
{
130161
"\$schema": "../metadata.schema.json",
131162
"language": "en-US",
@@ -145,6 +176,7 @@ cat >"${DEST}/metadata.json" <<EOF
145176
"displayTranslationStatus": false
146177
}
147178
EOF
179+
fi
148180

149181
# Done
150182
printf '\nFetch docs assets script done.\n'

scripts/netlify-build.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@ build_en_US v0.13.1
101101
# At present, typst-jp do not translate comments within example code.
102102
# And there is no simple way to download assets from GitHub Actions or the gh-pages branch.
103103
# Therefore, we reuse the assets from the official version.
104-
bash scripts/fetch-docs-assets.sh --tag "v0.13.1" --base "/irrelevant/"
105-
rm public/{docs,metadata}.json
104+
bash scripts/fetch-docs-assets.sh \
105+
--tag "v0.13.1" \
106+
--base "/irrelevant/" \
107+
--skip docs.json \
108+
--skip metadata
106109

107110
# Prepare JSON files
108111
mise exec -- bun run fetch-docs-ja-jp

src/metadata.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,7 @@ const metadata: Metadata = (() => {
4646
typstOfficialUrl: "https://typst.app/",
4747
typstOfficialDocsUrl: "https://typst.app/docs/",
4848
githubOrganizationUrl: "https://github.com/typst",
49-
socialLinks: [
50-
{ url: "https://github.com/typst/typst" },
51-
{
52-
title: "Discord (dummy)",
53-
url: "https://discord.gg/dummy",
54-
},
55-
],
49+
socialLinks: [{ url: "https://github.com/typst/typst" }],
5650
originUrl: "https://example.com/",
5751
basePath: "/docs/",
5852
displayTranslationStatus: true,

0 commit comments

Comments
 (0)