forked from su-kaka/gcli2api
-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (43 loc) · 1.35 KB
/
update-version.yml
File metadata and controls
51 lines (43 loc) · 1.35 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
name: Update Version File
on:
push:
branches:
- master
- main
jobs:
update-version:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update version.txt
run: |
# 获取最新commit信息
FULL_HASH=$(git log -1 --format=%H)
SHORT_HASH=$(git log -1 --format=%h)
MESSAGE=$(git log -1 --format=%s)
DATE=$(git log -1 --format=%ci)
# 写入version.txt
echo "full_hash=$FULL_HASH" > version.txt
echo "short_hash=$SHORT_HASH" >> version.txt
echo "message=$MESSAGE" >> version.txt
echo "date=$DATE" >> version.txt
echo "Version file updated:"
cat version.txt
- name: Commit version.txt if changed
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# 检查是否有变化
if git diff --quiet version.txt; then
echo "No changes to version.txt"
else
git add version.txt
git commit -m "chore: update version.txt [skip ci]"
git push
fi