Skip to content

Commit

Permalink
♻️ Refactoring code. 重构VERSION 版本号规则
Browse files Browse the repository at this point in the history
� Conflicts:
�	VERSION
  • Loading branch information
lltx committed Jul 13, 2024
1 parent 25d2bb7 commit 3661276
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,24 @@ jobs:
# 读取当前版本号
current_version=$(cat VERSION)
# 将版本号加1
new_version=$((current_version + 1))
# 提取版本号中的年份部分和当年版本序号
version_year=${current_version:1:4}
version_number=${current_version:5:3}
# 获取当前年份
current_year=$(date +'%Y')
# 判断版本号年份是否是当前年份
if [ "$version_year" = "$current_year" ]; then
# 当年版本号加1
new_version_number=$(printf "%03d" $((10#$version_number + 1)))
else
# 如果不是当前年份,则重置为001
new_version_number="001"
fi
# 生成新的版本号
new_version="V${current_year}${new_version_number}"
# 更新版本号到文件
echo $new_version > VERSION
Expand All @@ -28,5 +44,5 @@ jobs:
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m "Update version" -a
git push origin master
git commit -m "Update version to $new_version" -a
git push origin master
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10
v2024001

0 comments on commit 3661276

Please sign in to comment.