Created
June 20, 2023 17:42
-
-
Save oianmol/ef709e26a11ce87fb30721f807f1e7db to your computer and use it in GitHub Desktop.
Build and release ios github actions example
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: Build & Deploy | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build-ios: | |
name: Build iOS and Deploy | |
runs-on: macos-latest | |
steps: | |
- name: Export Release Timestamp | |
run: echo "APP_VERSION=release_$(date +'%Y-%m-%d_%H-%m-%S')" >> $GITHUB_ENV | |
- name: Checkout project | |
uses: actions/checkout@v2 | |
- name: Create Folder for certificates and profiles | |
run: | | |
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles | |
mkdir -p ~/Library/MobileDevice/Certificates/ | |
# decode and save the p12 and provisioning files stored as secrets | |
- name: Get Certificate | |
id: certFileDecode | |
uses: timheuer/[email protected] | |
with: | |
fileName: 'certificate.p12' | |
encodedString: ${{ secrets.SIGNING_CERTIFICATE_P12_DATA }} | |
- name: Copy Certificate | |
run: mv ${{ steps.certFileDecode.outputs.filePath }} ~/Library/MobileDevice/Certificates/certificate.p12 | |
- name: Get Profile | |
id: profFileDecode | |
uses: timheuer/[email protected] | |
with: | |
fileName: 'decoded.mobileprovision' | |
encodedString: ${{ secrets.PROVISIONING_PROFILE_DATA }} | |
- name: Copy Profiles | |
run: mv ${{ steps.profFileDecode.outputs.filePath }} ~/Library/MobileDevice/Provisioning\ Profiles/decoded.mobileprovision | |
- uses: actions/setup-java@v1 | |
with: | |
java-version: '12.x' | |
- uses: subosito/flutter-action@v1 | |
with: | |
channel: 'stable' | |
#install the necessary dependencies | |
- name: Install python and codemagic tools | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.7 | |
- name: Install python dependencies | |
run: python -m pip install codemagic-cli-tools | |
- name: Initialize Keychain with certificate | |
run: | | |
keychain initialize | |
keychain add-certificates --certificate ~/Library/MobileDevice/Certificates/certificate.p12 --certificate-password ${{ secrets.SIGNING_CERTIFICATE_PASSWORD }} | |
- name: Get Dependencies | |
run: | | |
xcode-project use-profiles | |
flutter pub get | |
- name: Build and sign the iOS ipa | |
run: | | |
flutter build ios --release --flavor=prod --no-codesign | |
xcode-project build-ipa --workspace ios/Runner.xcworkspace --scheme prod --config Release-prod | |
- name: Upload binaries | |
uses: actions/upload-artifact@v2 | |
with: | |
name: Artifacts ipa | |
if-no-files-found: warn | |
path: build/ios/ipa/*.ipa | |
- name: Upload app to App Store Connect | |
env: | |
APP_STORE_CONNECT_USERNAME: ${{ secrets.APP_STORE_CONNECT_USERNAME }} | |
APP_STORE_CONNECT_PASSWORD: ${{ secrets.APP_STORE_CONNECT_PASSWORD }} | |
run: | | |
cd build/ios/ipa | |
xcrun altool --upload-app -t ios -f appname.ipa -u "$APP_STORE_CONNECT_USERNAME" -p "$APP_STORE_CONNECT_PASSWORD" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment