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
7 changes: 7 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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'
Expand Down
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions components/home/sections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export function ActivitySection() {
</dl>
<p className="pl-activity__latest">
Latest release:{' '}
<a href={`${repo}/releases/tag/v${project.version}`}>
<a href={project.releaseUrl}>
{project.version}, {project.released}
</a>
</p>
Expand Down Expand Up @@ -508,7 +508,7 @@ export function SiteFooterNav() {
</div>
<p className="pl-footer__legal">
© 2024–{new Date().getFullYear()} Pelican · {project.license} · Latest release{' '}
<a href={`${repo}/releases/tag/v${project.version}`}>{project.version}</a>, {project.released}
<a href={project.releaseUrl}>{project.version}</a>, {project.released}
</p>
</div>
</footer>
Expand Down
12 changes: 10 additions & 2 deletions components/home/site-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@ 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 (
<>
<a href="#main" className="pl-skip">
Skip to content
</a>
<div className="pl-announce">
<span className="pl-announce__tag">{project.version.replace('1.0.0-', '')}</span>
<span>A crashing plugin can no longer take the panel down, and more.</span>
<a href={`https://github.com/pelican/panel/releases/tag/v${project.version}`} className="pl-announce__link">
<span>{text}</span>
<a href={project.releaseUrl} className="pl-announce__link">
Read the release →
</a>
</div>
Expand Down
1 change: 1 addition & 0 deletions data/release.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
21 changes: 20 additions & 1 deletion lib/home-data.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
"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",
"check:content": "bun scripts/check-content.mjs",
"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"
},
Expand Down
10 changes: 6 additions & 4 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand All @@ -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

Expand Down
50 changes: 50 additions & 0 deletions scripts/sync-release.mjs
Original file line number Diff line number Diff line change
@@ -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}`);
}
40 changes: 40 additions & 0 deletions scripts/sync-release.test.mjs
Original file line number Diff line number Diff line change
@@ -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();
});