Skip to content

Instantly share code, notes, and snippets.

@Limon-O-O
Last active February 27, 2017 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Limon-O-O/537daa29476a19202602a41c1a43aaba to your computer and use it in GitHub Desktop.
Save Limon-O-O/537daa29476a19202602a41c1a43aaba to your computer and use it in GitHub Desktop.
Release pod
#!/bin/bash
BGreen='\033[1;32m'
Default='\033[0;m'
podName=""
version=""
podspecFilePath=""
homepage=""
httpsRepo=""
oldVersion=""
confirmed="n"
getPodInfo() {
for file in ./*
do
if test -f $file
then
if [[ $file == *".podspec"* ]]; then
filename=`basename $file`
podName=${filename%.podspec*}
podspecFilePath="./${podName}.podspec"
fi
fi
done
while read line; do
line=${line//[[:blank:]]/}
if [[ $line == *".homepage="* ]]; then
homepage=${line##*='"'}
homepage=${homepage%'"'}
fi
if [[ $line == *".source="* ]]; then
httpsRepo=${line##*git=>'"'}
httpsRepo=${httpsRepo%'"'*}
fi
# 截取旧版本号
if [[ $line == *"s.version"*"="* ]]; then
oldVersion=${line##*=}
oldVersion=${oldVersion#*\"}
oldVersion=${oldVersion%\"}
oldVersion=${oldVersion#*\'}
oldVersion=${oldVersion%\'}
fi
done < $podspecFilePath
}
getVersion() {
read -p "Enter Version: " version
if test -z "$version"; then
getVersion
fi
}
updateVersion() {
# update .podspec file
while read line; do
if [[ $line == *"s.version"*"="* ]]; then
newLine=${line/$oldVersion/$version}
sed -i '' "s#$line#$newLine#" "$podspecFilePath"
fi
done < $podspecFilePath
# update README.md file
while read line; do
if [[ $line == *"pod"*"${oldVersion}"* ]]; then
newLine=${line/$oldVersion/$version}
sed -i '' "s#$line#$newLine#" "./README.md"
fi
if [[ $line == *"github"*"${podName}"*"${oldVersion}"* ]]; then
newLine=${line/$oldVersion/$version}
sed -i '' "s#${line}#${newLine}#" "./README.md"
fi
done < "./README.md"
# update Xcode project
./update_version.sh --version=$version --target=$podName
}
getInfomation() {
getVersion
echo -e "\n${Default}================================================"
echo -e " Pod Name : ${BGreen}${podName}${Default}"
echo -e " Version : ${BGreen}${version}${Default}"
echo -e " HTTPS Repo : ${BGreen}${httpsRepo}${Default}"
echo -e " Home Page URL : ${BGreen}${homepage}${Default}"
echo -e "================================================\n"
}
########### 开始 ###############
getPodInfo
echo -e "\n"
while [ "$confirmed" != "y" -a "$confirmed" != "Y" ]
do
if [ "$confirmed" == "n" -o "$confirmed" == "N" ]; then
getInfomation
fi
read -p "confirm? (y/n):" confirmed
done
updateVersion
git commit -m "[$podName] update version $version"
git push
git tag "${version}"
git push --tags
pod trunk push "${podName}.podspec" --allow-warnings
say "finished"
echo "finished"
@Limon-O-O
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment