Skip to content

👷 CI: Update project version and bump workflow configuration #46

👷 CI: Update project version and bump workflow configuration

👷 CI: Update project version and bump workflow configuration #46

Workflow file for this run

name: Pro Bump
on:
push:
branches:
- main
permissions:
contents: write
env:
tag: ${{ github.event.head_commit.id }}
jobs:
bump:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: 更新版本号
run: |
# 读取配置文件路径
projectFile=$(find $(pwd) ! -path "*Resources*" -type f -name "*.pbxproj" | head -n 1)
echo "项目文件: $projectFile"
# 显示当前版本号
echo "=== 当前版本号 ==="
grep -n "MARKETING_VERSION" "$projectFile"
# 使用perl一次性更新所有MARKETING_VERSION,将patch版本+1
perl -i -pe '
if (/^(\s*)MARKETING_VERSION = (\d+)\.(\d+)\.(\d+);/) {
$indent = $1;
$major = $2;
$minor = $3;
$patch = $4 + 1;
$_ = "${indent}MARKETING_VERSION = $major.$minor.$patch;\n";
}
' "$projectFile"
# 显示更新后的版本号
echo "=== 更新后的版本号 ==="
grep -n "MARKETING_VERSION" "$projectFile"
git status
- name: 生成标签
run: |
# 读取配置文件路径
projectFile=$(find $(pwd) ! -path "*Resources*" -type f -name "*.pbxproj" | head -n 1)
# 读取主应用版本号(第一个找到的版本号)
version=$(grep -o 'MARKETING_VERSION = [0-9]\+\.[0-9]\+\.[0-9]\+' "$projectFile" | head -n 1 | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
echo "主应用版本号: $version"
echo "tag=v$version" >> $GITHUB_ENV
- name: 打标签并推送到仓库
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: '🎨 Bump a new version'
commit_user_name: GitHub Action
tagging_message: ${{ env.tag }}
sync_dev:
if: github.ref == 'refs/heads/main'
needs:
- bump
runs-on: ubuntu-latest
steps:
- name: 检出 dev 分支
uses: actions/checkout@v3
with:
ref: dev
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: 拉取 main 最新提交
run: git fetch origin main
- name: 合并 main 到 dev
run: |
git config user.name "GitHub Action"
git config user.email "actions@github.com"
git merge --no-edit origin/main || true
- name: 推送 dev 分支
run: git push origin dev