-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (73 loc) · 2.49 KB
/
Copy pathpro-bump.yaml
File metadata and controls
83 lines (73 loc) · 2.49 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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