Skip to content

Repository files navigation

g-blog Core

g-blog-core 提供 g-blog 的构建核心、公共浏览器 runtime、测试和 Composite Action。用户内容、根配置和完整主题保留在模板仓 night2049/g-blog

使用 Composite Action

调用仓需先 checkout 内容仓与独立站点仓,再调用 Core:

- uses: night2049/g-blog-core@v1
  with:
    site-dir: site
    full: ${{ inputs.full || false }}
    content-pat: ${{ secrets.CONTENT_PAT }}

版本引用:

  • @v1:最新兼容稳定版。
  • @v1.0.5:固定源码版本。
  • @<40 位 commit SHA>:发布前候选验收。

main 不作为消费方默认引用。

Inputs

  • site-dir:调用仓 workspace 内已 checkout 的站点仓相对路径,默认 site
  • full:仅接受字符串 truefalse,默认 false
  • content-pat:可选,仅供 private 内容附件读取。

Action 不负责 checkout、commit 或 push。GITHUB_TOKENcontent-pat 只注入 build 子步骤;站点 Deploy Key 不应传入 Core Action,只应在调用方最终 push 子步骤短暂使用。

调用仓契约

六个配置文件固定放在调用仓根目录:

site.json
build.json
appearance.json
comments.json
content.json
feed.json

site.jsonbuild.json 必需;其余文件沿用默认值和现有校验。旧 config/*.json 布局不受支持。正式主题从调用仓 themes/<name>/ 读取,需包含 theme.jsontemplates/styles/assets/。主题同名浏览器资产覆盖 Core runtime;缺失资产回退到 Core src/runtime/

构建使用四个根:

  • workspaceRoot:调用仓;只读配置、内容和主题。
  • coreRoot:当前 Core package;只读源码、runtime、metadata 和依赖。
  • siteRoot:已 checkout 的站点仓;写静态产物。
  • tempRootRUNNER_TEMP 或系统临时目录下的独占目录;保存全部中间文件,结束后删除。

site-dir 拒绝空值、.、绝对路径、..、反斜杠、NUL、非 Git 目录及 realpath/symlink 越界。站点构建和 CSS 均成功后写入:

{
  "coreVersion": "1.0.5"
}

文件位置为 data/gblog-build.json。文件缺失、非法或版本不一致会强制 full build。 候选 commit SHA 变化但 package.json.version 未变时,metadata 无法识别源码变化;更换候选 SHA 后首次构建必须显式传入 full: true

Tailwind CLI、Tailwind、typography plugin 及主题 bare imports 只从 Core dependencies 解析。调用仓不需要 package.jsonnode_modules 或本地构建工具。

Core 开发

bun install
bun test
bun run typecheck
bun run build:fixture

fixture 位于 test/fixtures/minimal-site/,仅供自动化验收。

发布

Core 使用 SemVer。发布精确版本前必须确认 immutable releases 已启用,且 package.json.versionvX.Y.Z 一致。候选阶段只使用完整 commit SHA。精确版本通过 immutable GitHub Release 发布;移动兼容 tag(如 v1)只能指向已验收且已发布的同一提交。每次移动 v1 都必须伴随新的 package version。

About

g-blog build core and Composite Action

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages