Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ios CD/CD #87

Closed
wants to merge 15 commits into from
32 changes: 17 additions & 15 deletions .github/workflows/ios_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
name: iOS build

on:
push:
branches:
- main
workflow_dispatch:
on: push

jobs:
ios_deploy_testflight:
runs-on: macos-latest
runs-on: macos-14

steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.2'

- name: Checkout
uses: actions/checkout@v2
Expand All @@ -36,23 +35,32 @@ jobs:
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH

# import certificate to keychain
security import $CERTIFICATE_PATH -k $KEYCHAIN_PATH -P "$P12_PASSWORD" -T usr/bin/codesign
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH

security find-identity
security list-keychain -d user

chmod +x ios/install_dist_profile.sh && ./ios/install_dist_profile.sh

- name: Set up Flutter SDK
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true

- name: Install dependencies
run: |
flutter pub get

- name: Building ipa
run: |
security find-identity
security list-keychain -d user

/usr/bin/xcodebuild -version

flutter --version
file='VERSION'
fileData=`cat $file`
IFS='.'
Expand All @@ -63,10 +71,4 @@ jobs:
echo "Uploading build $buildName"
flutter build ipa --build-number=$buildNumber --build-name=$buildName --export-options-plist=ios/Runner/ExportOptions.plist
echo "Uploading app to iTC..."
xcrun altool --upload-app -t ios -f build/ios/ipa/*.ipa -u $ITC_USER_NAME -p $ITC_USER_PASSWORD

- name: Clean up keychain and provisioning profile
if: ${{ always() }}
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.mobileprovision
xcrun altool --upload-app -t ios -f build/ios/ipa/*.ipa -u $ITC_USER_NAME -p $ITC_USER_PASSWORD
2 changes: 1 addition & 1 deletion ios/Runner/ExportOptions.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>provisioningProfiles</key>
<dict>
<key>com.canopas.projectunity</key>
<string>205d1b89-17ca-49a3-bc88-1b79ea02204f</string>
<string>c0babb80-a073-45d8-aefa-4021ef3fdb9b</string>
</dict>
<key>signingCertificate</key>
<string>1EDB213DC565912BC6BC866ADEBF192575C633DC</string>
Expand Down
4 changes: 3 additions & 1 deletion ios/install_dist_profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
DIST_PROFILE_FILE=${DIST_PROVISION_UUID}.mobileprovision

# Recreate the certificate from the secure environment variable
echo $DIST_PROVISION | base64 --decode > $DIST_PROFILE_FILE
echo $BUILD_PROVISION_PROFILE_BASE64 | base64 --decode > $DIST_PROFILE_FILE
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command uses an environment variable without double quotes. This could lead to globbing and word splitting issues.

- echo $BUILD_PROVISION_PROFILE_BASE64 | base64 --decode > $DIST_PROFILE_FILE
+ echo "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode > "$DIST_PROFILE_FILE"

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
echo $BUILD_PROVISION_PROFILE_BASE64 | base64 --decode > $DIST_PROFILE_FILE
echo "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode > "$DIST_PROFILE_FILE"


mkdir -p "$HOME/Library/MobileDevice/Provisioning Profiles"

# copy where Xcode can find it
cp ${DIST_PROFILE_FILE} "$HOME/Library/MobileDevice/Provisioning Profiles/${DIST_PROVISION_UUID}.mobileprovision"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cp command should use double quotes around variables to prevent globbing and word splitting.

- cp ${DIST_PROFILE_FILE} "$HOME/Library/MobileDevice/Provisioning Profiles/${DIST_PROVISION_UUID}.mobileprovision"
+ cp "${DIST_PROFILE_FILE}" "$HOME/Library/MobileDevice/Provisioning Profiles/${DIST_PROVISION_UUID}.mobileprovision"

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
cp ${DIST_PROFILE_FILE} "$HOME/Library/MobileDevice/Provisioning Profiles/${DIST_PROVISION_UUID}.mobileprovision"
cp "${DIST_PROFILE_FILE}" "$HOME/Library/MobileDevice/Provisioning Profiles/${DIST_PROVISION_UUID}.mobileprovision"

Expand Down
Loading