Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/docs-gen-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ on:
push:
branches:
- main
# Final release tags publish versioned docs and move the latest alias.
# The paths filter is not evaluated for tag pushes.
tags:
- "v*"
- "!v*-*"
paths:
- "docs/**"
- "cli/**"
Expand Down Expand Up @@ -61,7 +66,7 @@ jobs:
if: >-
github.repository == 'kbind-dev/kbind' &&
github.event_name != 'pull_request' &&
github.ref == 'refs/heads/main'
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
needs: build
permissions:
contents: write
Expand All @@ -79,7 +84,7 @@ jobs:
python-version: "3.12"
cache: pip
cache-dependency-path: docs/requirements.txt
- name: Publish preview without changing latest
- name: Publish documentation
env:
PUSH: "1"
run: |
Expand Down
35 changes: 17 additions & 18 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ command tree. Generated references and the built site are ignored by git.
After changing API types or CLI definitions, restart the preview or run
`make generate-docs` again.

## Non-default v2 publication
## Publication

The preview is always published as **`v2`**, displayed in the
version selector as **v2 (preview)**:
Pushes to `main` publish the development docs as the **`main`** version:

<https://docs.kbind.dev/v2/>
<https://docs.kbind.dev/main/>

Publication deliberately does **not** derive the version from the newest
tag, assign the `latest` alias, call `mike set-default`, or replace the
root redirect. The existing 0.x versions, `latest`, and custom domain
stay in the `gh-pages` branch.
Final release tags (`v2.0.0`, not prereleases) publish under the minor
version (`v2.0`) and move the **`latest`** alias to it, so the site's
default follows the newest release. The older 0.x versions stay in the
`gh-pages` branch.

The **Docs** workflow (`.github/workflows/docs-gen-and-push.yaml`)
builds relevant pull requests without deployment. Pushes to `main`
and manual dispatches publish only in `kbind-dev/kbind`. Forks build but
builds relevant pull requests without deployment. Pushes to `main`,
final release tags, and manual dispatches publish only in
`kbind-dev/kbind`. Forks build but
cannot publish to the canonical site. Publication shares the `Docs`
concurrency group with the stable docs workflow and never force-pushes.
concurrency group and never force-pushes.

## Publish a checkout manually

Expand All @@ -62,13 +62,12 @@ git push upstream gh-pages:gh-pages
```

`deploy-docs` fetches the existing publishing branch and makes a local mike
commit. **It does not push by default.** Review that only `v2/` and the
new `versions.json` entry changed before pushing. If someone publishes in
the meantime, fetch and rebuild on the updated branch rather than
force-pushing.
commit. **It does not push by default.** By default it publishes the `main`
version; set `GITHUB_REF=refs/tags/vX.Y.Z` to publish a release version
with the `latest` alias instead. Review the diff before pushing. If someone
publishes in the meantime, fetch and rebuild on the updated branch rather
than force-pushing.

CI passes `PUSH=1` to publish immediately after the strict build.
`REMOTE` defaults to `origin` and `BRANCH` to `gh-pages`, override them
only deliberately. There is intentionally no `VERSION` or default-version
switch in the preview publisher. Making v2 the stable default is a
separate release decision.
only deliberately.
9 changes: 4 additions & 5 deletions docs/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,10 @@ gh release create v2.0.1 --generate-notes

## Naming conventions

Documentation publication is separate from binary releases. The
[v2 preview publisher](README.md) deploys
`v2` without moving `latest` or the site's default redirect, including
when v2 release-candidate tags exist. Promoting v2 to the default docs
requires a separate, explicit change.
Documentation follows the release: pushes to `main` publish the `main`
version, and final release tags publish the minor version (e.g. `v2.0`)
and move the `latest` alias to it (see [docs/README.md](README.md)).
Prerelease tags do not publish docs.

| Kind | Example | Cut from |
|------------------|----------------|-----------------|
Expand Down
21 changes: 19 additions & 2 deletions docs/scripts/deploy-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,22 @@ if [[ "${PUSH:-0}" == "1" ]]; then
fi

git fetch "$remote" "$branch"
message=${DOCS_COMMIT_MESSAGE:-Publish v2 documentation preview}
mike deploy "${options[@]}" --message "$message" --title "v2 (preview)" v2

ref=${GITHUB_REF:-refs/heads/main}
case "$ref" in
refs/tags/v*)
tag=${ref#refs/tags/}
if [[ "$tag" == *-* ]]; then
echo "Prerelease tag $tag does not publish docs." >&2
exit 0
fi
# Releases publish under the minor version and move the latest alias.
version=$(sed -E 's/^(v[0-9]+\.[0-9]+)\..*$/\1/' <<<"$tag")
message=${DOCS_COMMIT_MESSAGE:-"Publish documentation for $tag"}
mike deploy "${options[@]}" --update-aliases --message "$message" "$version" latest
;;
*)
message=${DOCS_COMMIT_MESSAGE:-"Publish main documentation"}
mike deploy "${options[@]}" --message "$message" main
;;
esac