chore(version): bump version to 2.12.9 #48
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| build-and-release: | |
| name: Build and Release | |
| runs-on: ubuntu-latest | |
| environment: release | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Fetch tags | |
| run: git fetch --tags --force | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Install dependencies | |
| run: uv sync --group ci -p 3.12 | |
| - name: Cache Ruff | |
| uses: actions/cache@v4 | |
| with: | |
| path: .ruff_cache | |
| key: ${{ runner.os }}-ruff-${{ hashFiles('**/uv.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-ruff- | |
| - name: Cache Mypy | |
| uses: actions/cache@v4 | |
| with: | |
| path: .mypy_cache | |
| key: ${{ runner.os }}-mypy-${{ hashFiles('**/uv.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-mypy- | |
| - name: Run Ruff | |
| run: | | |
| uv run ruff check . | |
| uv run ruff format --check . | |
| - name: Run Mypy | |
| run: uv run mypy . | |
| - name: Build project | |
| run: uv build | |
| - name: Verify dist contains packaged resources | |
| run: | | |
| uv run python -c "import glob, zipfile; wheels=glob.glob('dist/*.whl'); assert wheels, 'no wheel built'; z=zipfile.ZipFile(wheels[0]); names=set(z.namelist()); required={'config.toml.example','res/prompts/undefined.xml','img/xlwy.jpg'}; missing=sorted([p for p in required if p not in names]); assert not missing, f'missing in wheel: {missing}'" | |
| - name: Create Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # 1. 检查是否为注解标签 (Annotated Tag) | |
| TAG_TYPE=$(git cat-file -t ${{ github.ref_name }}) | |
| TAG_CONTENT="" | |
| if [ "$TAG_TYPE" = "tag" ]; then | |
| # 使用 %(contents) 获取完整的 Tag Message | |
| TAG_CONTENT=$(git tag -l --format='%(contents)' ${{ github.ref_name }}) | |
| # 移除 PGP 签名(如果存在) | |
| TAG_CONTENT=$(echo "$TAG_CONTENT" | sed '/-----BEGIN PGP SIGNATURE-----/,/-----END PGP SIGNATURE-----/d') | |
| fi | |
| # 2. 获取上一个 Tag | |
| PREV_TAG=$(git describe --tags --abbrev=0 ${{ github.ref_name }}^ 2>/dev/null || git rev-list --max-parents=0 HEAD) | |
| # 3. 初始化 tag_message.txt | |
| if [ -n "$TAG_CONTENT" ]; then | |
| echo "$TAG_CONTENT" > tag_message.txt | |
| echo -e "\n---\n" >> tag_message.txt | |
| else | |
| touch tag_message.txt | |
| fi | |
| # 4. 追加"Detailed Changes"标题 | |
| echo -e "## 📝 Detailed Changes\n" >> tag_message.txt | |
| # 5. 自动生成基于 Commit 的详细列表 (Angular 规范分类) | |
| # 仅在有对应 commits 时才显示标题 | |
| FEAT_COMMITS=$(git log ${PREV_TAG}..${{ github.ref_name }} --grep="^feat" --pretty=format:"* %s (%h)" 2>/dev/null || true) | |
| if [ -n "$FEAT_COMMITS" ]; then | |
| echo -e "### 🚀 Features" >> tag_message.txt | |
| echo "$FEAT_COMMITS" >> tag_message.txt | |
| echo -e "\n" >> tag_message.txt | |
| fi | |
| FIX_COMMITS=$(git log ${PREV_TAG}..${{ github.ref_name }} --grep="^fix" --pretty=format:"* %s (%h)" 2>/dev/null || true) | |
| if [ -n "$FIX_COMMITS" ]; then | |
| echo -e "### 🐛 Bug Fixes" >> tag_message.txt | |
| echo "$FIX_COMMITS" >> tag_message.txt | |
| echo -e "\n" >> tag_message.txt | |
| fi | |
| OTHER_COMMITS=$(git log ${PREV_TAG}..${{ github.ref_name }} --grep="^feat\|^fix" --invert-grep --pretty=format:"* %s (%h)" 2>/dev/null || true) | |
| if [ -n "$OTHER_COMMITS" ]; then | |
| echo -e "### 🛠 Maintenance & Others" >> tag_message.txt | |
| echo "$OTHER_COMMITS" >> tag_message.txt | |
| fi | |
| # 6. 创建 Release | |
| gh release create ${{ github.ref_name }} dist/* \ | |
| --title "Undefined ${{ github.ref_name }}" \ | |
| --notes-file tag_message.txt \ | |
| --generate-notes | |
| - name: Publish to PyPI | |
| run: uv publish |