当前位置:网站首页>podspec自动化升级脚本
podspec自动化升级脚本
2022-07-31 05:15:00 【迷曳】
#! /bin/sh
echo "\n ****** begin ****** \n"
# 获取到的文件路径
file_path=""
file_name=""
# 文件后缀名
file_extension="podspec"
# 文件夹路径,pwd表示当前文件夹
directory="$(pwd)"
# 参数1: 路径;参数2: 文件后缀名
function getFileAtDirectory(){
for element in `ls $1`
do
dir_or_file=$1"/"$element
# echo "$dir_or_file"
if [ -d $dir_or_file ]
then
getFileAtDirectory $dir_or_file
else
file_extension=${dir_or_file##*.}
if [[ $file_extension == $2 ]]; then
echo "$dir_or_file 是 $2 文件"
file_path=$dir_or_file
file_name=$element
fi
fi
done
}
getFileAtDirectory $directory $file_extension
echo "\n file_path: ${file_path}"
echo "\n file_name: ${file_name}"
echo "\n ---- 读取podspec文件内容 begin ---- \n"
# 定义pod文件名称
pod_file_name=${file_name}
# 查找 podspec 的版本
search_str="s.version"
# 读取podspec的版本
podspec_version=""
pod_spec_version_new=""
#定义了要读取文件的路径
my_file="${pod_file_name}"
while read my_line
do
#输出读到的每一行的结果
# echo $my_line
# 查找到包含的内容,正则表达式获取以 ${search_str} 开头的内容
result=$(echo ${my_line} | grep "^${search_str}")
if [[ "$result" != "" ]]
then
echo "\n ${my_line} 包含 ${search_str}"
# 分割字符串,是变量名称,不是变量的值; 前面的空格表示分割的字符,后面的空格不可省略
array=(${result// / })
# 数组长度
count=${#array[@]}
# 获取最后一个元素内容
version=${array[count - 1]}
# 去掉 '
version=${version//\'/}
podspec_version=$version
#else
# echo "\n ${my_line} 不包含 ${search_str}"
fi
done < $my_file
echo "\n podspec_version: ${podspec_version}"
pod_spec_name=${file_name}
pod_spec_version=${podspec_version}
echo "\n ---- 版本号自增 ---- \n"
increment_version ()
{
declare -a part=( ${1//\./ } )
declare new
declare -i carry=1
CNTR=${#part[@]}-1
len=${#part[CNTR]}
new=$((part[CNTR]+carry))
part[CNTR]=${new}
new="${part[*]}"
pod_spec_version_new=${new// /.}
}
increment_version $pod_spec_version
echo "\n podspec_version_new: ${pod_spec_version_new}"
LineNumber=`grep -nE 's.version.*=' ${pod_spec_name} | cut -d : -f1`
sed -i "" "${LineNumber}s/${podspec_version}/${pod_spec_version_new}/g" ${pod_spec_name}
echo "\n ---- pod install ---- \n"
cd Example
pod install
# 回到上级目录
cd ..
echo "\n ------ 执行 git 本地提交代码操作 ------ \n"
# git 操作
git add .
git status
git commit -m ${pod_spec_version_new}
# git推送到远端
git tag ${pod_spec_version_new}
git push origin master --tags
cd ~/.cocoapods/repos/BLRepos
git pull origin master
cd -
echo "\n ------ 推送 ${pod_spec_name} 到远端------ \n"
pod repo push BLRepos ${pod_spec_name} --verbose --allow-warnings --use-libraries
边栏推荐
- leetcode-每日一题1217. 玩筹码(贪心+位运算)
- 一文速学-玩转MySQL获取时间、格式转换各类操作方法详解
- 著名网站msdn.itellyou.cn原理分析
- 对js的数组的理解
- MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案
- this指向问题
- Common JVM interview questions and answers
- Yuan prospect and four track of the universe
- 数字取证autopsy工具用法
- leetcode-438. 找到字符串中所有字母异位词(滑动窗口)
猜你喜欢
Error: Cannot find module ‘D:\Application\nodejs\node_modules\npm\bin\npm-cli.js‘
On the side of Ali, tell me what are the application scenarios of message middleware you know?
Digital twins will be an important way to enter the "metaverse"
Powershell中UTF-8环境中文乱码解决办法
vulhub靶场学习日记hackme1
leetcode-每日一题565. 数组嵌套(标记图和并查集)
Linux修改MySQL数据库密码
数字孪生将成为进入“元宇宙”一项重要的途径
vulhub靶场学习日记xxe-lab
NFTs: The Heart of Digital Ownership
随机推荐
Access数据库的查询
Common JVM interview questions and answers
vulhub靶场学习日记hackme1
[Elastic-Job] Overview of Distributed Scheduling Tasks
Detailed explanation of pointers in C language
Fragmented NFT (Fractional NFT)
2021面经-拥抱变化
C language tutorial (2) - printf and data types that come with c
MySQL高级SQL语句(二)
Hyper-V新建虚拟机注意事项
gin框架学习-JWT认证
The server time zone value ‘й‘ is unrecognized or represents more than one time zone
this指向问题
工件SSMwar exploded 部署工件时出错。请参阅服务器日志了解详细信息
什么是EVM兼容链?
Several solutions for mysql startup error The server quit without updating PID file
代码执行漏洞
leetcode-每日一题1252. 奇数值单元格的数目(模拟优化)
leetcode-1833. 雪糕的最大数量(排序+贪心)
win11中利用IIS10搭建asp网站