Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions .github/workflows/publish-clawhub-plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Publish ClawBits Plugin to ClawHub

# Auto-triggers disabled — publishing is currently done manually via
# workflow_dispatch. Re-enable by restoring the `push:` and `workflow_run:`
# blocks below; the version-rewrite step is already gated on the
# `test-publish` ref name.
on:
workflow_dispatch:
# push:
# branches: [test-publish]
# workflow_run:
# workflows: ["Test"]
# types: [completed]
# branches: [main, prod]

permissions:
contents: read

concurrency:
group: publish-clawbits-${{ github.ref_name }}
cancel-in-progress: false

jobs:
test:
name: Test
uses: ./.github/workflows/test.yaml

publish-plugin:
name: Publish plugin
needs: test
runs-on: ubuntu-24.04
steps:
- name: Checkout tested commit
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install plugin dependencies
run: bun install --frozen-lockfile

- name: Mark plugin package as test-publish
if: github.ref_name == 'test-publish'
run: |
node <<'NODE'
const fs = require('node:fs');
const suffix = `test-publish.${process.env.GITHUB_RUN_NUMBER}`;
function updateVersion(path) {
const json = JSON.parse(fs.readFileSync(path, 'utf8'));
const base = String(json.version || '0.0.0').replace(/-test-publish(?:\.[0-9]+)?$/u, '');
json.version = `${base}-${suffix}`;
fs.writeFileSync(path, `${JSON.stringify(json, null, 2)}\n`);
return json.version;
}
const packageVersion = updateVersion('package.json');
const manifestVersion = updateVersion('openclaw.plugin.json');
if (packageVersion !== manifestVersion) {
throw new Error(`Version mismatch: package=${packageVersion} manifest=${manifestVersion}`);
}
console.log(`Marked ClawBits plugin as ${packageVersion}`);
NODE

- name: Verify version parity
if: github.ref_name != 'test-publish'
run: |
node <<'NODE'
const fs = require('node:fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
const mft = JSON.parse(fs.readFileSync('openclaw.plugin.json', 'utf8')).version;
if (pkg !== mft) {
console.error(`Version mismatch: package=${pkg} manifest=${mft}`);
process.exit(1);
}
console.log(`Publishing version ${pkg}`);
NODE

- name: Build plugin
run: node node_modules/typescript/bin/tsc

- name: Stage publish directory
id: pack
run: |
rm -rf publish/clawbits-openclaw-plugin
mkdir -p publish/clawbits-openclaw-plugin
cp -r dist src docs openclaw.plugin.json clawbits.config.example.json package.json publish/clawbits-openclaw-plugin/
[ -f PLUGIN_SPEC.md ] && cp PLUGIN_SPEC.md publish/clawbits-openclaw-plugin/ || true
[ -f STREAMING_DESIGN.md ] && cp STREAMING_DESIGN.md publish/clawbits-openclaw-plugin/ || true
echo "publish_path=publish/clawbits-openclaw-plugin" >> "$GITHUB_OUTPUT"

- name: Install ClawHub CLI
run: npm install --global clawhub@latest

- name: Authenticate ClawHub CLI
env:
CLAWHUB_API_TOKEN: ${{ secrets.CLAWHUB_API_TOKEN }}
run: |
if [ -z "$CLAWHUB_API_TOKEN" ]; then
echo "::error::Missing required secret CLAWHUB_API_TOKEN"
exit 1
fi
clawhub login --token "$CLAWHUB_API_TOKEN" --no-browser

- name: Verify ClawHub authentication
run: clawhub whoami

- name: Publish package to ClawHub
run: |
clawhub package publish "${{ steps.pack.outputs.publish_path }}" \
--family code-plugin \
--source-repo "${{ github.repository }}" \
--source-commit "${{ github.sha }}" \
--source-ref "${{ github.ref_name }}"
39 changes: 39 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test

on:
push:
pull_request:
workflow_call:
workflow_dispatch:

permissions:
contents: read

jobs:
test:
name: Test
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Typecheck
run: node node_modules/typescript/bin/tsc --noEmit

- name: Run tests
run: bun run test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ dist/
clawbits.config.json
package-lock.json
.DS_Store
*.swp
*.swo

Loading