From c7570732c0becb7dfa311ad6d21aa991221a0bf1 Mon Sep 17 00:00:00 2001 From: jackwener Date: Fri, 6 Mar 2026 00:06:52 +0800 Subject: [PATCH] ci add auto publish to ClawHub on version tags --- .github/workflows/publish-clawhub.yml | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/publish-clawhub.yml diff --git a/.github/workflows/publish-clawhub.yml b/.github/workflows/publish-clawhub.yml new file mode 100644 index 0000000..88e98a5 --- /dev/null +++ b/.github/workflows/publish-clawhub.yml @@ -0,0 +1,51 @@ +name: Publish to ClawHub + +on: + push: + tags: + - "v*" + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + env: + CLAWHUB_SLUG: twitter-cli + CLAWHUB_NAME: twitter-cli + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install ClawHub CLI + run: npm install -g clawhub@0.7.0 + + - name: Publish to ClawHub + env: + CLAWHUB_TOKEN: ${{ secrets.CLAWHUB_TOKEN }} + run: | + if [ -z "${CLAWHUB_TOKEN:-}" ]; then + echo "Missing required secret: CLAWHUB_TOKEN" + exit 1 + fi + + VERSION="${GITHUB_REF_NAME#v}" + echo "Publishing ${CLAWHUB_SLUG}@${VERSION}" + + if clawhub --no-input inspect "${CLAWHUB_SLUG}" --version "${VERSION}" >/dev/null 2>&1; then + echo "Version ${VERSION} already exists on ClawHub, skipping publish." + exit 0 + fi + + clawhub --no-input login --token "${CLAWHUB_TOKEN}" --no-browser + clawhub --no-input publish . \ + --slug "${CLAWHUB_SLUG}" \ + --name "${CLAWHUB_NAME}" \ + --version "${VERSION}" \ + --changelog "Release ${VERSION}" \ + --tags latest