Files
zaunistandClaude Opus 4.5 d1861fbebe ci: optimize docker build trigger and add hitokoto to release name
- Change docker-build.yml trigger from push-to-main to release-published
  and workflow_dispatch for more controlled builds
- Add hitokoto API integration to release workflow for dynamic release names

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 17:08:26 +08:00

63 lines
2.0 KiB
YAML

name: Create Release
on: push
jobs:
build:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Hitokoto
id: hitokoto
run: |
HITOKOTO=$(curl -s 'https://v1.hitokoto.cn/' | jq -r '.hitokoto')
echo "sentence=$HITOKOTO" >> $GITHUB_OUTPUT
- name: Generate Changelog
id: changelog
run: |
# 获取当前标签
CURRENT_TAG=${GITHUB_REF#refs/tags/}
# 查找上一个标签(如果存在)
PREVIOUS_TAG=$(git describe --tags --abbrev=0 $CURRENT_TAG^ 2>/dev/null || echo "")
# 生成变更日志
echo "generating changelog from $PREVIOUS_TAG to $CURRENT_TAG"
echo "changelog<<EOF" >> $GITHUB_OUTPUT
if [ -z "$PREVIOUS_TAG" ]; then
# 如果没有上一个标签,则获取所有提交
echo "## 完整变更日志" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
git log --pretty=format:"- %s (%h) by %an" >> $GITHUB_OUTPUT
else
# 获取自上一个标签以来的提交
echo "## 自 $PREVIOUS_TAG 以来的变更" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
git log $PREVIOUS_TAG..$CURRENT_TAG --pretty=format:"- %s (%h) by %an" >> $GITHUB_OUTPUT
fi
echo "" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.TOKEN }}
generate_release_notes: true
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }} - ${{ steps.hitokoto.outputs.sentence }}
body: |
${{ github.event.head_commit.message }}
${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false