Skip to content

Commit f5ea51f

Browse files
committed
docs: update the upgrade talos version make target
Signed-off-by: Amarachi Iheanacho <amarachi.iheanacho@siderolabs.com>
1 parent 3ef13dc commit f5ea51f

5 files changed

Lines changed: 409 additions & 193 deletions

File tree

Makefile

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ TALOS_VERSION := v1.14
1616
VALE_IMAGE := jdkato/vale:latest
1717
VALE_CONFIG ?= .vale.ini
1818

19+
# Auto-fill the GitHub token from `gh` when it isn't already set in the environment.
20+
# An exported/CI value wins; otherwise fall back to the local gh keychain. If gh is
21+
# unavailable this is simply empty, matching the previous behaviour.
22+
# `export` makes it visible to recipe subprocesses (e.g. the local `go run` targets),
23+
# not just to the containers that pass it explicitly with `-e`.
24+
GITHUB_TOKEN ?= $(shell gh auth token 2>/dev/null)
25+
export GITHUB_TOKEN
26+
1927
# Default target
2028
.PHONY: help
2129
help: ## Show this help message
@@ -131,13 +139,19 @@ test-docs-gen-race: ## Run tests with race detection
131139
.PHONY: test-all
132140
test-all: test-docs-gen ## Run all tests
133141

142+
# talosctl is a multi-arch image and its `--arch` flag defaults to the running
143+
# binary's architecture (runtime.GOARCH). Pin the platform so the generated
144+
# reference docs are deterministic (matching CI) regardless of the contributor's
145+
# machine — otherwise regenerating on Apple Silicon flips defaults to arm64.
146+
TALOSCTL_PLATFORM := linux/amd64
147+
134148
.PHONY: generate-talos-reference
135149
generate-talos-reference: ## Generate Talos reference docs and convert to MDX
136150
@echo "Generating Talos reference documentation..."
137-
docker pull $(TALOSCTL_IMAGE)
151+
docker pull --platform=$(TALOSCTL_PLATFORM) $(TALOSCTL_IMAGE)
138152
docker pull $(DOCS_CONVERT_IMAGE)
139153
mkdir -p _out/docs
140-
docker run --rm -u $(shell id -u):$(shell id -g) -v $(PWD)/_out/docs:/docs $(TALOSCTL_IMAGE) docs /docs
154+
docker run --rm --platform=$(TALOSCTL_PLATFORM) -u $(shell id -u):$(shell id -g) -v $(PWD)/_out/docs:/docs $(TALOSCTL_IMAGE) docs /docs
141155
@echo "Converting generated docs to MDX..."
142156
docker run --rm -u $(shell id -u):$(shell id -g) -v $(PWD):/workspace $(DOCS_CONVERT_IMAGE) \
143157
/workspace/_out/docs /workspace/public/talos/$(TALOS_VERSION)/reference/configuration/
@@ -147,9 +161,9 @@ generate-talos-reference: ## Generate Talos reference docs and convert to MDX
147161
.PHONY: generate-talos-reference-local
148162
generate-talos-reference-local: ## Generate Talos reference docs using local Go build
149163
@echo "Generating Talos reference documentation..."
150-
docker pull $(TALOSCTL_IMAGE)
164+
docker pull --platform=$(TALOSCTL_PLATFORM) $(TALOSCTL_IMAGE)
151165
mkdir -p _out/docs
152-
docker run --rm -u $(shell id -u):$(shell id -g) -v $(PWD)/_out/docs:/docs $(TALOSCTL_IMAGE) docs /docs
166+
docker run --rm --platform=$(TALOSCTL_PLATFORM) -u $(shell id -u):$(shell id -g) -v $(PWD)/_out/docs:/docs $(TALOSCTL_IMAGE) docs /docs
153167
@echo "Converting generated docs to MDX..."
154168
cd docs-convert && go run main.go ../_out/docs ../public/talos/$(TALOS_VERSION)/reference/configuration/
155169
@echo "Reference documentation generated in public/talos/$(TALOS_VERSION)/reference/configuration/"
@@ -331,29 +345,53 @@ changelog-local: ## Generate the changelog using local Go build
331345
validate-docs-nav: ## Validate all talos yaml nav configs match their content directories
332346
cd docs-validate && go run . --workspace ..
333347

348+
# validate-tag distinguishes the two ways a TAG can be wrong, with a tailored
349+
# message for each, and fails BEFORE the generator writes anything:
350+
# 1. malformed -> show the expected format and examples
351+
# 2. unpublished -> the format is fine but no talosctl image exists for it yet
352+
define validate-tag
353+
@echo "$(TAG)" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)\.[0-9]+)?$$' || { \
354+
echo "Error: malformed TAG '$(TAG)'."; \
355+
echo " Expected: vMAJOR.MINOR.PATCH with an optional -alpha.N / -beta.N / -rc.N suffix."; \
356+
echo " Examples: v1.14.0 v1.14.0-alpha.0 v1.14.0-beta.2 v1.14.0-rc.1"; \
357+
exit 1; }
358+
@docker manifest inspect ghcr.io/siderolabs/talosctl:$(TAG) >/dev/null 2>&1 || { \
359+
echo "Error: TAG '$(TAG)' is well-formed but not published yet."; \
360+
echo " No image 'ghcr.io/siderolabs/talosctl:$(TAG)' was found in the registry."; \
361+
echo " The release may not be cut yet — see https://github.com/siderolabs/talos/releases"; \
362+
echo " Pass a TAG whose talosctl image already exists."; \
363+
exit 1; }
364+
endef
365+
334366
.PHONY: upgrade-talos-version
335-
upgrade-talos-version: ## Upgrade docs to the next Talos minor version (fetches versions from GitHub)
367+
upgrade-talos-version: ## Upgrade Talos docs to a release tag: make upgrade-talos-version TAG=v1.14.0-beta.0
368+
@test -n "$(TAG)" || { echo "Error: TAG is required, e.g. make upgrade-talos-version TAG=v1.14.0-beta.0"; exit 1; }
369+
$(validate-tag)
336370
docker run --rm -it -v $(PWD):/workspace -w /workspace \
337371
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
338-
$(VERSION_UPGRADE_IMAGE)
339-
$(eval NEW_VERSION := $(shell cat .upgrade-version-tmp))
372+
$(VERSION_UPGRADE_IMAGE) --tag $(TAG)
373+
$(eval NEW_VERSION := $(shell cat .upgrade-version-tmp 2>/dev/null))
340374
@rm -f .upgrade-version-tmp
375+
$(MAKE) generate-talos-reference
341376
$(MAKE) changelog
342377
$(MAKE) docs.json
343378
$(MAKE) validate-docs-nav
344379
@echo ""
345-
@echo "Upgrade to $(NEW_VERSION) complete! Run: make preview to preview your $(NEW_VERSION) docs"
380+
@echo "Upgrade to $(TAG) complete! Run: make preview to preview your $(NEW_VERSION) docs"
346381

347382
.PHONY: upgrade-talos-version-local
348-
upgrade-talos-version-local: ## Upgrade docs to the next Talos minor version using local Go build
349-
cd version-upgrade-gen && go run . --workspace ..
350-
$(eval NEW_VERSION := $(shell cat .upgrade-version-tmp))
383+
upgrade-talos-version-local: ## Same as upgrade-talos-version but using the local Go build
384+
@test -n "$(TAG)" || { echo "Error: TAG is required, e.g. make upgrade-talos-version-local TAG=v1.14.0-beta.0"; exit 1; }
385+
$(validate-tag)
386+
cd version-upgrade-gen && go run . --workspace .. --tag $(TAG)
387+
$(eval NEW_VERSION := $(shell cat .upgrade-version-tmp 2>/dev/null))
351388
@rm -f .upgrade-version-tmp
389+
$(MAKE) generate-talos-reference-local
352390
$(MAKE) changelog
353391
$(MAKE) docs.json
354392
$(MAKE) validate-docs-nav
355393
@echo ""
356-
@echo "Upgrade to $(NEW_VERSION) complete! Run: make preview to preview your $(NEW_VERSION) docs"
394+
@echo "Upgrade to $(TAG) complete! Run: make preview to preview your $(NEW_VERSION) docs"
357395

358396
.PHONY: build-version-upgrade-container
359397
build-version-upgrade-container: ## Build the version-upgrade-gen container locally

contributing-guides/generating-docs.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ Both variants run `talosctl` from a container, so **Docker is required either wa
4848

4949
**Versioning:** the output directory is chosen by `TALOS_VERSION` in the Makefile (e.g. `v1.14`), and the talosctl image is pinned by `TALOSCTL_IMAGE`. Older versions already committed under `public/talos/` are not touched.
5050

51+
### Updating Talos docs for a new release
52+
53+
When Talos cuts a new release — an alpha, beta, or stable — the docs need to point at it: the version pins, the versioned variables, the navigation, the reference pages, and the changelog. `make upgrade-talos-version` does all of that from a single tag instead of editing each by hand.
54+
55+
```bash
56+
make upgrade-talos-version TAG=v1.14.0-alpha.0 # alpha
57+
make upgrade-talos-version TAG=v1.14.0-beta.0 # beta
58+
make upgrade-talos-version TAG=v1.14.0 # stable
59+
make upgrade-talos-version-local TAG=v1.14.0 # same, using the local Go build
60+
```
61+
62+
See [`version-upgrade-gen/README.md`](../version-upgrade-gen/README.md) for the full details.
63+
5164
## Omni reference
5265

5366
`make generate-omni-reference` regenerates all three Omni reference pages; each page also has its own target if you only need one:

public/snippets/custom-variables.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ export const nvidia_container_toolkit_release_v1_13 = "v1.19.0"
7272
export const nvidia_driver_release_v1_13 = "580.126.20"
7373

7474
{/* 1.14 talos release */}
75-
export const release_v1_14 = 'v1.14.0-alpha.0'
75+
export const release_v1_14 = 'v1.14.0-alpha.2'
7676
export const release_branch_v1_14 = 'release-1.14'
7777
export const version_v1_14 = 'v1.14'
7878
export const nvidia_container_toolkit_release_v1_14 = "v1.19.0"
7979
export const nvidia_driver_release_v1_14 = "580.126.20"
80-

version-upgrade-gen/README.md

Lines changed: 66 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,89 @@
11
# version-upgrade-gen
22

3-
A Go tool that automates upgrading the Talos documentation to the next version.
3+
A Go tool that points the Talos documentation at a specific Talos release tag.
44

55
## What it does
66

7-
When run, it prompts you to select a release type and then:
8-
9-
**Beta release**
10-
- Updates the versioned variables block in `custom-variables.mdx` with the new beta tag (e.g. `v1.14.0-beta.0`)
11-
- Adds the new `talos-vX.Y.yaml` at the bottom of the nav in all four Makefile targets so the beta version appears last in the version dropdown
12-
13-
**Stable release**
14-
- Updates the "latest stable" block in `custom-variables.mdx` with the new version's Kubernetes and nvidia versions (fetched from GitHub)
15-
- Updates or creates the versioned variables block in `custom-variables.mdx`
16-
- Updates the version warning banner to point to the new latest version
17-
- Updates all canonical URLs across older version docs to point to the new version
18-
- Moves the new `talos-vX.Y.yaml` to the top of the nav in all four Makefile targets
19-
- Updates `TALOSCTL_IMAGE` and `TALOS_VERSION` in the Makefile
7+
You pass the exact target image tag with `--tag` (e.g. `v1.14.0-beta.0` or
8+
`v1.14.0`). The tool reads the current tag from `TALOSCTL_IMAGE` in the Makefile
9+
and derives everything else from the two tags:
10+
11+
- **Stage** (alpha / beta / stable) comes from the tag's suffix — there is no
12+
interactive prompt.
13+
- **Folder** (`TALOS_VERSION`, e.g. `v1.14`) is the tag's `major.minor`. Moving a
14+
minor through alpha → beta → stable keeps the same folder; only a genuinely new
15+
minor changes it.
16+
17+
**Pre-release target (alpha/beta)**
18+
- Rewrites `TALOSCTL_IMAGE` to the exact tag and `TALOS_VERSION` to the folder minor
19+
- Updates (or appends) the versioned variables block in `custom-variables.mdx` with the tag
20+
- Leaves the "latest stable" pointer (banner, canonical URLs, latest-stable block) untouched
21+
- **Navigation differs by stage:**
22+
- **alpha** — leaves the `docs.json`/`check-missing` nav lists unchanged. The reference
23+
docs are still generated on disk, but the version stays out of the published nav.
24+
- **beta** — ensures `talos-vX.Y.yaml` is present at the bottom of the nav in all four
25+
Makefile targets so the version appears last in the dropdown. This is idempotent, so
26+
a beta correctly adds the entry that an earlier alpha of the same minor skipped.
27+
28+
**Stable target**
29+
- Rewrites `TALOSCTL_IMAGE` to the exact tag and `TALOS_VERSION` to the folder minor
30+
- Updates the "latest stable" block in `custom-variables.mdx` with the release's
31+
Kubernetes (from the `siderolabs/talos` release notes) and nvidia versions, and
32+
updates/creates the versioned block
33+
- Only when the latest stable minor actually changes (read from the version warning
34+
banner, not from `TALOS_VERSION`): updates the banner, rewrites canonical URLs
35+
across older version docs, and moves `talos-vX.Y.yaml` to the top of the nav
36+
37+
**nvidia values (both paths)**
38+
The `nvidia_container_toolkit_release` / `nvidia_driver_release` values are resolved
39+
the same way everywhere: first from the `siderolabs/extensions` release notes for the
40+
exact tag, and — if that release is missing, has no nvidia fields, or the fetch fails —
41+
falling back to the current unversioned latest-stable values. They are therefore never
42+
written empty, and a stable run no longer aborts when the extensions data lags behind.
43+
For an existing versioned block, a pre-release only backfills nvidia values that are
44+
currently empty, so good values from an earlier stable run are never overwritten.
45+
46+
The current image tag is matched in full, including any pre-release suffix, so a pin
47+
like `v1.14.0-alpha.2` is replaced cleanly rather than by prefix.
2048

2149
## Usage
2250

23-
From the repo root:
51+
From the repo root, pass the target tag with `TAG=`:
2452

2553
```bash
26-
# Using local Go build
27-
make upgrade-talos-version-local
54+
# Published Docker container
55+
make upgrade-talos-version TAG=v1.14.0-beta.0 # beta of the current minor
56+
make upgrade-talos-version TAG=v1.14.0 # stable
57+
make upgrade-talos-version TAG=v1.15.0-beta.0 # first beta of a new minor
2858

29-
# Using published Docker container
30-
make upgrade-talos-version
59+
# Local Go build
60+
make upgrade-talos-version-local TAG=v1.14.0-beta.0
3161
```
3262

33-
Both commands will prompt you interactively:
63+
After the tool rewrites the pins, the Makefile targets automatically regenerate the
64+
Talos reference docs (`make generate-talos-reference`), the changelog, and
65+
`docs.json`, then tell you to run `make preview` to verify the result.
3466

35-
```
36-
What type of release is this?
37-
[1] Beta - e.g v1.14.0-beta.0
38-
[2] Stable - e.g v1.14.0
67+
Running the binary directly:
3968

40-
Enter your choice (1 or 2):
69+
```bash
70+
go run . --workspace .. --tag v1.14.0-beta.0
4171
```
4272

43-
After the tool runs, it automatically regenerates the changelog and `docs.json`, then tells you to run `make preview` to verify the result.
73+
## Tag validation
74+
75+
The `--tag` value must be `vMAJOR.MINOR.PATCH` with an optional `-alpha.N` /
76+
`-beta.N` / `-rc.N` suffix (e.g. `v1.14.0`, `v1.14.0-beta.0`). Surrounding
77+
whitespace is trimmed. Anything else — a missing `v`, a missing patch number, a
78+
misspelled stage, etc. — is rejected up front, before any file is modified, so a
79+
typo can never leave the repo in a half-applied state.
4480

4581
## Prerequisites
4682

47-
- A `talos-vX.Y.yaml` navigation file must already exist before running in either mode
48-
- For stable releases, a `GITHUB_TOKEN` environment variable is recommended to avoid GitHub API rate limits
83+
- A `talos-vX.Y.yaml` navigation file must already exist before running
84+
- A `GITHUB_TOKEN` is used for the stable release GitHub lookups (and by the
85+
changelog step). The Makefile auto-fills it from `gh auth token` when it isn't
86+
already set in the environment, so no manual export is normally needed.
4987

5088
## Building the container
5189

0 commit comments

Comments
 (0)