Last active
February 22, 2018 12:39
-
-
Save michael-martinez/f12e9b73c4e81c7626895ebaf17c21e3 to your computer and use it in GitHub Desktop.
Automatically creates podspec file, tag V1.0.0 and push to your repository.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# To run : | |
# $ chmod +x xcode_podspec.sh | |
# $ /bin/sh xcode_podspec.sh /path/to/project/ | |
echo "========== Pod Spec Start ==========" | |
# define paths | |
projectPath="$1" | |
basename=$(basename $projectPath) | |
podspecFile=$basename".podspec" | |
USER_HOME=$(eval echo ~${SUDO_USER}) | |
githubId=$(git config user.name) | |
githubEmail=$(git config user.email) | |
# Check if folder exists | |
if [ -d "$projectPath" ]; then | |
CMD="cd $projectPath" | |
echo $CMD | |
$CMD | |
# Create podspec | |
if [ ! -f $(basename $projectPath).podspec ]; then | |
CMD="pod spec create $(basename $projectPath)" | |
echo $CMD | |
$CMD | |
read -p "Enter homepage (website) : " homepage | |
read -p "Enter summary: " summary | |
read -p "Enter description: " description | |
read -p "Enter target: " target | |
read -p "Enter swift_version: " swift_version | |
githubUrl="https://github.com/"$githubId"/"$basename".git" | |
echo "Pod::Spec.new do |s|" > $podspecFile | |
echo " s.name = '$basename'" >> $podspecFile | |
echo ' s.version = "1.0.0"' >> $podspecFile | |
echo " s.summary = '$summary'" >> $podspecFile | |
echo " s.description = '$description'" >> $podspecFile | |
echo ' s.author = { "'$githubId'" => "'$githubEmail'" }' >> $podspecFile | |
echo ' s.homepage = "'$homepage'"' >> $podspecFile | |
echo ' s.license = "MIT"' >> $podspecFile | |
echo ' s.platform = :ios, "'$target'"' >> $podspecFile | |
echo ' s.source = { :git => "'$githubUrl'", :tag => "1.0.0" }' >> $podspecFile | |
echo ' s.source_files = "'$basename'", "'$basename'/**/*.{h,m,swift}"' >> $podspecFile | |
echo " s.resources = ['"$basename"/**/*.{mp3,m4a,png,mp4,avi,mov,gif,jpg,psd,wav,mkv,flv,m4v,mpg,mp2,mpeg,pdf}']" >> $podspecFile | |
echo " s.swift_version = '"$swift_version"'" >> $podspecFile | |
echo "end" >> $podspecFile | |
else | |
echo "Pod Spec already there !" | |
fi | |
# Publish pod to github | |
if [ ! -f .git ]; then | |
git init | |
fi | |
echo "Updating README.md ..." | |
if [! -f README.md ]; then | |
echo >> README.md | |
echo $summary >> README.md | |
echo >> README.md | |
echo $description >> README.md | |
fi | |
CMD="git add ." | |
echo $CMD | |
$CMD | |
CMD='git commit -m "Deploy pod"' | |
echo $CMD | |
$CMD | |
CMD="git remote add origin $githubUrl" | |
echo $CMD | |
$CMD | |
CMD="git push" | |
echo $CMD | |
$CMD | |
CMD="git tag 1.0.0" | |
echo $CMD | |
$CMD | |
CMD="git push --tags" | |
echo $CMD | |
$CMD | |
CMD="pod spec lint" | |
echo $CMD | |
$CMD | |
else | |
echo "Project Path not found !" | |
fi | |
echo "========== Have a nice day :) ==========" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment