-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Refactoring code. 重构VERSION 版本号规则
� Conflicts: � VERSION
- Loading branch information
Showing
2 changed files
with
21 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
10 | ||
v2024001 |