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
34 changes: 27 additions & 7 deletions .github/workflows/module-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ on:
required: true
default: true
type: boolean
create_github_release:
description: 使用主仓 token 在模块仓创建标签和 Release(需要模块仓 Contents 写权限)
required: true
default: false
type: boolean

permissions:
contents: read
Expand Down Expand Up @@ -87,16 +92,23 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.SFMC_GITHUB_TOKEN }}
MODULE: ${{ inputs.module }}
CREATE_RELEASE: ${{ inputs.create_github_release }}
run: |
if [ -z "${NODE_AUTH_TOKEN}" ] || [ -z "${GH_TOKEN}" ]; then
echo "::error::主仓发布凭据未配置"
if [ -z "${NODE_AUTH_TOKEN}" ]; then
echo "::error::主仓 NPM_TOKEN 未配置"
exit 1
fi
pnpm whoami >/dev/null
can_push="$(gh api "repos/Tanya7z/sfmc-module-${MODULE}" --jq '.permissions.push')"
if [ "${can_push}" != "true" ]; then
echo "::error::SFMC_GITHUB_TOKEN 无法写入模块仓"
exit 1
if [ "${CREATE_RELEASE}" = "true" ]; then
if [ -z "${GH_TOKEN}" ]; then
echo "::error::主仓 SFMC_GITHUB_TOKEN 未配置"
exit 1
fi
can_push="$(gh api "repos/Tanya7z/sfmc-module-${MODULE}" --jq '.permissions.push')"
if [ "${can_push}" != "true" ]; then
echo "::error::SFMC_GITHUB_TOKEN 无法写入模块仓"
exit 1
fi
fi

- run: pnpm install --frozen-lockfile
Expand All @@ -123,7 +135,7 @@ jobs:
pnpm publish --access public --tag latest --no-git-checks

- name: 创建模块版本标签与 GitHub Release
if: inputs.dry_run == false
if: inputs.dry_run == false && inputs.create_github_release == true
env:
GH_TOKEN: ${{ secrets.SFMC_GITHUB_TOKEN }}
MODULE: ${{ inputs.module }}
Expand All @@ -148,3 +160,11 @@ jobs:
fi
gh release view "${tag}" --repo "${repo}" >/dev/null 2>&1 || \
gh release create "${tag}" --repo "${repo}" --target "${COMMIT}" --title "${tag}" --generate-notes

- name: 提示补齐模块版本标签与 Release
if: inputs.dry_run == false && inputs.create_github_release == false
env:
MODULE: ${{ inputs.module }}
VERSION: ${{ inputs.version }}
COMMIT: ${{ inputs.commit }}
run: echo "::notice::npm 发布完成;请用有模块仓写权限的维护者凭据,为 ${MODULE} 的 ${COMMIT} 创建 v${VERSION} 标签与 GitHub Release"
2 changes: 2 additions & 0 deletions docs/zh/dev/publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ pnpm publish --tag beta
2. 在 SFMC 工作目录:`sfmc mod install <id>`
3. `mod enable` → `mod reload`

官方模块可从主仓手动运行 `module-publish` 工作流。主仓现有 `SFMC_GITHUB_TOKEN` 没有模块仓创建 Git tag 的权限,因此正式发布时保持 `create_github_release=false`;npm 发布成功后,由有模块仓写权限的维护者在对应模块仓为指定 `commit` 创建 `v<version>` 标签和 GitHub Release。补齐后再更新 `sfmc-modules` 索引。若以后为工作流配置了模块仓 Contents 写权限,可将 `create_github_release` 设为 `true`。

命名与联调见 [模块开发](./module-author.md)。

## 附录:平台包发布(贡献者)
Expand Down
1 change: 1 addition & 0 deletions docs/zh/dev/stable-release-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@
- 在隔离服务关闭后,将测试数据、配置、模块目录及测试世界冷备份并解压至另一测试目录;54 个文件逐项 SHA256 相同,恢复数据库 `PRAGMA integrity_check` 为 `ok`。从恢复目录启动候选 db-server 后,健康检查与 QQ 管理队列均返回成功,再正常停止。这只验证隔离样本的备份/恢复,不代表正式服历史数据迁移已经验收。
- 平台正式版 PR #111 合并后,Changesets 工作流成功发布 9 个公开包,并建立对应 Git tag 和 GitHub Release;公共 registry 的精确版本与 `latest` 已逐项核对。隔离空目录以 pnpm 从公共 registry 安装 `@sfmc-bds/sfmc@0.2.0` 成功,直接运行其 CLI 的 `--version` 输出 `0.2.0`。升级文档中的旧 `sfmc version` 命令已改正。
- 首个模块 `activity-log@0.2.1` 的集中工作流完成 npm 发布,但标签步骤误把 GitHub API 的 404 当作已有标签而失败;公共 registry 已返回该版本,缺失的 `v0.2.1` 标签和 GitHub Release 已补到发布提交 `35c33e4`。工作流正在修复后再发布其余模块。`qq-link` 主分支的集中 dry run 已成功。
- `activity-log` 的标签缺失判断已在 PR #112 修复并合并。第二个模块 `afk@0.2.0` 完成 npm 发布后,GitHub 返回 403,证明主仓 `SFMC_GITHUB_TOKEN` 仍缺少模块仓创建标签所需的 Contents 写权限;它的标签和 Release 已由维护者登录态补齐。集中工作流改为默认只完成 npm 发布并明确提示维护者补齐跨仓元数据,待 token 权限补齐后可启用自动创建。
Loading