From 9f9b7080c6695533691965f576495564d5e4c2e3 Mon Sep 17 00:00:00 2001 From: Karol Szwaj Date: Tue, 1 Dec 2026 15:43:47 +0100 Subject: [PATCH] Publish docs from main and release tags, drop v2 preview Signed-off-by: Karol Szwaj --- .github/workflows/docs-gen-and-push.yaml | 9 ++++-- docs/README.md | 35 ++++++++++++------------ docs/RELEASING.md | 9 +++--- docs/scripts/deploy-docs.sh | 21 ++++++++++++-- 4 files changed, 47 insertions(+), 27 deletions(-) diff --git a/.github/workflows/docs-gen-and-push.yaml b/.github/workflows/docs-gen-and-push.yaml index dc839d56e..b9bb10c11 100644 --- a/.github/workflows/docs-gen-and-push.yaml +++ b/.github/workflows/docs-gen-and-push.yaml @@ -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/**" @@ -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 @@ -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: | diff --git a/docs/README.md b/docs/README.md index c774c9a5f..2af24608f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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: - + -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 @@ -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. diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 4b761a28a..b82601d23 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -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 | |------------------|----------------|-----------------| diff --git a/docs/scripts/deploy-docs.sh b/docs/scripts/deploy-docs.sh index 2633e1eeb..c2c58e782 100644 --- a/docs/scripts/deploy-docs.sh +++ b/docs/scripts/deploy-docs.sh @@ -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