1+ name : Reusable Publish Release Workflow
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ tag_name :
7+ description : ' Tag name for the release'
8+ required : true
9+ type : string
10+ repository_name :
11+ description : ' Repository name'
12+ required : true
13+ type : string
14+
15+ # 统一配置权限,调用方无需声明
16+ permissions :
17+ contents : write
18+ pull-requests : write
19+ actions : read
20+ metadata : read
21+ checks : write
22+ issues : write
23+ packages : write
24+
25+ jobs :
26+ publish-release :
27+ runs-on : ubuntu-latest
28+
29+ steps :
30+ - name : Checkout code
31+ uses : actions/checkout@v4
32+ with :
33+ fetch-depth : 0 # 获取所有提交历史,用于生成完整的changelog
34+
35+ - name : Set up Git user
36+ run : |
37+ git config --global user.email "${{ vars.GIT_USER_EMAIL }}"
38+ git config --global user.name "${{ vars.GIT_USER_NAME }}"
39+
40+ - name : " ✏️ Generate release changelog"
41+ uses : heinrichreimer/action-github-changelog-generator@v2.3
42+ with :
43+ token : ${{ secrets.GITHUB_TOKEN }}
44+
45+ - name : Commit CHANGELOG.md
46+ run : |
47+ git add CHANGELOG.md
48+ git commit -m "[修改] 修改更新日志" || echo "No changes to commit"
49+
50+ - name : Change version by tag
51+ uses : AlianBlank/github-action-tag-version@1.1.0
52+ with :
53+ version : ${{ inputs.tag_name }}
54+
55+ - name : Push changes
56+ uses : ad-m/github-push-action@master
57+ with :
58+ force : true
59+ tags : true
60+
61+ - name : Create GitHub Release
62+ uses : actions/create-release@v1
63+ env :
64+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
65+ with :
66+ tag_name : ${{ inputs.tag_name }}
67+ release_name : Release ${{ inputs.tag_name }}
68+ body : |
69+ ## 🎉 Release ${{ inputs.tag_name }}
70+
71+ This release was automatically generated from tag `${{ inputs.tag_name }}`.
72+
73+ ### 📋 Changes
74+ Please check the [CHANGELOG.md](./CHANGELOG.md) for detailed changes.
75+
76+ ### 📦 Repository
77+ Repository: ${{ inputs.repository_name }}
78+ draft : false
79+ prerelease : false
0 commit comments