Update README.md #169
This file contains 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
name: Deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: macos-13 | |
env: | |
APP_STORE_APP_ID: ${{ secrets.APP_STORE_APP_ID }} | |
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }} | |
APP_STORE_CONNECT_PRIVATE_KEY: ${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY }} | |
APP_STORE_CONNECT_KEY_IDENTIFIER: ${{ secrets.APP_STORE_CONNECT_KEY_IDENTIFIER }} | |
DIST_CERTIFICATE: ${{ secrets.DIST_CERTIFICATE }} | |
DIST_CERTIFICATE_PASSWORD: ${{ secrets.DIST_CERTIFICATE_PASSWORD }} | |
DIST_PROFILE: ${{ secrets.DIST_PROFILE }} | |
DIST_PROFILE_UUID: ${{ secrets.DIST_PROFILE_UUID }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Cancel Previous Runs | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ github.token }} | |
- name: Set Xcode Version | |
run: | | |
sudo xcode-select -switch /Applications/Xcode_15.2.app | |
- name: Display Xcode Version | |
run: /usr/bin/xcodebuild -version | |
- name: Cache CocoaPods | |
uses: actions/cache@v2 | |
with: | |
path: | | |
Pods | |
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pods- | |
- name: Install CocoaPods | |
run: | | |
if [ -f "Podfile.lock" ] && [ -f "${{ runner.workspace }}/Podfile.lock" ] && cmp -s Podfile.lock "${{ runner.workspace }}/Podfile.lock"; then | |
echo "Podfile.lock unchanged. Skipping pod installs." | |
else | |
gem install cocoapods | |
pod install --repo-update | |
fi | |
- name: Run SwiftLint | |
run: | | |
if git diff --name-only ${{ github.sha }} | grep -q '\.swift$'; then | |
Pods/SwiftLint/swiftlint Splito | |
else | |
echo "No Swift files changed. Skipping SwiftLint." | |
fi | |
- name: Install Codemagic CLI tools | |
run: pip install codemagic-cli-tools | |
- name: Set up keychain | |
run: keychain initialize | |
- name: Set up Provisioning profiles | |
run: | | |
PROFILES_HOME="$HOME/Library/MobileDevice/Provisioning Profiles" | |
mkdir -p "$PROFILES_HOME" | |
PROFILE_PATH="$(mktemp "$PROFILES_HOME"/${DIST_PROFILE_UUID}.mobileprovision)" | |
echo ${DIST_PROFILE} | base64 --decode > "$PROFILE_PATH" | |
- name: Set up signing certificate | |
run: | | |
echo $DIST_CERTIFICATE | base64 --decode > /tmp/certificate.p12 | |
keychain add-certificates --certificate /tmp/certificate.p12 --certificate-password $DIST_CERTIFICATE_PASSWORD | |
- name: Set up code signing settings on the Xcode project | |
run: xcode-project use-profiles | |
- name: Retrieve secrets and decode plist files | |
env: | |
SECRETS_CONFIG_FILE: ${{ secrets.SECRETS_CONFIG_FILE_BASE64 }} | |
EXPORT_OPTIONS_PLIST: ${{ secrets.EXPORT_OPTIONS_PLIST_BASE64 }} | |
GOOGLE_SERVICE_INFO_PLIST: ${{ secrets.GOOGLE_SERVICE_INFO_PLIST_BASE64 }} | |
run: | | |
echo "$SECRETS_CONFIG_FILE" | base64 --decode > Splito/Secrets.xcconfig | |
echo "$EXPORT_OPTIONS_PLIST" | base64 --decode > ExportOptions.plist | |
echo "$GOOGLE_SERVICE_INFO_PLIST" | base64 --decode > Splito/Plist/GoogleService-Info.plist | |
- name: Upload app to App Store Connect | |
env: | |
GOOGLE_REVERSE_CLIENT_ID: ${{ secrets.GOOGLE_REVERSE_CLIENT_ID }} | |
run: | | |
# Get Build Version | |
file='Splito/VERSION' | |
fileData=`cat $file` | |
IFS='.' | |
read -a versionValue <<< "$fileData" | |
buildNumber=$(expr `expr ${versionValue[0]} \* 1000000` + `expr ${versionValue[1]} \* 10000` + ${{ github.run_number }}) | |
IFS='' | |
buildName="${versionValue[0]}.${versionValue[1]}.${{ github.run_number }}" | |
echo "Uploading build $buildName" | |
# Update Version Information in Info.plist | |
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $buildName" Splito/Plist/Info.plist | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" Splito/Plist/Info.plist | |
# Update CFBundleURLSchemes with Reverse Client ID | |
/usr/libexec/PlistBuddy -c "Set :CFBundleURLTypes:0:CFBundleURLSchemes:0 $GOOGLE_REVERSE_CLIENT_ID" Splito/Plist/Info.plist | |
# Build and Archive Project | |
ARCHIVE_PATH=$RUNNER_TEMP/Splito.xcarchive | |
xcodebuild clean archive -workspace Splito.xcworkspace -scheme "Splito" -archivePath "$ARCHIVE_PATH" -destination generic/platform=iOS | xcpretty --color | |
# Export Archive | |
EXPORT_PATH=$RUNNER_TEMP/build | |
xcodebuild -exportArchive -archivePath "$ARCHIVE_PATH" -exportOptionsPlist "$(pwd)/ExportOptions.plist" -exportPath "$EXPORT_PATH" | xcpretty --color | |
# Upload to App Store Connect | |
APP_FILE=$(find "$EXPORT_PATH" -name "*.ipa") | |
app-store-connect publish --path "$APP_FILE" |