-
Notifications
You must be signed in to change notification settings - Fork 23
/
release_pb_app.sh
executable file
·91 lines (63 loc) · 2.28 KB
/
release_pb_app.sh
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
84
85
86
87
88
89
90
91
PROJECT_NAME=${PWD##*/}
APP_NAME="PBApp"
APP_PATH="$APP_NAME/workspace/Podfile"
# LATEST_TAG=$(git tag | xargs -I@ git log --format=format:"%ai @%n" -1 @ | sort | awk '{print $4}' | tail -2 | sed -n '2p')
# LATEST_PREVIOUS_TAG=$(git tag | xargs -I@ git log --format=format:"%ai @%n" -1 @ | sort | awk '{print $4}' | tail -2 | sed -n '1p')
if [ ! -d "$APP_NAME" ]; then
git clone git@gitlab.baidao.com:pb/PBApp.git
fi
cd PBApp
git checkout dev
git pull
cd ..
ORIGIN_POD_VERSION=$(cat $APP_PATH | grep $PROJECT_NAME | grep -o '[0-9]*\.[0-9]*\.[0-9]*')
CURRENT_POD_VERSION=$(cat $PROJECT_NAME.podspec | grep 's.version' | grep -o '[0-9]*\.[0-9]*\.[0-9]*')
CURRENT_POD_URL=$(cat $PROJECT_NAME.podspec | grep 's.homepage' | grep -o "'.*'" | sed "s/'//g")
echo "This current version is $CURRENT_POD_VERSION"
ORIGIN_POD_VALUE=$(cat $APP_PATH | grep $PROJECT_NAME)
NEW_POD_VALUE=" pod '$PROJECT_NAME', '$CURRENT_POD_VERSION'"
echo "ORIGIN_POD_VALUE: $ORIGIN_POD_VALUE"
echo "NEW_POD_VALUE: $NEW_POD_VALUE"
COMMIT_LOG='commit.log'
git log $ORIGIN_POD_VERSION..$CURRENT_POD_VERSION --graph > $COMMIT_LOG
echo "" | cat >> $COMMIT_LOG
echo "The merge request is from $PROJECT_NAME" | cat >> $COMMIT_LOG
cat $COMMIT_LOG
mv $COMMIT_LOG PBApp/workspace/$COMMIT_LOG
if [[ $ORIGIN_POD_VALUE ]]; then
echo "s/$ORIGIN_POD_VALUE/$NEW_POD_VALUE/g"
sed -i "" "s/$ORIGIN_POD_VALUE/$NEW_POD_VALUE/g" $APP_PATH
else
sed -i "" "/target 'PBApp' do/ a\\
$NEW_POD_VALUE
" $APP_PATH
fi
echo "========================================================="
cat $APP_PATH
echo "========================================================="
cd PBApp/workspace
BRANCH_NAME=CIPodfileUpdpateWith$PROJECT_NAME@$CURRENT_POD_VERSION
git checkout -b $BRANCH_NAME
# pod repo update baidao-ios-ytx-pod-specs
# rm Podfile.lock
# if [[ $(which podh) ]]; then
# echo 'podh install'
# podh install
# else
# echo 'pod install'
# pod install
# fi
git config --get user.name
git config --get user.email
git add Podfile
git commit -F $COMMIT_LOG
git remote -v
git push --set-upstream origin $BRANCH_NAME
cd ..
pwd
ls -l
if [[ -f "merge_request.sh" ]]; then
echo "Try to Add merge_request with PBApp"
sh merge_request.sh "CI_Update_Podfile_$PROJECT_NAME@$CURRENT_POD_VERSION" dev "$CURRENT_POD_URL/merge_requests?scope=all&state=merged"
fi
cd ..