Skip to content

💚 Fixing CI Build. #11

💚 Fixing CI Build.

💚 Fixing CI Build. #11

name: Update Version
on:
push:
branches:
- master # 监听主分支代码提交事件
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Update version
run: |
# 读取当前版本号
current_version=$(cat VERSION)
# 提取版本号中的年份部分和当年版本序号
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
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m "Update version to $new_version" -a
git push origin master
sync-repo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: yesolutions/mirror-action@master
with:
REMOTE: 'https://git.pig4cloud.com/pig/CGTM.git'
GIT_USERNAME: lengleng
GIT_PASSWORD: ${{ secrets.GIT_GOGS_PASSWORD }}