-
Notifications
You must be signed in to change notification settings - Fork 26
56 lines (48 loc) · 1.66 KB
/
release.yml
File metadata and controls
56 lines (48 loc) · 1.66 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
name: Create Release
on:
push:
tags:
- 'v*' # 当推送 v 开头的 tag 时触发(如 v2.0.0)
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Update README version badge
run: |
VERSION=${{ steps.get_version.outputs.version }}
sed -i "s/version-[0-9.]*-green/version-$VERSION-green/g" README.md
echo "Updated README.md with version $VERSION"
- name: Commit and push version update
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add README.md
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "chore: update version badge to ${{ steps.get_version.outputs.version }}"
git push origin HEAD:${{ github.event.repository.default_branch }}
echo "Version badge updated and pushed"
fi
- name: Create Release
uses: softprops/action-gh-release@v1
with: # 本项目直接脚本文件即可,不需要build
files: |
courseGrabber.js
generate_release_notes: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}