From 192bfbe7aabdb34d9f466a57f7e84aa1c31ca99f Mon Sep 17 00:00:00 2001 From: Gergely Hegedus Date: Thu, 7 Sep 2023 14:11:28 +0300 Subject: [PATCH] PR workflow --- .github/workflows/validate_pullrequest.yml | 139 +++++++++++++++++++++ android/fastlane/Fastfile | 22 ++-- android/fastlane/README.md | 8 ++ ios/fastlane/Fastfile | 50 ++++---- ios/fastlane/README.md | 24 ++-- 5 files changed, 205 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/validate_pullrequest.yml diff --git a/.github/workflows/validate_pullrequest.yml b/.github/workflows/validate_pullrequest.yml new file mode 100644 index 0000000..3a17dbc --- /dev/null +++ b/.github/workflows/validate_pullrequest.yml @@ -0,0 +1,139 @@ +name: Validate Pull Request + +on: + pull_request: + branches: + - main + +jobs: + run-tests: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'npm' + - name: node_modules cache + uses: actions/cache@v3 + id: npm-cache + with: + path: node_modules + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-npm- + - name: Install Dependencies + run: npm ci + - name: Run Tests + run: npm run test + + build-android: + needs: run-tests + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'npm' + - name: node_modules cache + uses: actions/cache@v3 + id: npm-cache + with: + path: node_modules + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-npm- + - name: Install Dependencies + run: npm ci + + - name: Set up Ruby & Fastlane + uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1 + with: + ruby-version: '3.2.1' + bundler-cache: true + working-directory: ./android + + - name: Restore Release Keystore + env: + keystore_base64: ${{ secrets.RELEASE_KEYSTORE_BASE64 }} + run: | + echo "$keystore_base64" | base64 --decode > release.keystore + echo "CI_EVALUATION_KEYSTORE_FILE=`pwd`/release.keystore" >> $GITHUB_ENV + + - name: Build Release APK + env: + CI_EVALUATION_KEY_ALIAS: ${{ secrets.CI_EVALUATION_KEY_ALIAS }} + CI_EVALUATION_KEY_PASSWORD: ${{ secrets.CI_EVALUATION_KEY_PASSWORD }} + CI_EVALUATION_STORE_PASSWORD: ${{ secrets.CI_EVALUATION_STORE_PASSWORD }} + working-directory: ./android + run: bundle exec fastlane buildReleaseApk + + build-ios: + needs: run-tests + runs-on: macos-latest + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'npm' + - name: node_modules cache + uses: actions/cache@v3 + id: npm-cache + with: + path: node_modules + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-npm- + - name: Install Dependencies + run: npm ci + + - name: Set up Ruby & Fastlane + uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1 + with: + ruby-version: '3.2.1' + bundler-cache: true + working-directory: ./ios + + - name: pod install cache + uses: actions/cache@v3 + id: pod-cache + with: + path: ios/Pods + key: ${{ runner.os }}-pod-${{ hashFiles('ios/Podfile.lock') }} + restore-keys: ${{ runner.os }}-pod- + - name: Install iOS Dependencies + working-directory: ./ios + run: pod install + + - name: Restore Provisioning Profile + env: + ci_evaluation_provision_profile_base64: ${{ secrets.CI_EVALUATION_PROVISION_PROFILE_BASE64 }} + run: | + echo "$ci_evaluation_provision_profile_base64" | base64 --decode > profile.mobileprovision + mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles + cp profile.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/profile.mobileprovision + echo "CI_EVALUATION_PROVISIONING_PROFILE_FILE=\"~/Library/MobileDevice/Provisioning Profiles/profile.mobileprovision\"" >> $GITHUB_ENV + - name: Restore iOS Cert + env: + ci_evaluation_cert_base64: ${{ secrets.CI_EVALUATION_CERT_BASE64 }} + run: | + echo "$ci_evaluation_cert_base64" | base64 --decode > ios_distribution.p12 + echo "CI_EVALUATION_IOS_CERT_FILE=`pwd`/ios_distribution.p12" >> $GITHUB_ENV + + - name: Build Release IPA + env: + CI_EVALUATION_CERTIFICATE_PASSWORD: ${{ secrets.CI_EVALUATION_CERTIFICATE_PASSWORD }} + CI_EVALUATION_APP_IDENTIFIER: ${{ secrets.CI_EVALUATION_APP_IDENTIFIER }} + working-directory: ./ios + run: bundle exec fastlane buildReleaseIPA \ No newline at end of file diff --git a/android/fastlane/Fastfile b/android/fastlane/Fastfile index 89a82a7..4d51933 100644 --- a/android/fastlane/Fastfile +++ b/android/fastlane/Fastfile @@ -32,15 +32,7 @@ platform :android do lane :deployInternalFirebase do |options| release_notes = options[:release_notes] - gradle(task: 'clean', flags: "--no-daemon") - gradle( - task: 'assemble', - build_type: 'release', - flags: "--no-daemon", - properties: { - "applicationId" => "com.initproject.staging" - } - ) + buildReleaseApk() internal_apk = lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS].find{ |i| i[/app-*release*.apk/] } firebase_app_distribution( @@ -53,6 +45,18 @@ platform :android do ) end + lane :buildReleaseApk do + gradle(task: 'clean', flags: "--no-daemon") + gradle( + task: 'assemble', + build_type: 'release', + flags: "--no-daemon", + properties: { + "applicationId" => "com.initproject.staging" + } + ) + end + desc "Submit a new Production Build to Play Store" lane :deployProdPlayStore do |options| version_code = options[:version_code] # optional, if not set, it gets the last from PlayStore then adds + 1 diff --git a/android/fastlane/README.md b/android/fastlane/README.md index 3dcd887..50cb4aa 100644 --- a/android/fastlane/README.md +++ b/android/fastlane/README.md @@ -31,6 +31,14 @@ Submit a new Internal Build to Firebase ``` +### android buildReleaseApk + +```sh +[bundle exec] fastlane android buildReleaseApk +``` + + + ### android deployProdPlayStore ```sh diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index 475cd32..09ef994 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -29,6 +29,35 @@ platform :ios do APP_IDENTIFIER = ENV['CI_EVALUATION_APP_IDENTIFIER'] end + desc "Description of what the lane does" + lane :deployInternalFirebase do + ipa_name = "Internal.ipa" + buildReleaseIPA(ipa_name: ipa_name) + + firebase_app_distribution( + service_credentials_file: FIREBASE_SERVICE_ACCOUNT_FILE, + app: FIREBASE_APP_DISTRIBUTION_APP_STAGING, + groups: FIREBASE_APP_DISTRIBUTION_GROUPS_QA, + ipa_path: "builds/#{ipa_name}", + ) + cleanupKeyChain() + end + + lane :buildReleaseIPA do |options| + ipa_name = options[:ipa_name] + if ipa_name.nil? + ipa_name = "InternalBuild.ipa" + end + setupCodeSigning() + + build_app( + scheme: "InitProject", + export_method: "ad-hoc", + output_directory: "./builds", + output_name: ipa_name + ) + end + lane :setupCodeSigning do password = (0...50).map { ('a'..'z').to_a[rand(26)] }.join cleanupKeyChain() @@ -65,27 +94,6 @@ platform :ios do path: KEYCHAIN_NAME, password: password ) - end - - desc "Description of what the lane does" - lane :deployInternalFirebase do - setupCodeSigning() - ipa_name = "Internal.ipa" - - build_app( - scheme: "InitProject", - export_method: "ad-hoc", - output_directory: "./builds", - output_name: ipa_name - ) - - firebase_app_distribution( - service_credentials_file: FIREBASE_SERVICE_ACCOUNT_FILE, - app: FIREBASE_APP_DISTRIBUTION_APP_STAGING, - groups: FIREBASE_APP_DISTRIBUTION_GROUPS_QA, - ipa_path: "builds/#{ipa_name}", - ) - cleanupKeyChain() end lane :cleanupKeyChain do diff --git a/ios/fastlane/README.md b/ios/fastlane/README.md index a0d5955..46ae987 100644 --- a/ios/fastlane/README.md +++ b/ios/fastlane/README.md @@ -15,14 +15,6 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do ## iOS -### ios setupCodeSigning - -```sh -[bundle exec] fastlane ios setupCodeSigning -``` - - - ### ios deployInternalFirebase ```sh @@ -31,6 +23,22 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do Description of what the lane does +### ios buildReleaseIPA + +```sh +[bundle exec] fastlane ios buildReleaseIPA +``` + + + +### ios setupCodeSigning + +```sh +[bundle exec] fastlane ios setupCodeSigning +``` + + + ### ios cleanupKeyChain ```sh