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
44 changes: 18 additions & 26 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

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

- name: Checkout
uses: actions/checkout@v2
Expand All @@ -36,7 +35,7 @@ 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" -k $KEYCHAIN_PATH -T /usr/bin/codesign;
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH

chmod +x ios/install_dist_profile.sh && ./ios/install_dist_profile.sh
Expand All @@ -45,28 +44,21 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true

- name: Install dependencies
run: |
flutter pub get

- name: Building ipa
run: |
file='VERSION'
fileData=`cat $file`
IFS='.'
read -a versionValue <<< "$fileData"
buildNumber=$(( ${versionValue[0]} * 1000000 + ${versionValue[1]} * 10000 + ${{ github.run_number }} ))
IFS=''
buildName="${versionValue[0]}.${versionValue[1]}.${{ github.run_number }}"
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
# - name: Building ipa
# run: |
# file='VERSION'
# fileData=`cat $file`
# IFS='.'
# read -a versionValue <<< "$fileData"
# buildNumber=$(( ${versionValue[0]} * 1000000 + ${versionValue[1]} * 10000 + ${{ github.run_number }} ))
# IFS=''
# buildName="${versionValue[0]}.${versionValue[1]}.${{ github.run_number }}"
# 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
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
11 changes: 10 additions & 1 deletion ios/install_dist_profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@
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"


if [ -f "$HOME/Library/MobileDevice/Provisioning Profiles/${DIST_PROVISION_UUID}.mobileprovision" ]; then
grep -a -A 1 'UUID' "$HOME/Library/MobileDevice/Provisioning Profiles/${DIST_PROVISION_UUID}.mobileprovision"
echo "Provisioning profile copied successfully."
else
echo "Error: Provisioning profile copy failed."
fi

Copy link

Choose a reason for hiding this comment

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

When cleaning up provisioning profiles, it's safer to specify the glob pattern more explicitly to avoid unintended deletions, especially in scripts that might be run in different environments.

- rm -fr *.mobileprovision
+ rm -fr ./*.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
rm -fr ./*.mobileprovision

# clean
rm -fr *.mobileprovision
Copy link

Choose a reason for hiding this comment

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

When cleaning up provisioning profiles, it's safer to specify the glob pattern more explicitly to avoid unintended deletions, especially in scripts that might be run in different environments.

- rm -fr *.mobileprovision
+ rm -fr ./*.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
rm -fr *.mobileprovision
rm -fr ./*.mobileprovision

Loading