Skip to content

Commit fa74804

Browse files
committed
Update .gitignore. Add test.yml workflow and publish-clawhub-plugin.yaml
1 parent 1decf1a commit fa74804

3 files changed

Lines changed: 164 additions & 0 deletions

File tree

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Publish ClawBits Plugin to ClawHub
2+
3+
# Auto-triggers disabled — publishing is currently done manually via
4+
# workflow_dispatch. Re-enable by restoring the `push:` and `workflow_run:`
5+
# blocks below; the version-rewrite step is already gated on the
6+
# `test-publish` ref name.
7+
on:
8+
workflow_dispatch:
9+
# push:
10+
# branches: [test-publish]
11+
# workflow_run:
12+
# workflows: ["Test"]
13+
# types: [completed]
14+
# branches: [main, prod]
15+
16+
permissions:
17+
contents: read
18+
19+
concurrency:
20+
group: publish-clawbits-${{ github.ref_name }}
21+
cancel-in-progress: false
22+
23+
jobs:
24+
test:
25+
name: Test
26+
uses: ./.github/workflows/test.yaml
27+
28+
publish-plugin:
29+
name: Publish plugin
30+
needs: test
31+
runs-on: ubuntu-24.04
32+
steps:
33+
- name: Checkout tested commit
34+
uses: actions/checkout@v4
35+
with:
36+
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}
37+
persist-credentials: false
38+
39+
- name: Setup Node.js
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: '22'
43+
44+
- name: Setup Bun
45+
uses: oven-sh/setup-bun@v2
46+
with:
47+
bun-version: latest
48+
49+
- name: Install plugin dependencies
50+
run: bun install --frozen-lockfile
51+
52+
- name: Mark plugin package as test-publish
53+
if: github.ref_name == 'test-publish'
54+
run: |
55+
node <<'NODE'
56+
const fs = require('node:fs');
57+
const suffix = `test-publish.${process.env.GITHUB_RUN_NUMBER}`;
58+
function updateVersion(path) {
59+
const json = JSON.parse(fs.readFileSync(path, 'utf8'));
60+
const base = String(json.version || '0.0.0').replace(/-test-publish(?:\.[0-9]+)?$/u, '');
61+
json.version = `${base}-${suffix}`;
62+
fs.writeFileSync(path, `${JSON.stringify(json, null, 2)}\n`);
63+
return json.version;
64+
}
65+
const packageVersion = updateVersion('package.json');
66+
const manifestVersion = updateVersion('openclaw.plugin.json');
67+
if (packageVersion !== manifestVersion) {
68+
throw new Error(`Version mismatch: package=${packageVersion} manifest=${manifestVersion}`);
69+
}
70+
console.log(`Marked ClawBits plugin as ${packageVersion}`);
71+
NODE
72+
73+
- name: Verify version parity
74+
if: github.ref_name != 'test-publish'
75+
run: |
76+
node <<'NODE'
77+
const fs = require('node:fs');
78+
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
79+
const mft = JSON.parse(fs.readFileSync('openclaw.plugin.json', 'utf8')).version;
80+
if (pkg !== mft) {
81+
console.error(`Version mismatch: package=${pkg} manifest=${mft}`);
82+
process.exit(1);
83+
}
84+
console.log(`Publishing version ${pkg}`);
85+
NODE
86+
87+
- name: Build plugin
88+
run: node node_modules/typescript/bin/tsc
89+
90+
- name: Stage publish directory
91+
id: pack
92+
run: |
93+
rm -rf publish/clawbits-openclaw-plugin
94+
mkdir -p publish/clawbits-openclaw-plugin
95+
cp -r dist src docs openclaw.plugin.json clawbits.config.example.json package.json publish/clawbits-openclaw-plugin/
96+
[ -f PLUGIN_SPEC.md ] && cp PLUGIN_SPEC.md publish/clawbits-openclaw-plugin/ || true
97+
[ -f STREAMING_DESIGN.md ] && cp STREAMING_DESIGN.md publish/clawbits-openclaw-plugin/ || true
98+
echo "publish_path=publish/clawbits-openclaw-plugin" >> "$GITHUB_OUTPUT"
99+
100+
- name: Install ClawHub CLI
101+
run: npm install --global clawhub@latest
102+
103+
- name: Authenticate ClawHub CLI
104+
env:
105+
CLAWHUB_API_TOKEN: ${{ secrets.CLAWHUB_API_TOKEN }}
106+
run: |
107+
if [ -z "$CLAWHUB_API_TOKEN" ]; then
108+
echo "::error::Missing required secret CLAWHUB_API_TOKEN"
109+
exit 1
110+
fi
111+
clawhub login --token "$CLAWHUB_API_TOKEN" --no-browser
112+
113+
- name: Verify ClawHub authentication
114+
run: clawhub whoami
115+
116+
- name: Publish package to ClawHub
117+
run: |
118+
clawhub package publish "${{ steps.pack.outputs.publish_path }}" \
119+
--family code-plugin \
120+
--source-repo "${{ github.repository }}" \
121+
--source-commit "${{ github.sha }}" \
122+
--source-ref "${{ github.ref_name }}"

.github/workflows/test.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_call:
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: ubuntu-24.04
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
persist-credentials: false
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '22'
26+
27+
- name: Setup Bun
28+
uses: oven-sh/setup-bun@v2
29+
with:
30+
bun-version: latest
31+
32+
- name: Install dependencies
33+
run: bun install --frozen-lockfile
34+
35+
- name: Typecheck
36+
run: node node_modules/typescript/bin/tsc --noEmit
37+
38+
- name: Run tests
39+
run: bun run test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ dist/
77
clawbits.config.json
88
package-lock.json
99
.DS_Store
10+
*.swp
11+
*.swo
12+

0 commit comments

Comments
 (0)