Files
twitter-cli-cookiefile/.github/workflows/publish-clawhub.yml
2026-03-06 00:08:39 +08:00

60 lines
1.6 KiB
YAML

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
if [ "${GITHUB_REF_TYPE:-}" = "tag" ] && [ -n "${GITHUB_REF_NAME:-}" ]; then
VERSION="${GITHUB_REF_NAME#v}"
else
VERSION="$(sed -n 's/^version = \"\([^\"]*\)\"/\1/p' pyproject.toml | head -n 1)"
fi
if [ -z "${VERSION:-}" ]; then
echo "Unable to resolve version"
exit 1
fi
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