当前位置:网站首页>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
边栏推荐
- Linux modify MySQL database password
- leetcode-829. 连续整数求和(数论)
- Yuan prospect and four track of the universe
- 【Elastic-Job源码分析】——作业监听器
- mysql启动报错The server quit without updating PID file几种解决办法
- Common JVM interview questions and answers
- MySQL面试题大全(陆续更新)
- Memcached :安装
- How MySQL - depots table?A look at will understand
- gin框架学习-GORM框架进阶之CRUD接口(数据库增删改查操作)
猜你喜欢
For penetration testing methods where the output point is a timestamp (take Oracle database as an example)
[Cloud Native] What should I do if SQL (and stored procedures) run too slowly?
常见JVM面试题及答案整理
leetcode-每日一题873. 最长的斐波那契子序列的长度(哈希和二分)
小米手机短信定位服务激活失败
CMOS管原理,及其在推挽电路中的应用
继承、Super,重写、抽象类、抽象方法 1(第七天)
Fragmented NFT (Fractional NFT)
gin框架学习-Casbin入门指南(ACL、RBAC、域内RBAC模型)
The latest MySql installation teaching, very detailed
随机推荐
Regular Expression Basics
DeFi Token in the project management
gin框架学习-Casbin进阶之策略管理API使用方法
leetcode-每日一题剑指 Offer II 041. 滑动窗口的平均值(队列模拟)
Linux中mysql密码修改方法(亲测可用)
【windows】--- SQL Server 2008 超详细安装教程
Year-end summary - the years are quiet~
阿里云中mysql数据库被攻击了,最终数据找回来了
Detailed explanation of pointers in C language
What is an EVM Compatible Chain?
【云原生】微服务Nacos的简单介绍与使用
著名网站msdn.itellyou.cn原理分析
Redis:简单实用
leetcode-1833. 雪糕的最大数量(排序+贪心)
【JVM加载】---类加载机制
[swagger close] The production environment closes the swagger method
小米手机短信定位服务激活失败
Hyper-V新建虚拟机注意事项
场效应管 | N-mos内部结构详解
05 【绑定样式 条件渲染 列表渲染】