2022-08-16 17:42:26 +00:00
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
set -uex
|
|
|
|
|
|
|
|
|
|
rustup default nightly
|
|
|
|
|
|
2022-08-19 13:30:54 +00:00
|
|
|
|
PYO3_VERSION=$(cargo search pyo3 --limit 1 | head -1 | tr -s ' ' | cut -d ' ' -f 3 | tr -d '"')
|
|
|
|
|
mkdir netlify_build
|
|
|
|
|
|
|
|
|
|
## Configure netlify _redirects file
|
|
|
|
|
|
|
|
|
|
# TODO: have some better system to automatically generate this on build rather
|
|
|
|
|
# than check this in to the repo
|
|
|
|
|
cp .netlify/_redirects netlify_build/
|
|
|
|
|
|
|
|
|
|
# Add latest redirect (proxy)
|
2022-08-21 07:15:11 +00:00
|
|
|
|
echo "/latest/* https://pyo3.github.io/pyo3/v${PYO3_VERSION}/:splat 200" >> netlify_build/_redirects
|
2022-08-19 13:30:54 +00:00
|
|
|
|
|
|
|
|
|
## Add landing page redirect
|
2022-09-07 02:11:09 +00:00
|
|
|
|
if [ "${CONTEXT}" == "deploy-preview" ]; then
|
|
|
|
|
echo "<meta http-equiv=refresh content=0;url=main/>" > netlify_build/index.html
|
|
|
|
|
else
|
|
|
|
|
echo "<meta http-equiv=refresh content=0;url=v${PYO3_VERSION}/>" > netlify_build/index.html
|
|
|
|
|
fi
|
2022-08-19 13:30:54 +00:00
|
|
|
|
|
2022-09-08 06:58:53 +00:00
|
|
|
|
## Generate towncrier release notes
|
|
|
|
|
|
|
|
|
|
pip install towncrier
|
|
|
|
|
towncrier build --yes --version Unreleased --date TBC
|
2022-08-19 13:30:54 +00:00
|
|
|
|
|
|
|
|
|
## Build guide
|
|
|
|
|
|
2022-08-16 17:42:26 +00:00
|
|
|
|
# Install latest mdbook. Netlify will cache the cargo bin dir, so this will
|
|
|
|
|
# only build mdbook if needed.
|
|
|
|
|
MDBOOK_VERSION=$(cargo search mdbook --limit 1 | head -1 | tr -s ' ' | cut -d ' ' -f 3 | tr -d '"')
|
|
|
|
|
INSTALLED_MDBOOK_VERSION=$(mdbook --version || echo "none")
|
|
|
|
|
if [ "${INSTALLED_MDBOOK_VERSION}" != "mdbook v${MDBOOK_VERSION}" ]; then
|
2022-11-30 08:31:00 +00:00
|
|
|
|
cargo install mdbook@${MDBOOK_VERSION} --force
|
2022-08-16 17:42:26 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
pip install nox
|
|
|
|
|
nox -s build-guide
|
|
|
|
|
mv target/guide netlify_build/main/
|
|
|
|
|
|
2022-08-19 13:30:54 +00:00
|
|
|
|
## Build public docs
|
|
|
|
|
|
2022-08-16 17:42:26 +00:00
|
|
|
|
cargo xtask doc
|
|
|
|
|
mv target/doc netlify_build/main/doc/
|
|
|
|
|
|
2022-09-07 06:46:24 +00:00
|
|
|
|
echo "<meta http-equiv=refresh content=0;url=pyo3/>" > netlify_build/main/doc/index.html
|
|
|
|
|
|
2022-08-19 13:30:54 +00:00
|
|
|
|
## Build internal docs
|
2022-08-16 17:42:26 +00:00
|
|
|
|
|
2022-08-19 13:30:54 +00:00
|
|
|
|
echo "<div class='internal-banner' style='position:fixed; z-index: 99999; color:red;border:3px solid red;margin-left: auto; margin-right: auto; width: 430px;left:0;right: 0;'><div style='display: flex; align-items: center; justify-content: center;'> ⚠️ Internal Docs ⚠️ Not Public API 👉 <a href='https://pyo3.rs/main/doc/pyo3/index.html' style='color:red;text-decoration:underline;'>Official Docs Here</a></div></div>" > netlify_build/banner.html
|
|
|
|
|
RUSTDOCFLAGS="--html-before-content netlify_build/banner.html" cargo xtask doc --internal
|
|
|
|
|
rm netlify_build/banner.html
|
2022-08-16 17:42:26 +00:00
|
|
|
|
|
2022-08-19 13:30:54 +00:00
|
|
|
|
mkdir -p netlify_build/internal
|
|
|
|
|
mv target/doc netlify_build/internal/
|
2022-08-16 17:42:26 +00:00
|
|
|
|
|
|
|
|
|
ls -l netlify_build/
|