zy
Committed by GitHub

feat: 添加 GitHub Actions 自动 Release 工作流 (#14)

push 到 main 时自动创建 Release,附带源码 tar.gz/zip 产物。
排除文档/配置类文件变更触发,防止无意义发版。

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
  1 +name: Release
  2 +
  3 +on:
  4 + push:
  5 + branches: [main]
  6 + paths-ignore:
  7 + - "CLAUDE.md"
  8 + - "PROMPT.md"
  9 + - "README.md"
  10 + - ".gitignore"
  11 + - ".claude/**"
  12 + - ".github/**"
  13 + - "tests/**"
  14 + - "docs/**"
  15 +
  16 +permissions:
  17 + contents: write
  18 +
  19 +jobs:
  20 + release:
  21 + runs-on: ubuntu-latest
  22 + steps:
  23 + - name: Checkout
  24 + uses: actions/checkout@v4
  25 +
  26 + - name: Extract version and generate tag
  27 + id: version
  28 + run: |
  29 + VERSION=$(grep -m1 '^version' pyproject.toml | sed 's/.*"\(.*\)".*/\1/')
  30 + SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c1-7)
  31 + TAG="v${VERSION}-${SHORT_SHA}"
  32 + echo "version=$VERSION" >> "$GITHUB_OUTPUT"
  33 + echo "tag=$TAG" >> "$GITHUB_OUTPUT"
  34 +
  35 + - name: Check if tag exists
  36 + id: check_tag
  37 + run: |
  38 + if git ls-remote --tags origin "refs/tags/${{ steps.version.outputs.tag }}" | grep -q .; then
  39 + echo "exists=true" >> "$GITHUB_OUTPUT"
  40 + else
  41 + echo "exists=false" >> "$GITHUB_OUTPUT"
  42 + fi
  43 +
  44 + - name: Package source
  45 + if: steps.check_tag.outputs.exists == 'false'
  46 + run: |
  47 + TAG="${{ steps.version.outputs.tag }}"
  48 + PREFIX="xiaohongshu-skills-${TAG}"
  49 + tar czf "${PREFIX}.tar.gz" \
  50 + --transform "s,^,${PREFIX}/," \
  51 + skills/ scripts/ SKILL.md pyproject.toml uv.lock LICENSE README.md
  52 + zip -r "${PREFIX}.zip" \
  53 + skills/ scripts/ SKILL.md pyproject.toml uv.lock LICENSE README.md \
  54 + -x '*.pyc' '__pycache__/*'
  55 +
  56 + - name: Create GitHub Release
  57 + if: steps.check_tag.outputs.exists == 'false'
  58 + env:
  59 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  60 + run: |
  61 + TAG="${{ steps.version.outputs.tag }}"
  62 + PREFIX="xiaohongshu-skills-${TAG}"
  63 + gh release create "$TAG" \
  64 + "${PREFIX}.tar.gz" \
  65 + "${PREFIX}.zip" \
  66 + --title "$TAG" \
  67 + --generate-notes