Skip to content

Commit 5c52580

Browse files
author
linyuan.yang
committed
release-app
1 parent 2312e02 commit 5c52580

4 files changed

Lines changed: 110 additions & 3 deletions

File tree

‎.github/workflows/release-app.yml‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,62 @@ jobs:
201201
with:
202202
name: sbot-android-apk
203203
path: artifacts/*.apk
204+
205+
publish-vscode:
206+
runs-on: ubuntu-latest
207+
steps:
208+
- uses: actions/checkout@v4
209+
210+
- uses: pnpm/action-setup@v4
211+
with:
212+
version: 10.33.0
213+
214+
- uses: actions/setup-node@v4
215+
with:
216+
node-version: 20
217+
cache: pnpm
218+
219+
- run: pnpm install --frozen-lockfile
220+
221+
- name: Build extension
222+
run: pnpm run build:vscode
223+
224+
- name: Resolve version
225+
id: version
226+
shell: bash
227+
run: |
228+
PKG_VERSION=$(node -p "require('./packages/vscode-extension/package.json').version")
229+
if [ "${{ github.event_name }}" = "push" ]; then
230+
TAG_VERSION="${GITHUB_REF_NAME#app-v}"
231+
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
232+
echo "::error::Tag version ($TAG_VERSION) does not match packages/vscode-extension/package.json version ($PKG_VERSION) — run pnpm run release:app to keep them in sync"
233+
exit 1
234+
fi
235+
fi
236+
echo "version=$PKG_VERSION" >> "$GITHUB_OUTPUT"
237+
238+
- name: Package VSIX
239+
working-directory: packages/vscode-extension
240+
run: npx --yes @vscode/vsce package --no-dependencies --out "sbot-vscode-${{ steps.version.outputs.version }}.vsix"
241+
242+
- name: Publish to VS Marketplace
243+
if: github.event_name == 'push'
244+
working-directory: packages/vscode-extension
245+
env:
246+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
247+
run: npx --yes @vscode/vsce publish --no-dependencies --packagePath "sbot-vscode-${{ steps.version.outputs.version }}.vsix"
248+
249+
- name: Attach VSIX to release
250+
if: github.event_name == 'push'
251+
uses: softprops/action-gh-release@v2
252+
with:
253+
tag_name: ${{ github.ref_name }}
254+
files: packages/vscode-extension/sbot-vscode-${{ steps.version.outputs.version }}.vsix
255+
draft: true
256+
257+
- name: Upload VSIX as artifact
258+
if: github.event_name == 'workflow_dispatch'
259+
uses: actions/upload-artifact@v4
260+
with:
261+
name: sbot-vscode-vsix
262+
path: packages/vscode-extension/sbot-vscode-${{ steps.version.outputs.version }}.vsix

‎packages/vscode-extension/package.json‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
"displayName": "sbot",
44
"description": "Chat with sbot AI server inside VS Code",
55
"version": "0.0.1",
6-
"private": true,
6+
"publisher": "while",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/while-coder/sbot.git",
10+
"directory": "packages/vscode-extension"
11+
},
712
"engines": {
813
"vscode": "^1.85.0"
914
},

‎scripts/release.js‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const TARGETS = {
88
tagPrefix: 'app-v',
99
tauriConf: 'packages/app/src-tauri/tauri.conf.json',
1010
pkgJson: 'packages/app/package.json',
11+
companionPkgJsons: ['packages/vscode-extension/package.json'],
1112
},
1213
helper: {
1314
tagPrefix: 'helper-v',
@@ -127,7 +128,15 @@ function main() {
127128
(releaseNotes.zh !== undefined && pkg.releasenoteZh !== releaseNotes.zh)
128129
);
129130

130-
const mutate = versionChanged || notesChanged;
131+
// companion pkg.json files that should track the main version (e.g. vscode-extension follows app)
132+
const companions = (cfg.companionPkgJsons || []).map((rel) => {
133+
const p = path.join(root, rel);
134+
const json = readJson(p);
135+
return { rel, path: p, json, outOfSync: json.version !== nextVersion };
136+
});
137+
const companionsChanged = companions.some((c) => c.outOfSync);
138+
139+
const mutate = versionChanged || notesChanged || companionsChanged;
131140
const tag = `${cfg.tagPrefix}${nextVersion}`;
132141

133142
console.log(`target : ${target}`);
@@ -165,9 +174,20 @@ function main() {
165174
filesToAdd.push(cfg.tauriConf);
166175
}
167176

177+
for (const c of companions) {
178+
if (c.outOfSync) {
179+
c.json.version = nextVersion;
180+
writeJson(c.path, c.json);
181+
filesToAdd.push(c.rel);
182+
console.log(`companion: bumped ${c.rel} → ${nextVersion}`);
183+
}
184+
}
185+
168186
const commitMsg = versionChanged
169187
? `chore(${target}): release v${nextVersion}`
170-
: `chore(${target}): sync release notes for v${nextVersion}`;
188+
: notesChanged
189+
? `chore(${target}): sync release notes for v${nextVersion}`
190+
: `chore(${target}): sync companion versions for v${nextVersion}`;
171191

172192
run(`git add ${filesToAdd.map((f) => `"${f}"`).join(' ')}`);
173193
run(`git commit -m "${commitMsg}"`);

‎secrets.example/README.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ pnpm --filter @sbot/app exec tauri signer generate \
8888
| `NPM_TOKEN` | npm 发布 | 见下方 [npm](#npm_token) |
8989
| `DOCKERHUB_USERNAME` | Docker Hub 用户名 | Docker Hub 账号 |
9090
| `DOCKERHUB_TOKEN` | Docker Hub PAT | 见下方 [Docker Hub](#dockerhub_token) |
91+
| `VSCE_PAT` | VSCode 插件市场发布 token | 见下方 [VSCE_PAT](#vsce_pat) |
9192

9293
### 生成 base64
9394

@@ -116,6 +117,28 @@ Docker Hub 登录用户名(不是邮箱),即 `hub.docker.com/u/<username>`
116117

117118
CI 一律用 PAT,不要用账号密码。
118119

120+
### `VSCE_PAT`
121+
122+
发布 VSCode 插件到 Marketplace 用。Publisher 在 [marketplace.visualstudio.com/manage/publishers](https://marketplace.visualstudio.com/manage/publishers/) 注册,但 token 必须从 Azure DevOps 申请。
123+
124+
**前置条件**:必须有一个 Azure DevOps organization。没有 org 时所有 PAT 入口都会 404。
125+
126+
1. 打开 https://aex.dev.azure.com/me 看自己有没有 org:
127+
- **有**:记下 org 名(当前账号的 org 是 `qingfeng346`)
128+
- **没有**:页面会引导建一个;名字随便填,Region 选 `Asia Pacific`,建完会跳到 `https://dev.azure.com/<org>`
129+
2. 打开 PAT 页面:https://dev.azure.com/qingfeng346/_usersSettings/tokens
130+
(URL 必须带 org 名,缺了就 404;其他 org 把 `qingfeng346` 替换掉即可)
131+
3. 点 **+ New Token**,填:
132+
- **Name**:随便,比如 `vsce-publish`
133+
- **Organization**:下拉选 **All accessible organizations**(关键,否则 vsce 报 401)
134+
- **Expiration**:按需,最长 1 年
135+
- **Scopes**:选 **Custom defined** → 默认列表里没有 Marketplace,点底部 **Show all scopes** 展开 → 找到 **Marketplace** → 勾 `Manage`
136+
4. **Create** → 立即复制 token(只显示一次,关掉就没了)
137+
138+
Publisher 必须先在 Marketplace 创建好(当前为 `while`),且 [packages/vscode-extension/package.json](../packages/vscode-extension/package.json) 的 `publisher` 字段要与之匹配。
139+
140+
token 过期后 `Release App` workflow 的 `publish-vscode` job 会失败,重新申请 PAT 并更新 secret 即可。
141+
119142
---
120143

121144
## 备份

0 commit comments

Comments
 (0)