From 7588a1e0e2a039ee95507eed9aa9ac36b06f7711 Mon Sep 17 00:00:00 2001 From: Yawen Li Date: Thu, 25 Jul 2024 16:02:54 -0300 Subject: [PATCH] add ios and android build files --- .github/workflows/build-android-app.yml | 46 +++++++++++ .github/workflows/build-ios-app.yml | 105 ++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 .github/workflows/build-android-app.yml create mode 100644 .github/workflows/build-ios-app.yml diff --git a/.github/workflows/build-android-app.yml b/.github/workflows/build-android-app.yml new file mode 100644 index 0000000..bcdafd7 --- /dev/null +++ b/.github/workflows/build-android-app.yml @@ -0,0 +1,46 @@ +name: "Build Android app" + +on: + push: + branches: + - main + +jobs: + build: + runs-on: macos-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Java + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: adopt + cache: gradle + + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: "18" + cache: "yarn" + + - name: Run Yarn Install + run: | + npm i -g corepack + yarn install + + - name: Build application + run: | + cd android + ./gradlew assembleRelease + + - name: Upload application + uses: actions/upload-artifact@v2 + with: + name: app + path: android/app/build/outputs/apk/release/app-release.apk + retention-days: 3 diff --git a/.github/workflows/build-ios-app.yml b/.github/workflows/build-ios-app.yml new file mode 100644 index 0000000..3928e98 --- /dev/null +++ b/.github/workflows/build-ios-app.yml @@ -0,0 +1,105 @@ +name: "Build iOS app" + +on: + push: + branches: + - main + +jobs: + build_with_signing: + runs-on: macos-latest + steps: + - name: check Xcode version + run: /usr/bin/xcodebuild -version + - name: checkout repository + uses: actions/checkout@v3 + - name: Debug Workflow Variables + run: | + echo "CERTIFICATE_PATH: $CERTIFICATE_PATH" + echo "PP_PATH: $PP_PATH" + echo "KEYCHAIN_PATH: $KEYCHAIN_PATH" + echo "P12_PASSWORD: $P12_PASSWORD" + - name: Install the Apple certificate and provisioning profile + env: + BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} + P12_PASSWORD: ${{ secrets.P12_PASSWORD }} + PROVISION_PROFILES_BASE64: ${{ secrets.PROVISION_PROFILES_BASE64 }} + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} + run: | + CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 + PP_ARCHIVE=$RUNNER_TEMP/mobile_pp.tgz + KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db + + echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH + echo -n "$PROVISION_PROFILES_BASE64" | base64 --decode -o $PP_ARCHIVE + + security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + security set-keychain-settings -lut 21600 $KEYCHAIN_PATH + security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + + echo "P12_PASSWORD: $P12_PASSWORD" + security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH + security list-keychain -d user -s $KEYCHAIN_PATH + + mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles + tar xzvf $PP_ARCHIVE -C $RUNNER_TEMP + for PROVISION in `ls $RUNNER_TEMP/*.mobileprovision` + do + UUID=`/usr/libexec/PlistBuddy -c 'Print :UUID' /dev/stdin <<< $(security cms -D -i $PROVISION)` + cp $PROVISION ~/Library/MobileDevice/Provisioning\ Profiles/$UUID.mobileprovision + done + + security find-identity -v -p codesigning + ls -l ~/Library/MobileDevice/Provisioning\ Profiles + + - uses: actions/setup-node@v3 + with: + node-version: "18" + cache: "yarn" + + - name: Clean workspace + run: | + git clean -ffdx + npm cache clean --force + + - name: Clean Xcode Build + run: | + cd ios + xcodebuild clean -workspace your_app.xcworkspace -scheme your_app + + - name: install yarn dependencies + run: | + cd ios + yarn install + + - name: install Cocoapod dependencies + run: | + cd ios + pod repo update + pod install + + - name: build archive + run: | + cd ios + xcodebuild -workspace your_app.xcworkspace \ + -scheme "your_app" \ + -sdk iphoneos \ + -configuration Release \ + -destination generic/platform=iOS \ + -archivePath $RUNNER_TEMP/your_app.xcarchive \ + archive + + - name: export ipa + env: + EXPORT_OPTIONS_PLIST: ${{ secrets.EXPORT_OPTIONS_PLIST }} + run: | + EXPORT_OPTS_PATH=$RUNNER_TEMP/ExportOptions.plist + echo -n "$EXPORT_OPTIONS_PLIST" | base64 --decode -o $EXPORT_OPTS_PATH + xcodebuild -exportArchive -archivePath $RUNNER_TEMP/your_app.xcarchive -exportOptionsPlist $EXPORT_OPTS_PATH -exportPath $RUNNER_TEMP/build + + - name: Upload application + uses: actions/upload-artifact@v3 + with: + name: app + path: ${{ runner.temp }}/build + retention-days: 3