Skip to content

Commit aa4b44f

Browse files
authored
Merge pull request #193 from swgoh-utils/ci/prepare-release-dispatch-docs
ci(release): dispatch the docs deploy on the staged release branch
2 parents 4298ae2 + d8c1994 commit aa4b44f

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

‎.github/workflows/docs.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ name: Deploy docs
2222
# build-checks every PR.
2323
#
2424
# Pushes made with GITHUB_TOKEN (such as prepare-release.yml's) do not start this
25-
# workflow; run it by hand on that release branch instead.
25+
# workflow, so prepare-release.yml dispatches it on the branch it stages.
2626
#
2727
# One-time setup: Settings -> Pages -> Build and deployment -> Source:
2828
# "Deploy from a branch", branch `gh-pages`, folder `/ (root)`.
@@ -40,7 +40,8 @@ on:
4040
- "uv.lock"
4141
- ".github/workflows/docs.yml"
4242
- ".github/scripts/docs_version.py"
43-
# Run by hand on a release/* branch, e.g. after prepare-release.yml pushed it.
43+
# Dispatched by prepare-release.yml for the branch it stages; also run by hand
44+
# on a release/* branch to rebuild that version.
4445
# Runs started on any other ref are skipped by the job condition below.
4546
workflow_dispatch:
4647

‎.github/workflows/prepare-release.yml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ permissions:
2626
# Read merged PRs and their issues to restate closing keywords (closing_issues.py).
2727
pull-requests: read
2828
issues: read
29+
# Dispatch docs.yml on the release branch (see "Deploy the release docs").
30+
actions: write
2931

3032
jobs:
3133
prepare:
@@ -127,6 +129,20 @@ jobs:
127129
git commit -m "chore(changelog): update for ${tag}"
128130
git push --force-with-lease origin "${branch}"
129131
132+
# A push made with GITHUB_TOKEN does not start workflows, so docs.yml's
133+
# `push: release/**` trigger never fires for the branch staged above.
134+
# workflow_dispatch is the documented exception, so start the deploy
135+
# explicitly: the release's docs publish (and take `latest` if it is the
136+
# newest stable) as soon as its branch exists.
137+
- name: Deploy the release docs
138+
env:
139+
GH_TOKEN: ${{ github.token }}
140+
run: |
141+
set -euo pipefail
142+
branch="release/${{ steps.version.outputs.tag }}"
143+
gh workflow run docs.yml --repo "${{ github.repository }}" --ref "${branch}"
144+
echo "Dispatched docs.yml on ${branch}."
145+
130146
- name: Summarise how to open the release PR
131147
run: |
132148
set -euo pipefail

‎CONTRIBUTING.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ Never paste your comlink `access_key` / `secret_key` into an issue.
547547
548548
Releases are handled by the maintainer through GitHub Actions. Contributors don't need to manage versioning or releases, but here's how it works for reference:
549549
550-
1. **prepare release** (`prepare-release.yml`) is dispatched on `develop`. It computes the next version from the Conventional Commits since the last tag (or a chosen `patch`/`minor`/`major` bump), regenerates `CHANGELOG.md`, and pushes a `release/vX.Y.Z` branch. If the computed version is a major, the job summary lists the commit lines that triggered it, and an `auto` bump stops unless one is a real `BREAKING CHANGE:` footer (see [Commit Messages](#commit-messages)).
550+
1. **prepare release** (`prepare-release.yml`) is dispatched on `develop`. It computes the next version from the Conventional Commits since the last tag (or a chosen `patch`/`minor`/`major` bump), regenerates `CHANGELOG.md`, pushes a `release/vX.Y.Z` branch, and dispatches **Deploy docs** on it. If the computed version is a major, the job summary lists the commit lines that triggered it, and an `auto` bump stops unless one is a real `BREAKING CHANGE:` footer (see [Commit Messages](#commit-messages)).
551551
2. The maintainer opens the release PR from that branch into `main` (a link is in the workflow summary). Its body restates every `Closes #N` from the PRs merged since the last release, so GitHub closes those issues when it merges. CI runs as normal and the PR is merged.
552552
3. **comlink-python release** (`release.yml`) is dispatched on `main`. It reads the version from `CHANGELOG.md`, builds the package — [hatch-vcs](https://github.com/ofek/hatch-vcs) stamps that version, so **no version string is committed to the repo** — and publishes to [PyPI](https://pypi.org/project/swgoh-comlink/) via trusted publishing.
553553
4. Only after a successful publish is the Git tag created and a GitHub Release cut, with release notes auto-generated from the PR history.
@@ -583,7 +583,7 @@ Deploys run **only from `release/*` branches of `swgoh-utils/comlink-python`**.
583583
- **Pre-releases** take the alias for their kind (`alpha`, `beta`, `rc`, or `dev`, which wins for `aN.devM`) only when they are at least as new as every deployed version of that kind. They never touch `latest` or the default, and every page shows a "pre-release" banner ([`overrides/main.html`](overrides/main.html); the deploy sets `DOCS_PRERELEASE`, which feeds `extra.prerelease` in `mkdocs.yml`). Stable versions instead get Material's "older version" banner whenever they are not `latest`.
584584
- **Every release is its own folder.** `2.5.0` and `2.5.1` both stay in the picker; remove ones you no longer want with `mike delete` (below).
585585
- **Nothing else deploys.** Pushes to `main`, `develop` or tags, runs in forks, and manual runs on a non-`release/*` ref skip the job. Deleting a release branch after its PR merges leaves its docs on `gh-pages`.
586-
- **Release timing.** `prepare-release.yml` pushes `release/vX.Y.Z` before the release PR merges and before the PyPI publish, so a stable release's docs can go live (and take `latest`) before the package is on PyPI. That push is made with `GITHUB_TOKEN`, though, and GitHub does not start workflows from `GITHUB_TOKEN` pushes: run **Actions → Deploy docs → Run workflow** on the new release branch (later pushes to the branch, such as review fixes, deploy on their own).
586+
- **Release timing.** `prepare-release.yml` pushes `release/vX.Y.Z` before the release PR merges and before the PyPI publish, so a stable release's docs can go live (and take `latest`) before the package is on PyPI. That push is made with `GITHUB_TOKEN`, and GitHub does not start workflows from `GITHUB_TOKEN` pushes, so `prepare-release.yml` dispatches **Deploy docs** on the new branch itself (`workflow_dispatch` is the documented exception). Later pushes to the branch, such as review fixes, deploy on their own.
587587
- Deploys queue in the `gh-pages` concurrency group, so they never race.
588588
589589
**Preview the versioned site locally** without touching the remote (the deploy commits to a local `gh-pages` branch only):
@@ -612,9 +612,11 @@ The site used to be deployed by `actions/deploy-pages` from `main`, as a single
612612
uv run mike set-default --push latest
613613
```
614614
615-
3. **Switch the Pages source.** In **Settings → Pages → Build and deployment**, change **Source** from "GitHub Actions" to **"Deploy from a branch"**, branch **`gh-pages`**, folder **`/ (root)`**. Check that the root URL opens the 2.5.0 docs.
615+
3. **Switch the Pages source.** First allow the branch to deploy: in **Settings → Environments → `github-pages` → Deployment branches and tags**, add **`gh-pages`** (branch-based Pages builds still deploy through this environment, and it only allowed `main`). Then, in **Settings → Pages → Build and deployment**, change **Source** from "GitHub Actions" to **"Deploy from a branch"**, branch **`gh-pages`**, folder **`/ (root)`**. Check that the root URL opens the 2.5.0 docs.
616616
4. **Protect `gh-pages`** (optional, recommended). Add a ruleset or branch protection rule for `gh-pages` that blocks force pushes and deletion. Leave direct pushes allowed for GitHub Actions: the deploy pushes with the workflow's `GITHUB_TOKEN`, so a rule that requires pull requests or status checks would block it (or add "GitHub Actions" to the bypass list).
617-
5. **Clean up.** The old `github-pages` environment created by `deploy-pages` can be deleted, or kept for history.
617+
5. **Keep the `github-pages` environment.** Branch-based Pages builds (`pages-build-deployment`) deploy through it, so deleting it or removing `gh-pages` from its deployment branches stops the site from updating.
618+
619+
This cutover was completed on 2026-10-18: `2.5.0` (`latest`) and `3.0.0a2` (`alpha`) are published, and `gh-pages` is protected by the **Protect gh-pages** ruleset.
618620
619621
#### Maintaining versions
620622

0 commit comments

Comments
 (0)