-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (94 loc) · 3.45 KB
/
changelog-release.yml
File metadata and controls
111 lines (94 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Changelog Release Sync
# 仅支持手动触发,用于补充创建或更新已有版本的 Release Notes
# 注意:tag push 时由 ci.yml 的 release job 自动处理,无需此工作流
on:
workflow_dispatch:
inputs:
version:
description: "Version to sync (e.g., 1.2.0)"
required: true
type: string
permissions:
contents: write
jobs:
sync-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Determine version
id: version
run: |
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
echo "tag=v${{ inputs.version }}" >> $GITHUB_OUTPUT
- name: Read Changelog (English)
id: changelog_en
uses: mindsers/changelog-reader-action@v2
continue-on-error: true
with:
validation_level: none
version: ${{ steps.version.outputs.version }}
path: ./CHANGELOG.md
- name: Read Changelog (Chinese)
id: changelog_zh
uses: mindsers/changelog-reader-action@v2
continue-on-error: true
with:
validation_level: none
version: ${{ steps.version.outputs.version }}
path: ./CHANGELOG_ZH.md
- name: Check if release exists
id: check_release
run: |
if gh release view ${{ steps.version.outputs.tag }} &>/dev/null; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Create bilingual release notes
run: |
cat << 'EOF' > release_notes.md
## English
${{ steps.changelog_en.outputs.changes }}
---
## 简体中文
${{ steps.changelog_zh.outputs.changes }}
EOF
- name: Create or Update GitHub Release
run: |
TAG="${{ steps.version.outputs.tag }}"
if [ "${{ steps.check_release.outputs.exists }}" = "true" ]; then
echo "Updating existing release $TAG"
gh release edit "$TAG" \
--notes-file release_notes.md
else
echo "Creating new release $TAG"
PRERELEASE_FLAG=""
if [[ "$TAG" == *"alpha"* ]] || [[ "$TAG" == *"beta"* ]] || [[ "$TAG" == *"rc"* ]]; then
PRERELEASE_FLAG="--prerelease"
fi
gh release create "$TAG" \
--title "$TAG" \
--notes-file release_notes.md \
$PRERELEASE_FLAG \
|| echo "Release creation skipped or failed"
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Summary
run: |
echo "## Release Sync Complete" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Tag**: ${{ steps.version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "- **Action**: ${{ steps.check_release.outputs.exists == 'true' && 'Updated' || 'Created' }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "View release: https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY