Skip to content

Commit f16c016

Browse files
committed
ci: release 后自动更新 README 下载链接版本号
1 parent 700ac99 commit f16c016

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,26 @@ jobs:
8181
with:
8282
generate_release_notes: true
8383
files: artifacts/*
84+
85+
update-readme:
86+
needs: release
87+
runs-on: ubuntu-latest
88+
steps:
89+
- uses: actions/checkout@v4
90+
with:
91+
ref: main
92+
- name: Update README version
93+
run: |
94+
NEW_VERSION="${GITHUB_REF_NAME}"
95+
# Extract old version from README download URL pattern
96+
OLD_VERSION=$(grep -oE 'download/v[0-9]+\.[0-9]+\.[0-9]+/' README.md | head -1 | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+')
97+
if [ -z "$OLD_VERSION" ] || [ "$OLD_VERSION" = "$NEW_VERSION" ]; then
98+
echo "No version update needed"
99+
exit 0
100+
fi
101+
sed -i "s|${OLD_VERSION}|${NEW_VERSION}|g" README.md README.zh-CN.md
102+
git config user.name "github-actions[bot]"
103+
git config user.email "github-actions[bot]@users.noreply.github.com"
104+
git add README.md README.zh-CN.md
105+
git commit -m "docs: README 下载链接版本号自动更新为 ${NEW_VERSION}"
106+
git push

0 commit comments

Comments
 (0)