iOS 手動作一個自動打包部署神器

以前使用的fastlane添加pgyer自動打包的,最近發現更新老是有問題,因此產生了本身shell作一個的想法。雖然代碼比較少,可是很實用。ios

  • 打包
  • 導出ipa
  • 上傳pgyer

打包自動上傳pgyer

#!/bin/bash 
#xcodebuild archive -project 'test.xcodeproj' -configuration 'Debug' -scheme 'BLTSZY' -archivePath './app.xcarchive' LIBRARY_SEARCH_PATHS="./Pods/../build/**  ./BLTSZY/**"
proName='your project name'
proURL="your project path"#like /Users/Jerry/Desktop/ios_afu
api_key=''#pgyer api_key
configuration='Debug' #Release 
autoPlus(){
path=${proURL}/${proName}/${proName}/Info.plist
number=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${path}")
BundleVersion=$(( $number + 1 ))
/usr/libexec/PlistBuddy -c "Set CFBundleVersion $BundleVersion" "${path}"
}
#打包
arch(){
    echo '開始編譯Pods'
    xcodebuild -project Pods/Pods.xcodeproj build
    echo '開始編譯project'

xcodebuild -archivePath "./build/${proName}.xcarchive" -workspace $proName.xcworkspace -sdk iphoneos -scheme $proName -configuration $configuration archive
autoPlus
}
#導出ipa
exportIPA(){
    echo '開始導出ipa'
    xcodebuild -exportArchive -archivePath "./build/${proName}.xcarchive" -exportPath './app' -exportOptionsPlist './ExportOptions.plist'
}
#上傳ipa到蒲公英
upload(){
if [ -e "${proURL}/app/${proName}.ipa" ]
then
    echo '開始上傳ipa/apk到蒲公英'
    curl -F "file=@${proURL}/app/${proName}.ipa" -F "_api_key=${api_key}" 'http://www.pgyer.com/apiv2/app/upload'
else
    echo "在目錄:${proURL}/app/${proName}.ipa 不存在"
fi
}
startarch(){
    arch
    if (($? == 0))
    then
        echo 'archive success🍺'
        startExportIPA
    else
        echo 'archive faild❌'
    fi
}
startExportIPA(){
    exportIPA
    if(($? == 0))
    then
        echo 'exportIPA success🍺🍺'
        startUPLoadIPA
    else
        echo 'exportIPA faild ❌'
    fi
}
startUPLoadIPA(){
    upload
    if(($? == 0))
    then
        echo 'uploadIPA success'
    else
        echo 'uploadIPA faild ❌'
    fi
}


if (($# == 0))
#then
# startarch
#elif (($# == 1))
then
        while :
        do
        echo '🍺🍺🍺***********************🍺🍺🍺'
        echo  "輸入 1 到 4 之間的數字:"
        echo  "輸入 1:從編譯打包開始至結束"
        echo  "輸入 2:從導出IPA開始至結束"
        echo  "輸入 3:從上傳ipa開始至結束"
        echo  "輸入 4:退出"
        read a
        case $a in
            1)startarch
            break;;
            2)startExportIPA
            break;;
            3)startUPLoadIPA
            break;;
            4) break;;
        esac
        done
fi

複製代碼

將該文件和plis拖到project目錄下,而後配置 plis文件:git

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>compileBitcode</key>
	<false/>
	<key>method</key>
	<string>ad-hoc</string>
	<key>provisioningProfiles</key>
	<dict>
		<key>your bundle id</key>
		<string>your .mobileprovsion</string>
	</dict>
	<key>signingCertificate</key>
	<string>iPhone Distribution</string>
	<key>signingStyle</key>
	<string>manual</string>
	<key>stripSwiftSymbols</key>
	<true/>
	<key>teamID</key>
	<string>your_team_id</string>
	<key>thinning</key>
	<string>&lt;none&gt;</string>
</dict>
</plist>
複製代碼

下載setup.sh拖到項目文件夾內,而後 運行./setup.sh,便可完成上傳到pgyer網站。 具體的配置屬性見源碼下載頁面。 查看源碼github

相關文章
相關標籤/搜索