diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 76cc3575..e981481c 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -15,6 +15,10 @@ on: branches: - 'main' - 'feat/fumadocs-next' + # Daily, so a new Panel release (scripts/sync-release.mjs) reaches pelican.dev without a push. + # GitHub runs schedules from main only, so this rebuilds pelican.dev, like a push to main. + schedule: + - cron: '23 5 * * *' concurrency: group: publish-docs-${{ github.ref_name }} @@ -64,6 +68,9 @@ jobs: # prebuild checks the content, postbuild checks every file lands where it should and every link works. - name: 'Build' + env: + # sync-release reads the latest Panel release with it (a higher rate limit). + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: bun run build - name: 'Pack the docs for the Hub' diff --git a/AGENTS.md b/AGENTS.md index add8a264..24304e8b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -19,7 +19,9 @@ This block is written and re-added by `next dev` — verify at `node_modules/nex - Before opening a pull request: `bun test`, `bun run typecheck`, `bun run build`. The build checks the pages before it (`check:content`), refreshes the egg data (`sync:eggs`, which uses the network and rewrites `data/eggs.json`, `public/data/eggs/`, `public/img/eggs/`, `public/img/games/`: don't - commit those unless the task is about eggs), and checks the paths and the links after it (`check:paths`, `check:links`). + commit those unless the task is about eggs), reads the latest Panel release from GitHub (`sync:release`, + which rewrites `data/release.json`: never commit it; on failure the build uses `lib/home-data.ts`'s typed + values), and checks the paths and the links after it (`check:paths`, `check:links`). - The paths this build serves on pelican.dev are in one file, `router/paths.mjs`. Change them there, and in the Hub's `DocsBuildService::ROOT_FILES` for the root files. - A new MDX component goes in `mdx-components.tsx` and in `COMPONENTS` in diff --git a/README.md b/README.md index 72615e46..16f06ead 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ bun test # the tests for scripts/ and router/ Every script in `scripts/` and `router/` runs on Bun and starts with the same header: what it does, when it runs, how to run it and where its tests are. [scripts/README.md](scripts/README.md) lists them all. -The build refreshes the egg data for the interim `/eggs` page (it uses the network), so it can change `data/eggs.json`, `public/data/eggs/`, `public/img/eggs/` and `public/img/games/`. Leave those out of a pull request unless it's about the egg data. +The build refreshes the egg data for the interim `/eggs` page (it uses the network), so it can change `data/eggs.json`, `public/data/eggs/`, `public/img/eggs/` and `public/img/games/`. Leave those out of a pull request unless it's about the egg data. It also writes the latest Panel release from GitHub into `data/release.json`; leave that out too (`git restore data`). ### Before a pull request diff --git a/components/home/sections.tsx b/components/home/sections.tsx index 25c51c03..10d21a3e 100644 --- a/components/home/sections.tsx +++ b/components/home/sections.tsx @@ -300,7 +300,7 @@ export function ActivitySection() {

Latest release:{' '} - + {project.version}, {project.released}

@@ -508,7 +508,7 @@ export function SiteFooterNav() {

© 2024–{new Date().getFullYear()} Pelican · {project.license} · Latest release{' '} - {project.version}, {project.released} + {project.version}, {project.released}

diff --git a/components/home/site-header.tsx b/components/home/site-header.tsx index d47412df..2cc1becc 100644 --- a/components/home/site-header.tsx +++ b/components/home/site-header.tsx @@ -5,8 +5,16 @@ import { links } from '@/lib/links'; import { project } from '@/lib/home-data'; import { MobileMenu } from './mobile-menu'; +/** + * What the announcement bar says about a release. The version comes from GitHub at build time + * (lib/home-data.ts), so a newer release than the one written about here gets a plain line. + */ +const announced = { version: '1.0.0-rc.2', text: 'A crashing plugin can no longer take the panel down, and more.' }; + /** Announcement bar plus the sky-blue nav from the V12 "B v3" board. */ export function SiteHeader() { + const text = + project.version === announced.version ? announced.text : `The latest Panel release, out ${project.released}.`; return ( <> @@ -14,8 +22,8 @@ export function SiteHeader() {
{project.version.replace('1.0.0-', '')} - A crashing plugin can no longer take the panel down, and more. - + {text} + Read the release →
diff --git a/data/release.json b/data/release.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/data/release.json @@ -0,0 +1 @@ +{} diff --git a/lib/home-data.ts b/lib/home-data.ts index cd61e30a..0a745122 100644 --- a/lib/home-data.ts +++ b/lib/home-data.ts @@ -1,13 +1,32 @@ +import releaseJson from '@/data/release.json'; + /** * Facts the homepage shows. Everything here was read from a real source on * 2 November 2026; the source is noted beside each block. Update it when the * numbers move (a new release, a new plugin count) rather than guessing. */ -export const project = { +/** + * The latest Panel release, read from GitHub before each build by scripts/sync-release.mjs + * (data/release.json). These typed values are the fallback for when it couldn't (no network, + * a rate limit); in git the file holds no release, so they also apply until the first build. + */ +const typedRelease = { // github.com/pelican/panel/releases version: '1.0.0-rc.2', released: '22 October 2026', + url: 'https://github.com/pelican/panel/releases/tag/v1.0.0-rc.2', +}; +const live = releaseJson as { version?: string; released?: string; url?: string }; +export const release = + live.version && live.released && live.url + ? { version: live.version, released: live.released, url: live.url } + : typedRelease; + +export const project = { + version: release.version, + released: release.released, + releaseUrl: release.url, // github.com/pelican/panel (stargazers, contributors on the default branch) stars: 2419, contributors: 235, diff --git a/package.json b/package.json index 776b61be..c4c6c04a 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dev": "next dev", "dev:site": "bun router/dev-server.mjs", "build": "next build", - "prebuild": "bun scripts/check-content.mjs && bun scripts/sync-eggs.mjs --if-online", + "prebuild": "bun scripts/check-content.mjs && bun scripts/sync-eggs.mjs --if-online && bun scripts/sync-release.mjs", "postbuild": "bun scripts/check-paths.mjs && bun scripts/check-links.mjs", "test": "bun test", "typecheck": "fumadocs-mdx && next typegen && tsc --noEmit", @@ -15,6 +15,7 @@ "check:paths": "bun scripts/check-paths.mjs", "check:links": "bun scripts/check-links.mjs", "sync:eggs": "bun scripts/sync-eggs.mjs", + "sync:release": "bun scripts/sync-release.mjs", "pack:docs": "bun scripts/pack-docs.mjs", "postinstall": "fumadocs-mdx" }, diff --git a/scripts/README.md b/scripts/README.md index aaa9ee2f..c6c27f08 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -27,6 +27,7 @@ run and change one without reading the others first: | --- | --- | --- | --- | --- | | `check-content.mjs` | Fails if a page in `content/` could run code (MDX compiles pages to JavaScript) | Before every build, and in CI | `bun run check:content` | `check-content.test.mjs` | | `sync-eggs.mjs` | Refreshes the egg data for the interim `/eggs` page and the homepage games strip. Uses the network and rewrites `data/eggs.json`, `public/data/eggs/`, `public/img/eggs/` and `public/img/games/` | Before every build (`--if-online`: no network keeps the saved data; a bug still fails); by hand | `bun run sync:eggs` | `sync-eggs.test.mjs` | +| `sync-release.mjs` | Reads the latest Pelican Panel release from GitHub (version, date, link) for the homepage and `llms.txt`, into `data/release.json`. Uses the network (`GITHUB_TOKEN` if set); on any failure it prints one line and the build uses the typed values in `lib/home-data.ts` | Before every build (never fails it: 5 s timeout); by hand | `bun run sync:release` | `sync-release.test.mjs` | | `check-paths.mjs` | Fails if the build puts a file where pelican.dev won't serve it from this build, misses a root file, or a docs page loads something from outside `/docs/` | After every build, and in CI | `bun run check:paths` | `check-paths.test.mjs` | | `check-links.mjs` | Fails if a link on a docs page goes to a docs page, file or `#anchor` that isn't in the build (links to the Hub and other sites aren't checked) | After every build, and in CI | `bun run check:links` | `check-links.test.mjs` | | `pack-docs.mjs` | Packs `out/` into the folder the Hub serves on pelican.dev (docs, root files, 404 page, redirects) | Before every publish, in CI ("Publish docs build"); by hand to look at the result | `bun run pack:docs` | `pack-docs.test.mjs` | @@ -35,13 +36,14 @@ run and change one without reading the others first: | `../router/dev-server.mjs` | Shows pelican.dev as one site on your machine (docs from `out/`, the rest from a local Hub) | By hand | `bun run dev:site` | `router/dev-server.test.mjs` | | `../router/worker.mjs` | The Cloudflare Worker option for later (not deployed) | Not deployed | see `router/README.md` | `router/worker.test.mjs` | -`bun run build` runs the checks around Next.js: `prebuild` runs `check-content` and `sync-eggs` -(`--if-online`), and `postbuild` runs `check-paths` and `check-links`. +`bun run build` runs the checks around Next.js: `prebuild` runs `check-content`, `sync-eggs` +(`--if-online`) and `sync-release`, and `postbuild` runs `check-paths` and `check-links`. **The build changes tracked files.** `sync-eggs` refreshes the egg data, so after `bun run build` you may see changes in `data/eggs.json`, `public/data/eggs/`, `public/img/eggs/` and `public/img/games/`. Commit -them only when a pull request is about the egg data. Otherwise leave them out -(`git restore data public/data public/img/eggs public/img/games`). +them only when a pull request is about the egg data. `sync-release` writes the latest release into +`data/release.json`; in git that file holds no release (the typed values in `lib/home-data.ts` apply), so +never commit it. Leave them out with `git restore data public/data public/img/eggs public/img/games`. ## Before a pull request diff --git a/scripts/sync-release.mjs b/scripts/sync-release.mjs new file mode 100644 index 00000000..e7ab2e98 --- /dev/null +++ b/scripts/sync-release.mjs @@ -0,0 +1,50 @@ +#!/usr/bin/env bun +/** + * Reads the latest Pelican Panel release from GitHub, for the homepage and llms.txt. + * + * When: before every build (prebuild); by hand to see what the build will use + * Writes: data/release.json ({} when GitHub can't be reached: the typed values in lib/home-data.ts are used) + * Run: bun run sync:release + * Tests: bun test scripts/sync-release.test.mjs + * + * Never fails the build: no network, a rate limit or a 5-second timeout just means the fallback. + * GITHUB_TOKEN, when set (CI sets it), raises GitHub's rate limit. + */ +import { join } from 'node:path'; + +const OUT = join(import.meta.dir, '..', 'data', 'release.json'); + +/** The newest published release (drafts skipped, prereleases kept), or null. */ +export function pickRelease(releases) { + const latest = releases + .filter((release) => !release.draft && release.published_at) + .sort((a, b) => Date.parse(b.published_at) - Date.parse(a.published_at))[0]; + if (!latest) return null; + + return { + version: latest.tag_name.replace(/^v/, ''), // "v1.0.0-rc.4" → "1.0.0-rc.4" + released: new Date(latest.published_at).toLocaleDateString('en-GB', { + day: 'numeric', + month: 'long', + year: 'numeric', + timeZone: 'UTC', + }), + url: latest.html_url, + }; +} + +if (import.meta.main) { + let release = null; + try { + const response = await fetch('https://api.github.com/repos/pelican/panel/releases?per_page=10', { + headers: process.env.GITHUB_TOKEN ? { Authorization: `Bearer ${process.env.GITHUB_TOKEN}` } : {}, + signal: AbortSignal.timeout(5000), + }); + if (!response.ok) throw new Error(`GitHub answered ${response.status}`); + release = pickRelease(await response.json()); + } catch (error) { + console.warn(`release: using the typed version in lib/home-data.ts (${error.message})`); + } + await Bun.write(OUT, `${JSON.stringify(release ?? {}, null, 2)}\n`); + if (release) console.log(`release: pelican/panel ${release.version}, ${release.released}`); +} diff --git a/scripts/sync-release.test.mjs b/scripts/sync-release.test.mjs new file mode 100644 index 00000000..24269cdf --- /dev/null +++ b/scripts/sync-release.test.mjs @@ -0,0 +1,40 @@ +// bun test scripts/sync-release.test.mjs (all tests: bun test) +// Which release sync-release.mjs picks from GitHub's list. No network: the list is written here. +import { expect, test } from 'bun:test'; +import { pickRelease } from './sync-release.mjs'; + +const release = (tag, publishedAt, draft = false) => ({ + tag_name: tag, + published_at: publishedAt, + html_url: `https://github.com/pelican/panel/releases/tag/${tag}`, + draft, +}); + +test('takes the newest release, whatever order GitHub lists them in', () => { + expect( + pickRelease([ + release('v1.0.0-rc.3', '2026-11-14T17:04:30Z'), + release('v1.0.0-rc.4', '2026-11-19T18:47:34Z'), + release('v1.0.0-rc.2', '2026-10-22T16:29:49Z'), + ]), + ).toEqual({ + version: '1.0.0-rc.4', + released: '19 November 2026', + url: 'https://github.com/pelican/panel/releases/tag/v1.0.0-rc.4', + }); +}); + +test('skips drafts, which have no publish date yet', () => { + expect(pickRelease([release('v1.0.1', null, true), release('v1.0.0-rc.4', '2026-11-19T18:47:34Z')]).version).toBe( + '1.0.0-rc.4', + ); +}); + +test('reads the date in UTC', () => { + expect(pickRelease([release('v1.0.0', '2026-11-19T23:30:00Z')]).released).toBe('19 November 2026'); +}); + +test('gives null when there is no published release', () => { + expect(pickRelease([])).toBeNull(); + expect(pickRelease([release('v1.0.1', null, true)])).toBeNull(); +});