当前位置:网站首页>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
边栏推荐
- Xiaobai learns reptiles - introduction to reptiles
- [JVM Loading]---Class Loading Mechanism
- MySQL-如何分库分表?一看就懂
- 著名网站msdn.itellyou.cn原理分析
- About integrating superset into your own project
- [uiautomation] Get WeChat friend list (stored in txt)
- MySQL分页查询的5种方法
- Error: Cannot find module ‘D:\Application\nodejs\node_modules\npm\bin\npm-cli.js‘
- 常见JVM面试题及答案整理
- 【uiautomation】微信好友列表获取(存储到txt中)
猜你喜欢
随机推荐
Digital twins will be an important way to enter the "metaverse"
gin框架学习-Casbin入门指南(ACL、RBAC、域内RBAC模型)
Take you to understand the MySQL isolation level, what happens when two transactions operate on the same row of data at the same time?
DeFi 项目中的治理Token
著名网站msdn.itellyou.cn原理分析
Redis:简单实用
DeFi Token in the project management
2021 Mianjing - Embrace Change
[Cloud Native] What should I do if SQL (and stored procedures) run too slowly?
Regular Expression Basics
Build DVWA with phpstudy
NFT:数字所有权的核心
js中的break与continue退出
元宇宙的前景及四大赛道
MySQL高级语句(一)
对于输出点是时间戳的渗透测试方法(以Oracle数据库为例)
C语言 | 获取字符串里逗号间隔的内容
PHP中abstract(抽象)、final(最终)和static(静态)原理与用法
Powershell中UTF-8环境中文乱码解决办法
5 methods of MySQL paging query









