Skip to content

Commit 115da2c

Browse files
freelwfreelw
andauthored
build: bundle platform binaries in Skill package (#14)
Co-authored-by: freelw <“freelw81@qq.com“>
1 parent 8201231 commit 115da2c

11 files changed

Lines changed: 65 additions & 15 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ jobs:
6969
merge-multiple: true
7070
- name: Package SkillHub upload ZIP
7171
run: |
72-
./scripts/package-skill.sh
7372
version="${GITHUB_REF_NAME#v}"
73+
install -D -m 0755 \
74+
"browser-cli-v${version}-aarch64-apple-darwin" \
75+
skills/lexmount-browser/bin/browser-cli
76+
install -D -m 0755 \
77+
"browser-cli-v${version}-x86_64-pc-windows-msvc.exe" \
78+
skills/lexmount-browser/bin/browser-cli.exe
79+
./scripts/package-skill.sh
7480
cp dist/lexmount-browser.zip "lexmount-browser-v${version}-skillhub.zip"
7581
sha256sum "lexmount-browser-v${version}-skillhub.zip" > "lexmount-browser-v${version}-skillhub.zip.sha256"
7682
- run: cat *.sha256 | sort -k2 > SHA256SUMS

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/target/
22
/dist/
3+
/skills/lexmount-browser/bin/
34
*.tmp

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lexmount-browser"
3-
version = "1.1.7"
3+
version = "1.1.8"
44
edition = "2024"
55
license = "MIT"
66
description = "Native Rust SDK and CLI for Lexmount cloud browsers"

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,22 @@ surface.
2525
The publishable Skill is in `skills/lexmount-browser`. Build a deterministic ZIP:
2626

2727
```bash
28+
mkdir -p skills/lexmount-browser/bin
29+
cp /path/to/macos-arm64/browser-cli skills/lexmount-browser/bin/browser-cli
30+
cp /path/to/windows-x64/browser-cli.exe skills/lexmount-browser/bin/browser-cli.exe
2831
./scripts/package-skill.sh
2932
```
3033

31-
The ZIP contains `SKILL.md` at its archive root and can be uploaded directly to
32-
SkillHub. Tagged releases publish it as `lexmount-browser-v<VERSION>-skillhub.zip`
33-
alongside the two platform binaries and `SHA256SUMS`.
34+
The ZIP contains `SKILL.md` at its archive root plus the signed macOS arm64
35+
binary at `bin/browser-cli` and the Windows x64 binary at
36+
`bin/browser-cli.exe`. It can be uploaded directly to SkillHub. Tagged releases
37+
publish it as `lexmount-browser-v<VERSION>-skillhub.zip` alongside the standalone
38+
platform binaries and `SHA256SUMS`.
3439

35-
The package installer downloads a pinned GitHub Release binary and verifies its
36-
SHA-256 digest before installation. Set `LEXMOUNT_BROWSER_CLI_VERSION` only when
37-
testing a different published release.
40+
The Skill uses the bundled binary for the current platform. Its bootstrap script
41+
downloads a pinned GitHub Release binary and verifies its SHA-256 digest only as
42+
a fallback when the bundled binary is missing. Set `LEXMOUNT_BROWSER_CLI_VERSION`
43+
only when testing a different published release.
3844

3945
Published binaries are intentionally limited to two targets: macOS arm64 and
4046
Windows x64. The macOS binary is signed with a Developer ID Application

scripts/package-skill.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,30 @@ trap 'rm -rf "$staging_dir"' EXIT INT TERM
88
mkdir -p "$dist_dir"
99
rm -f "$dist_dir/lexmount-browser.zip"
1010

11+
for required_binary in \
12+
"$skill_dir/bin/browser-cli" \
13+
"$skill_dir/bin/browser-cli.exe"
14+
do
15+
if [ ! -f "$required_binary" ]; then
16+
echo "Missing required Skill binary: $required_binary" >&2
17+
exit 1
18+
fi
19+
done
20+
21+
file "$skill_dir/bin/browser-cli" | grep -q 'Mach-O 64-bit.*arm64' || {
22+
echo "bin/browser-cli is not a macOS arm64 executable" >&2
23+
exit 1
24+
}
25+
file "$skill_dir/bin/browser-cli.exe" | grep -q 'PE32+ executable.*x86-64' || {
26+
echo "bin/browser-cli.exe is not a Windows x64 executable" >&2
27+
exit 1
28+
}
29+
1130
(
1231
cd "$skill_dir"
13-
find . -type f ! -path './bin/*' ! -name '.DS_Store' -print | LC_ALL=C sort |
32+
find . -type f ! -name '.DS_Store' \
33+
\( ! -path './bin/*' -o -path './bin/browser-cli' -o -path './bin/browser-cli.exe' \) \
34+
-print | LC_ALL=C sort |
1435
while IFS= read -r relative_path; do
1536
mkdir -p "$staging_dir/$(dirname -- "$relative_path")"
1637
cp "$relative_path" "$staging_dir/$relative_path"
@@ -20,6 +41,7 @@ rm -f "$dist_dir/lexmount-browser.zip"
2041
find "$staging_dir" -type d -exec chmod 0755 {} +
2142
find "$staging_dir" -type f -exec chmod 0644 {} +
2243
find "$staging_dir/scripts" -type f \( -name '*.sh' -o -name '*.ps1' \) -exec chmod 0755 {} +
44+
find "$staging_dir/bin" -type f -exec chmod 0755 {} +
2345
find "$staging_dir" -exec touch -t 198001010000 {} +
2446

2547
(

skills/lexmount-browser/SKILL.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@ description: Use Lexmount cloud browsers to open and interact with JavaScript-he
55

66
# Lexmount Browser
77

8-
Use the native Rust binary at `${CODEBUDDY_SKILL_DIR}/bin/browser-cli` on macOS or `${CODEBUDDY_SKILL_DIR}/bin/browser-cli.exe` on Windows. Release binaries support macOS arm64 and Windows x64 and emit JSON. The examples below abbreviate that path as `browser-cli`; resolve it to the platform path before running commands.
8+
Use the bundled native Rust binary that matches the current platform:
9+
10+
- macOS arm64: `${CODEBUDDY_SKILL_DIR}/bin/browser-cli`
11+
- Windows x64: `${CODEBUDDY_SKILL_DIR}/bin/browser-cli.exe`
12+
13+
Do not run the binary for the other platform. Both binaries emit JSON. The examples below abbreviate the selected platform path as `browser-cli`; resolve it before running commands.
914

1015
## Setup
1116

12-
1. Run the platform `doctor` script from `${CODEBUDDY_SKILL_DIR}/scripts/`. If the binary is missing, run the matching bootstrap script after telling the user that it downloads a fixed-version release binary and verifies its SHA-256 digest.
17+
1. Run `doctor.sh` on macOS or `doctor.ps1` on Windows from `${CODEBUDDY_SKILL_DIR}/scripts/`. Use the bundled platform binary. Only if that binary is missing, run the matching bootstrap script after telling the user that it downloads a fixed-version replacement and verifies its SHA-256 digest.
1318
2. If credentials are missing, run `browser-cli auth login`. Let the user approve in their browser. Never ask them to paste an API key into chat.
1419
3. Run `browser-cli doctor` again. Continue only when `ready_for_browser_actions` is true.
1520

skills/lexmount-browser/scripts/bootstrap.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
$ErrorActionPreference = "Stop"
2-
$version = if ($env:LEXMOUNT_BROWSER_CLI_VERSION) { $env:LEXMOUNT_BROWSER_CLI_VERSION } else { "1.1.7" }
3-
if (-not [Environment]::Is64BitOperatingSystem) { throw "Only 64-bit Windows is supported" }
2+
$version = if ($env:LEXMOUNT_BROWSER_CLI_VERSION) { $env:LEXMOUNT_BROWSER_CLI_VERSION } else { "1.1.8" }
3+
$architecture = if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE }
4+
if ($architecture -ne "AMD64") { throw "Only Windows x64 is supported" }
45
$asset = "browser-cli-v$version-x86_64-pc-windows-msvc.exe"
56
$repo = "https://github.com/lexmount/browser-cli-rs/releases/download/v$version"
67
$tmp = Join-Path ([IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())

skills/lexmount-browser/scripts/bootstrap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
set -eu
33

4-
version="${LEXMOUNT_BROWSER_CLI_VERSION:-1.1.7}"
4+
version="${LEXMOUNT_BROWSER_CLI_VERSION:-1.1.8}"
55
repo="https://github.com/lexmount/browser-cli-rs/releases/download/v${version}"
66
case "$(uname -s)-$(uname -m)" in
77
Darwin-arm64) target="aarch64-apple-darwin" ;;

skills/lexmount-browser/scripts/doctor.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
$ErrorActionPreference = "Stop"
2+
$architecture = if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE }
3+
if ($architecture -ne "AMD64") {
4+
Write-Output '{"ok":false,"error":"unsupported_platform","message":"This Skill supports Windows x64 through scripts/doctor.ps1 and macOS arm64 through scripts/doctor.sh."}'
5+
exit 2
6+
}
27
$skillBinary = Join-Path (Split-Path -Parent $PSScriptRoot) "bin\browser-cli.exe"
38
if (Test-Path $skillBinary) { & $skillBinary doctor; exit $LASTEXITCODE }
49
Write-Output '{"ok":false,"error":"command_not_found","message":"Skill-local browser-cli.exe is missing. Run scripts/bootstrap.ps1 first."}'

0 commit comments

Comments
 (0)