Skip to content

Commit 890a3c9

Browse files
thinkthinkingclaude
andcommitted
ci: 并入 npm 自动发布(NPM_TOKEN 认证)
release workflow 新增 npm-publish job:GoReleaser 发完 GitHub Release 后, 自动发布 @thinkthinking/cli 到 npm registry。 - 用 NPM_TOKEN secret 认证(需在 GitHub 仓库 Secrets 配置) - npm 版本从 tag 自动同步,避免与 GitHub Release 漂移 - 增加 workflow_dispatch 手动入口:首次发布或 tag 已存在时用网页触发 - npm 包补充 README.md Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 05e8075 commit 890a3c9

2 files changed

Lines changed: 86 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,23 @@ on:
44
push:
55
tags:
66
- "v*"
7+
# 手动触发:用于首次发布 npm(tag 已存在、push 不会再触发时),
8+
# 在 GitHub Actions 页面选 release workflow → Run workflow,填版本号。
9+
# 手动触发只发 npm(GitHub Release 此时已存在),跳过 GoReleaser。
10+
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: "要发布到 npm 的版本号(不含 v 前缀,如 0.1.0)"
14+
required: true
715

816
permissions:
917
contents: write
1018

1119
jobs:
12-
release:
20+
# 第一步:GoReleaser 构建 5 平台二进制并创建 GitHub Release。
21+
# 仅在 tag push 时运行;手动触发(dispatch)时跳过。
22+
goreleaser:
23+
if: github.event_name == 'push'
1324
runs-on: ubuntu-latest
1425
steps:
1526
- uses: actions/checkout@v6
@@ -31,3 +42,45 @@ jobs:
3142
args: release --clean
3243
env:
3344
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
46+
# 第二步:发布 npm 分发壳。
47+
# - tag push:等 goreleaser 成功后再发(postinstall 要从 Release 下载二进制)。
48+
# - 手动触发:直接发(Release 已存在)。
49+
npm-publish:
50+
needs: goreleaser
51+
# 手动触发时 goreleaser 被跳过,用 always() + 条件让本 job 仍能运行;
52+
# tag push 时要求 goreleaser 成功。
53+
if: |
54+
always() &&
55+
(github.event_name == 'workflow_dispatch' || needs.goreleaser.result == 'success')
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v6
59+
60+
- name: Set up Node
61+
uses: actions/setup-node@v6
62+
with:
63+
node-version: "22"
64+
registry-url: "https://registry.npmjs.org"
65+
66+
- name: Resolve version
67+
# tag push 用 GITHUB_REF_NAME(去 v 前缀);手动触发用输入参数。
68+
id: ver
69+
run: |
70+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
71+
VERSION="${{ github.event.inputs.version }}"
72+
else
73+
VERSION="${GITHUB_REF_NAME#v}"
74+
fi
75+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
76+
echo "publishing @thinkthinking/cli@$VERSION"
77+
78+
- name: Sync package version
79+
working-directory: npm/package
80+
run: npm version "${{ steps.ver.outputs.version }}" --no-git-tag-version --allow-same-version
81+
82+
- name: Publish to npm
83+
working-directory: npm/package
84+
run: npm publish --access public
85+
env:
86+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

npm/package/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# @thinkthinking/cli
2+
3+
面向 **LLM Agent、自动化脚本和开发者** 的本地 CLI 工具箱。第一期聚焦微信公众号能力:将 Markdown 转换为微信公众号兼容 HTML,并上传草稿。所有命令默认输出统一 JSON envelope。
4+
5+
## 安装
6+
7+
```bash
8+
npm install -g @thinkthinking/cli
9+
```
10+
11+
本 npm 包只是 Go 二进制的分发壳:`postinstall` 会根据你的平台/架构从 [GitHub Releases](https://github.com/thinkthinking/cli/releases) 下载对应二进制,运行时**不依赖 Node**
12+
13+
## 快速开始
14+
15+
```bash
16+
thinkthinking init
17+
thinkthinking config set wechat.app_id wx_your_appid
18+
thinkthinking config set wechat.app_secret your_appsecret
19+
thinkthinking wechat convert --input article.md
20+
thinkthinking wechat draft create --markdown-file article.md --title "标题"
21+
```
22+
23+
## 环境变量
24+
25+
- `THINKTHINKING_SKIP_DOWNLOAD=1` 跳过二进制下载(离线 / 自行构建)
26+
- `THINKTHINKING_VERSION=x.y.z` 指定下载版本
27+
28+
完整文档见 [GitHub 仓库](https://github.com/thinkthinking/cli)
29+
30+
## License
31+
32+
MIT

0 commit comments

Comments
 (0)