Files
matrix-authentication-service/misc/build-docs.sh
T
Quentin Gliech 4bd083e81d ci: install pnpm via pnpm/action-setup, move CLI tools to root devDeps
All workflows that previously ran `npm ci` + a frontend script now install
pnpm via pnpm/action-setup (which honors the `packageManager` field in the
root package.json) and run scripts through `pnpm --filter mas-frontend`.
setup-node gets `cache: "pnpm"` so the pnpm store survives between runs.

The @localazy/cli and semver CLIs used by the release/translation workflows
move from ad-hoc `npm install -g` / `npx --yes` invocations to root
devDependencies, so the version is locked in pnpm-lock.yaml and a single
`pnpm install --frozen-lockfile` makes both available as `pnpm exec`.

misc/build-docs.sh (used by the docs workflow and Cloudflare Pages) is
updated to call `corepack enable` on Cloudflare Pages and to run storybook
through `pnpm --filter mas-frontend exec`.
2026-05-12 12:51:20 +02:00

60 lines
2.0 KiB
Bash

#!/bin/sh
# Copyright 2025 New Vector Ltd.
#
# SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
# Please see LICENSE files in the repository root for full details.
#
# This script is used by the Cloudflare Pages to build the documentation.
# It detects if it's running in the Cloudflare Pages build environment and will install the required dependencies.
# It can also be used locally to build the documentation, given that the required dependencies are installed.
set -eux
# Install the dependencies if we're in the Cloudflare Pages build environment
# In this environment, the CF_PAGES environment variable is set to 1
if [ "${CF_PAGES:-""}" = "1" ]; then
MDBOOK_VERSION=0.5.0
# Install rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
# Source the environment variables to add cargo to the path
. "$HOME/.cargo/env"
# Install the minimal toolchain, which includes rustc, rustdoc, and cargo
rustup toolchain install stable --profile minimal
# Install mdbook
MDBOOK_URL="https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-$(uname -m)-unknown-linux-gnu.tar.gz"
curl --proto '=https' --tlsv1.2 -sSfL "${MDBOOK_URL}" | tar -C "$HOME/.cargo/bin" -xzv
# Enable pnpm via corepack (Node and corepack are pre-installed on Cloudflare Pages)
corepack enable
fi
# Sanity check
rustdoc --version
rustc --version
cargo --version
mdbook --version
pnpm --version
# Build the docs
mdbook build
# Build the rustdoc
# This is required to be able to use the unstable `-Zrustdoc-map` flag
env RUSTC_BOOTSTRAP=1 \
cargo doc -Zrustdoc-map --workspace --lib --no-deps
# Delete the rustdoc lockfile
rm target/doc/.lock
# Move the Rust documentation within the mdBook
rm -rf target/book/rustdoc
mv target/doc target/book/rustdoc
# Build the frontend storybook
pnpm install --frozen-lockfile
pnpm --filter mas-frontend exec storybook build -o ../target/book/storybook