Skip to content

Commit c3d63c8

Browse files
chore: 添加 release 脚本
1 parent 1173a62 commit c3d63c8

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Generate changelog
18+
id: changelog
19+
run: |
20+
PREV_TAG=$(git tag --sort=-version:refname | head -2 | tail -1)
21+
if [ "$PREV_TAG" = "$GITHUB_REF_NAME" ]; then
22+
PREV_TAG=""
23+
fi
24+
25+
if [ -n "$PREV_TAG" ]; then
26+
COMMITS=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s (%h)" --no-merges)
27+
else
28+
COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges -20)
29+
fi
30+
31+
{
32+
echo "commits<<EOF"
33+
echo "$COMMITS"
34+
echo "EOF"
35+
} >> "$GITHUB_OUTPUT"
36+
37+
- name: Create GitHub Release
38+
uses: softprops/action-gh-release@v2
39+
with:
40+
name: ${{ github.ref_name }}
41+
body: |
42+
## What's Changed
43+
44+
${{ steps.changelog.outputs.commits }}
45+
46+
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.ref_name }}^...${{ github.ref_name }}
47+
draft: false
48+
prerelease: ${{ contains(github.ref_name, 'rc') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'alpha') }}

0 commit comments

Comments
 (0)