Skip to content

Commit 3b000f7

Browse files
authored
Merge pull request #121 from TrueNine/codex/fix-release-cli-shell-binary
Fix CLI release workflow to package SDK artifacts
2 parents 182ea11 + 6c49c01 commit 3b000f7

File tree

26 files changed

+357
-99
lines changed

26 files changed

+357
-99
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Check GUI Release State
2+
description: Check whether the current GUI version already has a GitHub release tag
3+
4+
inputs:
5+
github-token:
6+
description: GitHub token used for release lookups
7+
required: true
8+
9+
outputs:
10+
version:
11+
description: GUI version from gui/package.json
12+
value: ${{ steps.check.outputs.version }}
13+
should_release:
14+
description: Whether the GUI version still needs a GitHub release
15+
value: ${{ steps.check.outputs.should_release }}
16+
17+
runs:
18+
using: composite
19+
steps:
20+
- name: Check GUI release state
21+
id: check
22+
shell: bash
23+
env:
24+
GH_TOKEN: ${{ inputs.github-token }}
25+
run: |
26+
version=$(jq -r '.version' gui/package.json)
27+
echo "GUI version: $version"
28+
29+
if gh release view "v${version}" >/dev/null 2>&1; then
30+
echo "Release v${version} already exists on GitHub, skipping GUI"
31+
echo "should_release=false" >> "$GITHUB_OUTPUT"
32+
else
33+
echo "Release v${version} does not exist, will build GUI"
34+
echo "should_release=true" >> "$GITHUB_OUTPUT"
35+
echo "version=$version" >> "$GITHUB_OUTPUT"
36+
fi
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Check Release State
2+
description: Check whether CLI and MCP package versions are already published to npm
3+
4+
inputs:
5+
registry-url:
6+
description: npm registry URL used for publish-state checks
7+
required: false
8+
default: "https://registry.npmjs.org/"
9+
10+
outputs:
11+
version:
12+
description: Workspace version from the repository root package.json
13+
value: ${{ steps.check.outputs.version }}
14+
publish_cli:
15+
description: Whether the CLI package should be published
16+
value: ${{ steps.check.outputs.publish_cli }}
17+
publish_mcp:
18+
description: Whether the MCP package should be published
19+
value: ${{ steps.check.outputs.publish_mcp }}
20+
publish_npm:
21+
description: Whether any npm package should be published
22+
value: ${{ steps.check.outputs.publish_npm }}
23+
24+
runs:
25+
using: composite
26+
steps:
27+
- name: Check npm publish state
28+
id: check
29+
shell: bash
30+
env:
31+
NPM_REGISTRY_URL: ${{ inputs.registry-url }}
32+
run: |
33+
check_publish_state() {
34+
local package_json_path="$1"
35+
local output_key="$2"
36+
local version
37+
local name
38+
local published_version
39+
40+
version=$(jq -r '.version' "$package_json_path")
41+
name=$(jq -r '.name' "$package_json_path")
42+
published_version=$(npm view "${name}@${version}" version --registry "$NPM_REGISTRY_URL" 2>/dev/null || echo "")
43+
44+
if [[ "$version" != "$published_version" ]]; then
45+
echo "$name@$version is not published to npm, will publish"
46+
echo "${output_key}=true" >> "$GITHUB_OUTPUT"
47+
return 0
48+
fi
49+
50+
echo "$name@$version already published to npm, skipping"
51+
echo "${output_key}=false" >> "$GITHUB_OUTPUT"
52+
return 1
53+
}
54+
55+
version=$(jq -r '.version' package.json)
56+
echo "version=$version" >> "$GITHUB_OUTPUT"
57+
58+
cli_needs_publish=false
59+
mcp_needs_publish=false
60+
61+
if check_publish_state cli/package.json publish_cli; then
62+
cli_needs_publish=true
63+
fi
64+
65+
if check_publish_state mcp/package.json publish_mcp; then
66+
mcp_needs_publish=true
67+
fi
68+
69+
if [[ "$cli_needs_publish" == "true" || "$mcp_needs_publish" == "true" ]]; then
70+
echo "publish_npm=true" >> "$GITHUB_OUTPUT"
71+
else
72+
echo "publish_npm=false" >> "$GITHUB_OUTPUT"
73+
fi

.github/actions/setup-node-pnpm/action.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ inputs:
1414
description: Optional npm registry URL to configure for npm publish/auth steps
1515
required: false
1616
default: ""
17+
cache:
18+
description: Whether to enable actions/setup-node pnpm cache
19+
required: false
20+
default: "true"
1721
install:
1822
description: Whether to run pnpm install
1923
required: false
@@ -31,14 +35,23 @@ runs:
3135
with:
3236
version: ${{ inputs.pnpm-version }}
3337

34-
- name: Setup Node
38+
- name: Setup Node with pnpm cache
39+
if: inputs.cache == 'true'
3540
uses: actions/setup-node@v6
3641
with:
3742
node-version: ${{ inputs.node-version }}
3843
cache: pnpm
3944
cache-dependency-path: pnpm-lock.yaml
4045
registry-url: ${{ inputs.registry-url }}
4146

47+
- name: Setup Node without pnpm cache
48+
if: inputs.cache != 'true'
49+
uses: actions/setup-node@v6
50+
with:
51+
node-version: ${{ inputs.node-version }}
52+
package-manager-cache: false
53+
registry-url: ${{ inputs.registry-url }}
54+
4255
- name: Install workspace dependencies
4356
if: inputs.install == 'true' && inputs['install-filter'] == ''
4457
shell: bash

.github/workflows/pull-request.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,35 @@ concurrency:
2626
cancel-in-progress: true
2727

2828
jobs:
29+
release-preflight:
30+
if: github.event.pull_request.draft == false
31+
runs-on: ubuntu-24.04
32+
timeout-minutes: 10
33+
steps:
34+
- uses: actions/checkout@v6
35+
36+
- uses: ./.github/actions/setup-node-pnpm
37+
with:
38+
cache: "false"
39+
install: "false"
40+
41+
- name: Run npm release preflight
42+
uses: ./.github/actions/check-release-state
43+
with:
44+
registry-url: https://registry.npmjs.org/
45+
46+
gui-release-preflight:
47+
if: github.event.pull_request.draft == false
48+
runs-on: ubuntu-24.04
49+
timeout-minutes: 10
50+
steps:
51+
- uses: actions/checkout@v6
52+
53+
- name: Run GUI release preflight
54+
uses: ./.github/actions/check-gui-release-state
55+
with:
56+
github-token: ${{ github.token }}
57+
2958
check:
3059
if: github.event.pull_request.draft == false
3160
runs-on: ubuntu-24.04

.github/workflows/release-cli.yml

Lines changed: 7 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -58,52 +58,13 @@ jobs:
5858
- uses: actions/checkout@v6
5959
- uses: ./.github/actions/setup-node-pnpm
6060
with:
61+
cache: "false"
6162
install: "false"
62-
6363
- name: Check if should publish
6464
id: check
65-
run: |
66-
check_publish_state() {
67-
local package_json_path="$1"
68-
local output_key="$2"
69-
local version
70-
local name
71-
local published_version
72-
73-
version=$(jq -r '.version' "$package_json_path")
74-
name=$(jq -r '.name' "$package_json_path")
75-
published_version=$(npm view "${name}@${version}" version --registry "$NPM_REGISTRY_URL" 2>/dev/null || echo "")
76-
77-
if [[ "$version" != "$published_version" ]]; then
78-
echo "$name@$version is not published to npm, will publish"
79-
echo "${output_key}=true" >> "$GITHUB_OUTPUT"
80-
return 0
81-
fi
82-
83-
echo "$name@$version already published to npm, skipping"
84-
echo "${output_key}=false" >> "$GITHUB_OUTPUT"
85-
return 1
86-
}
87-
88-
version=$(jq -r '.version' package.json)
89-
echo "version=$version" >> "$GITHUB_OUTPUT"
90-
91-
cli_needs_publish=false
92-
mcp_needs_publish=false
93-
94-
if check_publish_state cli/package.json publish_cli; then
95-
cli_needs_publish=true
96-
fi
97-
98-
if check_publish_state mcp/package.json publish_mcp; then
99-
mcp_needs_publish=true
100-
fi
101-
102-
if [[ "$cli_needs_publish" == "true" || "$mcp_needs_publish" == "true" ]]; then
103-
echo "publish_npm=true" >> "$GITHUB_OUTPUT"
104-
else
105-
echo "publish_npm=false" >> "$GITHUB_OUTPUT"
106-
fi
65+
uses: ./.github/actions/check-release-state
66+
with:
67+
registry-url: ${{ env.NPM_REGISTRY_URL }}
10768

10869
# 1.5. GUI 版本检查(独立于 npm,检查 GitHub Release)
10970
check-gui-version:
@@ -114,24 +75,11 @@ jobs:
11475
version: ${{ steps.check.outputs.version }}
11576
steps:
11677
- uses: actions/checkout@v6
117-
11878
- name: Check if GUI should be released
11979
id: check
120-
env:
121-
GH_TOKEN: ${{ github.token }}
122-
run: |
123-
version=$(jq -r '.version' gui/package.json)
124-
echo "GUI version: $version"
125-
126-
# Check if this version tag exists on GitHub
127-
if gh release view "v${version}" >/dev/null 2>&1; then
128-
echo "Release v${version} already exists on GitHub, skipping GUI"
129-
echo "should_release=false" >> "$GITHUB_OUTPUT"
130-
else
131-
echo "Release v${version} does not exist, will build GUI"
132-
echo "should_release=true" >> "$GITHUB_OUTPUT"
133-
echo "version=$version" >> "$GITHUB_OUTPUT"
134-
fi
80+
uses: ./.github/actions/check-gui-release-state
81+
with:
82+
github-token: ${{ github.token }}
13583

13684
# 2. 构建 NAPI 二进制(5 平台矩阵)
13785
build-napi:

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ members = [
1010
]
1111

1212
[workspace.package]
13-
version = "2026.10402.103"
13+
version = "2026.10402.109"
1414
edition = "2024"
1515
rust-version = "1.88"
1616
license = "AGPL-3.0-only"

cli/npm/darwin-arm64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@truenine/memory-sync-cli-darwin-arm64",
3-
"version": "2026.10402.103",
3+
"version": "2026.10402.109",
44
"os": [
55
"darwin"
66
],

cli/npm/darwin-x64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@truenine/memory-sync-cli-darwin-x64",
3-
"version": "2026.10402.103",
3+
"version": "2026.10402.109",
44
"os": [
55
"darwin"
66
],

cli/npm/linux-arm64-gnu/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@truenine/memory-sync-cli-linux-arm64-gnu",
3-
"version": "2026.10402.103",
3+
"version": "2026.10402.109",
44
"os": [
55
"linux"
66
],

cli/npm/linux-x64-gnu/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@truenine/memory-sync-cli-linux-x64-gnu",
3-
"version": "2026.10402.103",
3+
"version": "2026.10402.109",
44
"os": [
55
"linux"
66
],

0 commit comments

Comments
 (0)