diff --git a/.cloudflare/docs-proxy/src/worker.js b/.cloudflare/docs-proxy/src/worker.js
index f9f441883ad9b86fe1156277489cc6451c2ff316..60b4a67054d69501f05d3048809cc42a76a38efb 100644
--- a/.cloudflare/docs-proxy/src/worker.js
+++ b/.cloudflare/docs-proxy/src/worker.js
@@ -1,8 +1,17 @@
export default {
async fetch(request, _env, _ctx) {
const url = new URL(request.url);
- url.hostname = "docs-anw.pages.dev";
+ let hostname;
+ if (url.pathname.startsWith("/docs/nightly")) {
+ hostname = "docs-nightly.pages.dev";
+ } else if (url.pathname.startsWith("/docs/preview")) {
+ hostname = "docs-preview.pages.dev";
+ } else {
+ hostname = "docs-anw.pages.dev";
+ }
+
+ url.hostname = hostname;
let res = await fetch(url, request);
if (res.status === 404) {
diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml
index 0920fe4da5c3d06a03f9d32889f3f68c3095c058..61db90aee4fce70842808f18adf3a4898247bd3e 100644
--- a/.github/workflows/deploy_docs.yml
+++ b/.github/workflows/deploy_docs.yml
@@ -5,19 +5,73 @@ on:
push:
branches:
- main
- - staged-docs-releases
+ - preview
+ - stable
+ workflow_dispatch:
+ inputs:
+ channel:
+ description: 'Docs channel to deploy: nightly, preview, or stable'
+ type: string
+ default: nightly
jobs:
- deploy_docs_job:
+ deploy_docs:
if: github.repository_owner == 'zed-industries'
name: Build and Deploy Docs
runs-on: namespace-profile-16x32-ubuntu-2204
env:
DOCS_AMPLITUDE_API_KEY: ${{ secrets.DOCS_AMPLITUDE_API_KEY }}
+ MDBOOK_BOOK__SITE_URL: ${{ steps.resolve-channel.outputs.site_url }}
+ DOCS_CHANNEL: ${{ steps.resolve-channel.outputs.channel }}
steps:
- name: steps::checkout_repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
clean: false
+ - id: resolve-channel
+ name: deploy_docs::resolve_channel_step
+ run: |
+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
+ CHANNEL="${{ inputs.channel }}"
+ else
+ case "${{ github.ref }}" in
+ "refs/heads/main")
+ CHANNEL="nightly"
+ ;;
+ "refs/heads/preview")
+ CHANNEL="preview"
+ ;;
+ "refs/heads/stable")
+ CHANNEL="stable"
+ ;;
+ *)
+ echo "::error::Unsupported ref for docs deploy: ${{ github.ref }}"
+ exit 1
+ ;;
+ esac
+ fi
+
+ case "$CHANNEL" in
+ "nightly")
+ SITE_URL="/docs/nightly/"
+ PROJECT_NAME="docs-nightly"
+ ;;
+ "preview")
+ SITE_URL="/docs/preview/"
+ PROJECT_NAME="docs-preview"
+ ;;
+ "stable")
+ SITE_URL="/docs/"
+ PROJECT_NAME="docs"
+ ;;
+ *)
+ echo "::error::Invalid docs channel '$CHANNEL'. Expected one of: nightly, preview, stable."
+ exit 1
+ ;;
+ esac
+
+ echo "channel=$CHANNEL" >> "$GITHUB_OUTPUT"
+ echo "site_url=$SITE_URL" >> "$GITHUB_OUTPUT"
+ echo "project_name=$PROJECT_NAME" >> "$GITHUB_OUTPUT"
- name: steps::setup_cargo_config
run: |
mkdir -p ./../.cargo
@@ -55,12 +109,12 @@ jobs:
args: --no-progress --exclude '^http' 'target/deploy/docs'
fail: true
jobSummary: false
- - name: deploy_docs::deploy_docs_to_pages
+ - name: deploy_docs::pages_deploy_step
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- command: pages deploy target/deploy --project-name=docs
+ command: pages deploy target/deploy --project-name=${{ steps.resolve-channel.outputs.project_name }}
- name: deploy_docs::deploy_install_script
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
with:
diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml
index af47904c7ade90aed2bc9ac1297363152aafed2b..32de9f5d589254e9aa79fe2f66c99d1242804a83 100644
--- a/.github/workflows/run_tests.yml
+++ b/.github/workflows/run_tests.yml
@@ -505,11 +505,19 @@ jobs:
runs-on: namespace-profile-16x32-ubuntu-2204
env:
DOCS_AMPLITUDE_API_KEY: ${{ secrets.DOCS_AMPLITUDE_API_KEY }}
+ MDBOOK_BOOK__SITE_URL: ${{ steps.resolve-channel.outputs.site_url }}
+ DOCS_CHANNEL: ${{ steps.resolve-channel.outputs.channel }}
steps:
- name: steps::checkout_repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
clean: false
+ - id: resolve-channel
+ name: deploy_docs::static_channel_resolution_step
+ run: |
+ echo "channel=stable" >> "$GITHUB_OUTPUT"
+ echo "site_url=/docs/" >> "$GITHUB_OUTPUT"
+ echo "project_name=docs" >> "$GITHUB_OUTPUT"
- name: steps::setup_cargo_config
run: |
mkdir -p ./../.cargo
diff --git a/crates/docs_preprocessor/src/main.rs b/crates/docs_preprocessor/src/main.rs
index 6ef599542a5b2f511915d7435af192162a5dbd3b..78b96b532b042623f83792769f08e33ed05524a6 100644
--- a/crates/docs_preprocessor/src/main.rs
+++ b/crates/docs_preprocessor/src/main.rs
@@ -578,6 +578,12 @@ fn handle_postprocessing() -> Result<()> {
.expect("Default title not a string")
.to_string();
let amplitude_key = std::env::var("DOCS_AMPLITUDE_API_KEY").unwrap_or_default();
+ let docs_channel = std::env::var("DOCS_CHANNEL").unwrap_or_else(|_| "stable".to_string());
+ let noindex = if docs_channel == "nightly" || docs_channel == "preview" {
+ ""
+ } else {
+ ""
+ };
output.insert("html".to_string(), zed_html);
mdbook::Renderer::render(&mdbook::renderer::HtmlHandlebars::new(), &ctx)?;
@@ -647,6 +653,7 @@ fn handle_postprocessing() -> Result<()> {
zlog::trace!(logger => "Updating {:?}", pretty_path(&file, &root_dir));
let contents = contents.replace("#description#", meta_description);
let contents = contents.replace("#amplitude_key#", &litude_key);
+ let contents = contents.replace("#noindex#", noindex);
let contents = title_regex()
.replace(&contents, |_: ®ex::Captures| {
format!("
{}", meta_title)
diff --git a/docs/theme/index.hbs b/docs/theme/index.hbs
index 98f64d41c3eb86dfb335ecf0964f434c50fad0bb..31b22ccfe263063958ae51dec664c77d29d75bcf 100644
--- a/docs/theme/index.hbs
+++ b/docs/theme/index.hbs
@@ -30,6 +30,7 @@
{{#if is_print }}
{{/if}}
+ #noindex#
{{#if base_url}}
{{/if}}
diff --git a/tooling/xtask/src/tasks/workflows/deploy_docs.rs b/tooling/xtask/src/tasks/workflows/deploy_docs.rs
index b215f59f64b8ee3461c83bb494afdbbfa788f767..1711cac707f6de9d7bb80a375493492fbfea249e 100644
--- a/tooling/xtask/src/tasks/workflows/deploy_docs.rs
+++ b/tooling/xtask/src/tasks/workflows/deploy_docs.rs
@@ -1,11 +1,43 @@
-use gh_workflow::{Event, Expression, Job, Push, Run, Step, Use, Workflow};
+use gh_workflow::{Event, Expression, Job, Push, Run, Step, Use, Workflow, WorkflowDispatch};
use crate::tasks::workflows::{
- runners::{self, Platform},
+ runners,
steps::{self, FluentBuilder as _, NamedJob, named, release_job},
- vars,
+ vars::{self, StepOutput, WorkflowInput},
};
+pub(crate) enum DocsChannel {
+ Nightly,
+ Preview,
+ Stable,
+}
+
+impl DocsChannel {
+ pub(crate) fn site_url(&self) -> &'static str {
+ match self {
+ Self::Nightly => "/docs/nightly/",
+ Self::Preview => "/docs/preview/",
+ Self::Stable => "/docs/",
+ }
+ }
+
+ pub(crate) fn project_name(&self) -> &'static str {
+ match self {
+ Self::Nightly => "docs-nightly",
+ Self::Preview => "docs-preview",
+ Self::Stable => "docs",
+ }
+ }
+
+ pub(crate) fn channel_name(&self) -> &'static str {
+ match self {
+ Self::Nightly => "nightly",
+ Self::Preview => "preview",
+ Self::Stable => "stable",
+ }
+ }
+}
+
pub(crate) fn lychee_link_check(dir: &str) -> Step