ci: devvm.dev shows the latest release's docs, next.devvm.dev shows main's (#16)

Two docs sites, from one Docs workflow (`.github/workflows/docs.yml`):

- **devvm.dev** shows the latest release's docs. The `release` job
builds a tag's `docs/` and the `deploy` job deploys it to GitHub Pages
(`github-pages` environment), on a published release that isn't a
prerelease, and on a `workflow_dispatch` with `site=devvm.dev` and `ref`
(a release tag; empty means the latest release, from `gh release view`).
The tag is checked against `^v[0-9]+\.[0-9]+\.[0-9]+$` through `env:`
before it's used, and checked out as `refs/tags/<tag>`. Pushes to main
no longer deploy devvm.dev.
- **next.devvm.dev** shows main's docs. On pushes to main that touch the
docs (the same paths anchor), or a dispatch with `site=next.devvm.dev`,
`check` lints and builds, then `next` builds with `hugo -s docs --minify
--config hugo.yaml,next.yaml`, checks out devvmhq/docs-next with
`DOCS_NEXT_DEPLOY_KEY` (environment `docs-next`, only after the build),
replaces everything but README.md, and commits `Build from devvm <short
sha>` as github-actions[bot], skipping an unchanged build. Its
concurrency group keeps pushes from racing.
- `docs/next.yaml` sets `baseURL: https://next.devvm.dev/`, Hextra's
`params.banner` (a note that links devvm.dev), and `noindex` both as a
site param and through `cascade`, so Hextra's head writes `noindex,
nofollow` on every page. `docs/layouts/robots.txt` adds `Disallow: /`
when the site's `noindex` is set. The build stays in Hugo's production
environment, so Hextra's minified, fingerprinted assets are the same as
devvm.dev's.
- PRs get the same lint and build as before, and nothing runs with an
environment or a secret on `pull_request`. Permissions: `contents: read`
at the top; only `deploy` has `pages: write` and `id-token: write`. The
publishing jobs set `cache: false` on mise-action (zizmor's
cache-poisoning, now that the workflow publishes on `release`), and so
does `check`.
- Docs: Contributing's Maintaining has a new section, The docs sites
(what deploys each, the hand redeploy, the key and environments,
Cloudflare Pages serving devvmhq/docs-next); Contributing's two mentions
of the deploy point at it; Upgrading's Trying a prerelease links
next.devvm.dev.

Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
CJandClaude Opus 5.5 authored and GitHub committed 2026-11-07 09:02:34 -07:00
1 parent b3a188712f
commit da804f0568
6 files changed
+165 -14

No files matched your search

+131 -12
View File
@@ -1,9 +1,13 @@
name: Docs
# Pull requests touching the docs get their lints and a build; main deploys when the docs change.
# Two sites. devvm.dev shows the latest release's docs: a published release that isn't a
# prerelease deploys its tag's docs to GitHub Pages, and so does a dispatch, with any release's
# tag. next.devvm.dev shows main's: each push to main that changes the docs builds them with
# docs/next.yaml and commits the site to devvmhq/docs-next, which Cloudflare Pages serves.
# Pull requests touching the docs get their lints and a build, and nothing else.
# The site is built from docs/ alone (the CLI reference included, which a help change commits
# there), and CI's lint runs the docs checks on every code change, so other pushes skip this.
# Both triggers take the same paths; workflow_dispatch deploys by hand.
# A release event runs this file as its tag has it.
on:
push:
branches: [main]
@@ -16,19 +20,34 @@ on:
- ".github/workflows/docs.yml"
pull_request:
paths: *docs-paths
release:
types: [published]
workflow_dispatch:
inputs:
site:
description: The site to deploy
type: choice
options: [devvm.dev, next.devvm.dev]
default: devvm.dev
ref:
description: "devvm.dev only: the release tag whose docs it shows, such as v0.1.0 (empty: the latest release)"
type: string
required: false
permissions:
contents: read
# Deploys queue one after another; a pull request's newer run replaces its last.
concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build:
# main's docs, or a pull request's: the lints and a build.
check:
if: >-
github.event_name == 'pull_request' || github.event_name == 'push' ||
(github.event_name == 'workflow_dispatch' && inputs.site == 'next.devvm.dev')
runs-on: ubuntu-latest
# A pull request's newer run replaces its last.
concurrency:
group: docs-check-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
# Only the docs' tools, not every tool in mise.toml.
MISE_TASK_RUN_AUTO_INSTALL: "false"
@@ -42,18 +61,118 @@ jobs:
with:
version: 2026.10.18
install_args: go hugo-extended node markdownlint-cli2 vale lychee
# The workflow publishes, so no job in it reads a cache another run could have written.
cache: false
- run: mise run lint:docs
# The site's address is baseURL in docs/hugo.yaml.
- run: hugo -s docs --minify
- if: github.event_name != 'pull_request'
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
# next.devvm.dev: main's docs, committed to devvmhq/docs-next.
next:
if: >-
github.ref == 'refs/heads/main' &&
(github.event_name == 'push' ||
(github.event_name == 'workflow_dispatch' && inputs.site == 'next.devvm.dev'))
needs: check
runs-on: ubuntu-latest
# One push at a time; a newer run waiting replaces an older one.
concurrency:
group: docs-next
cancel-in-progress: false
# The environment holds the deploy key, and only main can use it.
environment:
name: docs-next
url: https://next.devvm.dev/
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0
- uses: jdx/mise-action@6be3c7ed4c21d4f76b208d351d95aac273ebb76d # v5.2.4
with:
version: 2026.10.18
install_args: go hugo-extended
# What's published is built from no cache.
cache: false
# docs/next.yaml over docs/hugo.yaml: next.devvm.dev's address, the banner and noindex.
- run: hugo -s docs --minify --config hugo.yaml,next.yaml -d "$RUNNER_TEMP/next"
# The key is checked out only after the build, which never sees it.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: devvmhq/docs-next
ref: main
path: docs-next
ssh-key: ${{ secrets.DOCS_NEXT_DEPLOY_KEY }}
# The push below needs the key; this checkout is the only thing that uses it.
persist-credentials: true # zizmor: ignore[artipacked] -- the push needs the deploy key, and nothing is uploaded
- name: Publish
working-directory: docs-next
run: |
# Everything but README.md is the site's.
find . -mindepth 1 -maxdepth 1 ! -name .git ! -name README.md -exec rm -rf {} +
cp -R "$RUNNER_TEMP/next/." .
git add -A
if git diff --cached --quiet; then
echo "next.devvm.dev is already this build."
exit 0
fi
git -c user.name="github-actions[bot]" \
-c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
commit -q -m "Build from devvm ${GITHUB_SHA::7}"
git push origin HEAD:main
# devvm.dev: a release's docs, built from its tag.
release:
if: >-
(github.event_name == 'release' && !github.event.release.prerelease) ||
(github.event_name == 'workflow_dispatch' && inputs.site == 'devvm.dev')
runs-on: ubuntu-latest
steps:
- id: tag
name: The release's tag
env:
GH_TOKEN: ${{ github.token }}
EVENT: ${{ github.event_name }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
INPUT_REF: ${{ inputs.ref }}
run: |
if [ "$EVENT" = release ]; then
tag=$RELEASE_TAG
elif [ -n "$INPUT_REF" ]; then
tag=$INPUT_REF
else
tag=$(gh release view --repo devvmhq/devvm --json tagName --jq .tagName)
fi
if ! [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::A release tag is vX.Y.Z, such as v0.1.0; this is $tag."
exit 1
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: refs/tags/${{ steps.tag.outputs.tag }}
persist-credentials: false
# Full history, for each page's last updated date.
fetch-depth: 0
- uses: jdx/mise-action@6be3c7ed4c21d4f76b208d351d95aac273ebb76d # v5.2.4
with:
version: 2026.10.18
install_args: go hugo-extended
# What's published is built from no cache.
cache: false
# The tag's docs/hugo.yaml, whose baseURL is devvm.dev.
- run: hugo -s docs --minify
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: docs/public
deploy:
if: github.event_name != 'pull_request'
needs: build
needs: release
runs-on: ubuntu-latest
# Deploys queue one after another.
concurrency:
group: docs-pages
cancel-in-progress: false
permissions:
pages: write # to deploy the site
id-token: write # to prove the deployment comes from this workflow
+2 -2
View File
@@ -61,7 +61,7 @@ Run the tasks with `mise run <task>`:
Before and after every change, `mise run fmt && mise run lint && mise run test` must pass.
CI runs `lint` and `test` on macOS and Linux. A change that touches only the docs and Markdown files skips them: the Docs workflow runs `lint:docs` and builds the site instead, and deploys it on every push to `main`.
CI runs `lint` and `test` on macOS and Linux. A change that touches only the docs and Markdown files skips them: the Docs workflow runs `lint:docs` and builds the site instead, and on every push to `main` it deploys next.devvm.dev ([the docs sites](maintaining.md#the-docs-sites)).
## Go lint rules
@@ -598,4 +598,4 @@ The tests fail when the checked-in pages are stale: `TestReferenceIsCurrent` in
### Building the site
`mise run docs` serves the site at `http://localhost:1313/` and reloads on every change. `mise exec -- hugo -s docs --minify` builds it into `docs/public/`, as the Pages workflow does on every push to `main`.
`mise run docs` serves the site at `http://localhost:1313/` and reloads on every change. `mise exec -- hugo -s docs --minify` builds it into `docs/public/`, as the Docs workflow does for devvm.dev, and `mise exec -- hugo -s docs --minify --config hugo.yaml,next.yaml` builds the site as next.devvm.dev has it, with its banner and its noindex ([the docs sites](maintaining.md#the-docs-sites)).
@@ -61,3 +61,13 @@ Until a fix ships, users can still build base, because devvm's fallback to the r
- To try `dist/install.sh` on such a build, copy `dist/` to `DIR/releases/download/v<version>/`, then in a throwaway `HOME` with `DEVVM_PREFIX` under it: `DEVVM_INSTALL_TEST=1 source dist/install.sh`, set `repo_url=file://DIR` and `protos='=https,file'` (it downloads over HTTPS only), and run `main --no-deps`. Without `--no-deps` it offers to install what the host lacks: answer no, or run it with no terminal.
- Every build sets the version with `-X github.com/devvmhq/devvm/internal/cli.version=<version>`: devvm doesn't read `VERSION`. The formula (`packaging/homebrew/devvm.rb`) builds nothing. It has an archive for each of macOS and Linux on arm64 and Intel, the same archives the install script installs, and it installs the binary alone from the one for this machine. `release.sh` fills in each archive's URL and its checksum, which it reads from the `SHA256SUMS` it just wrote, on every line that isn't a comment. The generated formula passes `brew audit --strict --online` and `brew style`.
- Publishing is the maintainer's call, so an agent asks first and never runs `scripts/publish.sh` without `--dry-run` on its own. The script's tests (`testdata/script/publish.txtar`) run it against a local bare repo as `origin`, a local bare tap and a fake `gh`.
## The docs sites
The docs have two sites, and the Docs workflow (`.github/workflows/docs.yml`) deploys both. devvm.dev shows the docs of the latest release, so what users read matches the devvm they install. next.devvm.dev shows the docs on `main`, for the next release, which is what someone trying a prerelease reads. A pull request that touches the docs gets their lints and a build, and it deploys nothing, so a pull request from a fork never reaches either site or its keys.
- **devvm.dev** is GitHub Pages, in the repo's `github-pages` environment, which accepts deployments from `main` and from `v*` tags, and only admins can create a `v*` tag. When a release is published, and it isn't a prerelease, the workflow builds the docs in that release's tag and deploys them. A release event runs the workflow file that the tag has, so a release whose tag predates this workflow doesn't deploy on its own. Pushes to `main` never change devvm.dev.
- **To deploy a release's docs by hand,** for a release that didn't deploy on its own or to put devvm.dev back on a release, run the Docs workflow from `main` in the repo's Actions tab, or with `gh workflow run docs.yml --repo devvmhq/devvm -f site=devvm.dev -f ref=v0.1.0`. The site is `devvm.dev` unless you choose another one, and the ref is the release's tag, which has to look like `v0.1.0`, so a prerelease's tag is refused. Without a ref, the workflow deploys the latest release, as `gh release view` names it.
- **next.devvm.dev** is Cloudflare Pages, serving the files on the `main` branch of the repo `devvmhq/docs-next`, and Cloudflare builds nothing. On each push to `main` that touches the docs, the workflow lints and builds `main`'s docs for next.devvm.dev, then replaces everything in `devvmhq/docs-next` but its `README.md` with the build, and commits it as `Build from devvm <short sha>`. When the build is the same as the last one, it commits nothing. `gh workflow run docs.yml --repo devvmhq/devvm -f site=next.devvm.dev` runs it by hand. Nobody edits `devvmhq/docs-next` by hand, because the next build replaces it.
- **The deploy key** that pushes to `devvmhq/docs-next` is the secret `DOCS_NEXT_DEPLOY_KEY` in the `docs-next` environment, which only `main` can deploy from. It's an ed25519 key with write access to `devvmhq/docs-next` and to nothing else. The workflow checks that repo out with it only after the site is built, so the build never sees the key. To rotate it, make a new key, add its public half to `devvmhq/docs-next` as a deploy key with write access, put its private half in the secret, then delete the old deploy key.
- **The next build** is `hugo -s docs --minify --config hugo.yaml,next.yaml`, which reads `docs/next.yaml` over `docs/hugo.yaml`. It sets the site's address to `https://next.devvm.dev/` and puts a banner on every page that says these docs are for the next devvm and links to devvm.dev. It also sets `noindex`, so Hextra gives every page a `noindex, nofollow` robots meta tag, and `docs/layouts/robots.txt` disallows everything, so search engines don't index the site. devvm.dev's build, `hugo -s docs --minify`, never reads `docs/next.yaml`, so it has no banner, its pages say `index, follow`, and its `robots.txt` allows everything.
+2
View File
@@ -79,6 +79,8 @@ Homebrew installs only its formula's release, so with Homebrew devvm upgrade doe
A prerelease is a version of devvm that you can try before its release is out, such as a release candidate, `0.2.0-rc.1`, or a beta, `0.2.0-beta.1`. devvm upgrade and the install script never pick a prerelease as the newest release, and the daily release check never announces one, so you get a prerelease only when you name it.
The docs at [devvm.dev](https://devvm.dev/) are for the newest release. The docs for the next release, which a prerelease comes before, are at [next.devvm.dev](https://next.devvm.dev/), and they change as that release is written, so they can describe more than a prerelease has.
To install a prerelease with the install script, run the copy of the script that comes with the prerelease, which installs that prerelease, or give its version to the newest release's script with `--version`:
```sh
+4
View File
@@ -0,0 +1,4 @@
User-agent: *
{{- if site.Params.noindex }}
Disallow: /
{{- end }}
+16
View File
@@ -0,0 +1,16 @@
# next.devvm.dev: main's docs, for the next release. The Docs workflow builds it with
# `hugo -s docs --minify --config hugo.yaml,next.yaml`, which merges this over hugo.yaml.
# devvm.dev's build, `hugo -s docs --minify`, never reads it.
baseURL: https://next.devvm.dev/
# Search engines skip every page: Hextra's head says noindex for a page whose noindex
# param is set, and layouts/robots.txt disallows everything when the site's is.
cascade:
- params:
noindex: true
params:
noindex: true
banner:
key: next-docs
message: "These docs are for the next devvm, which isn't released yet. The docs for the current release are at [devvm.dev](https://devvm.dev/)."