ci: auto-create GitHub Release on tag push

When a v* tag is pushed, all platforms build in parallel then
a release job collects artifacts and creates a draft GitHub
Release with changelog and download instructions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
7418andClaude Opus 4.6 committed 2026-02-10 22:03:48 +08:00
1 parent 5d80969b3b
commit a346ef230b
1 file changed
+101
+101
View File
@@ -17,6 +17,9 @@ on:
tags:
- "v*"
permissions:
contents: write
jobs:
build-windows:
if: ${{ github.event_name == 'push' || inputs.platform == 'all' || inputs.platform == 'windows' }}
@@ -109,3 +112,101 @@ jobs:
release/*.deb
release/*.rpm
if-no-files-found: warn
release:
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
needs: [build-windows, build-macos, build-linux]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Get version and previous tag
id: meta
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
PREV_TAG=$(git tag --sort=-creatordate | grep '^v' | sed -n '2p' || echo "")
echo "prev_tag=$PREV_TAG" >> "$GITHUB_OUTPUT"
- name: Generate changelog
id: changelog
run: |
PREV_TAG="${{ steps.meta.outputs.prev_tag }}"
if [ -n "$PREV_TAG" ]; then
RANGE="${PREV_TAG}..HEAD"
else
RANGE="HEAD"
fi
{
echo "changelog<<CHANGELOG_EOF"
git log "$RANGE" --pretty=format:'| `%h` | %s |'
echo ""
echo "CHANGELOG_EOF"
} >> "$GITHUB_OUTPUT"
- name: Collect release files
run: |
mkdir -p release-files
find artifacts -type f \( -name '*.exe' -o -name '*.dmg' -o -name '*.AppImage' -o -name '*.deb' -o -name '*.rpm' -o -name '*.zip' \) -exec cp {} release-files/ \;
ls -lh release-files/
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.meta.outputs.version }}"
PREV_TAG="${{ steps.meta.outputs.prev_tag }}"
cat > release-notes.md << 'NOTES_EOF'
## Downloads
**Windows**
- **CodePilot Setup ${{ steps.meta.outputs.version }}.exe** — Windows installer (x64 + arm64)
**macOS**
- **CodePilot-${{ steps.meta.outputs.version }}-arm64.dmg** — macOS Apple Silicon (M1/M2/M3/M4)
- **CodePilot-${{ steps.meta.outputs.version }}-x64.dmg** — macOS Intel
**Linux**
- **AppImage / deb / rpm** — x64 and arm64
## Installation
**Windows**: 下载 exe 安装包,双击安装,按提示完成即可。
**macOS**:
1. 下载对应芯片架构的 DMG 文件
2. 打开 DMG,将 CodePilot 拖入 Applications 文件夹
3. 首次打开时如遇安全提示,前往 **系统设置 → 隐私与安全性** 点击"仍要打开"
4. 在 Settings 页面配置 Anthropic API Key 或环境变量
**Linux**: 使用 AppImage 直接运行,或通过 deb/rpm 包安装。
## Requirements
- Windows 10+ / macOS 12.0+ / Linux (glibc 2.31+)
- Anthropic API Key 或已配置 `ANTHROPIC_API_KEY` 环境变量
- 如需使用代码相关功能,建议安装 Claude Code CLI
## Changelog
NOTES_EOF
if [ -n "$PREV_TAG" ]; then
echo "" >> release-notes.md
echo "| Commit | Description |" >> release-notes.md
echo "|--------|-------------|" >> release-notes.md
echo '${{ steps.changelog.outputs.changelog }}' >> release-notes.md
fi
gh release create "${GITHUB_REF_NAME}" \
--title "CodePilot v${VERSION}" \
--notes-file release-notes.md \
--draft \
release-files/*