From 0e378c67b86fa8c693989dadc3e43f2f8a20bdac Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Fri, 29 Jul 2022 14:10:31 -0300 Subject: [PATCH] Chore: Try Github Actions (#4376) --- .github/workflow-android-experimental.yml | 76 +++++++++++++++++++++++ .github/workflow-ios-experimental.yml | 71 +++++++++++++++++++++ .github/workflow-test-and-lint.yml | 26 ++++++++ 3 files changed, 173 insertions(+) create mode 100644 .github/workflow-android-experimental.yml create mode 100644 .github/workflow-ios-experimental.yml create mode 100644 .github/workflow-test-and-lint.yml diff --git a/.github/workflow-android-experimental.yml b/.github/workflow-android-experimental.yml new file mode 100644 index 000000000..4aaca6e6e --- /dev/null +++ b/.github/workflow-android-experimental.yml @@ -0,0 +1,76 @@ +name: Build Android + +on: + pull_request: + types: ["labeled"] + +jobs: + build-android: + if: contains(github.event.pull_request.labels.*.name, 'android-build') + + name: Build Android + runs-on: ubuntu-latest + environment: develop + defaults: + run: + working-directory: android + + env: + JAVA_OPTS: "-Xms512m -Xmx2g" + GRADLE_OPTS: '-Xmx3g -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-Xmx2g -XX:+HeapDumpOnOutOfMemoryError"' + TERM: dumb + + steps: + - name: Check out Git repository + uses: actions/checkout@v3 + + - name: Decode Keystore + run: echo ${{ secrets.KEYSTORE_BASE_64 }} | base64 -d > ./app/key.keystore + + - uses: c-hive/gha-yarn-cache@v2 + + - name: Install dependencies + run: yarn install --prefer-offline + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + distribution: "zulu" + java-version: 11.0.14 + cache: "gradle" + + - name: Make Gradlew Executable + run: chmod +x ./gradlew + + - name: Set gradle.properties + run: | + echo -e "" > ./gradle.properties + echo -e android.useAndroidX=true >> ./gradle.properties + echo -e android.enableJetifier=true >> ./gradle.properties + echo -e FLIPPER_VERSION=0.51.0 >> ./gradle.properties + echo -e VERSIONCODE=${{ github.run_number }} >> ./gradle.properties + echo -e APPLICATION_ID=chat.rocket.reactnative >> ./gradle.properties + echo -e BugsnagAPIKey=${{ secrets.BUGSNAG_KEY }} >> ./gradle.properties + echo -e KEYSTORE=${{ secrets.KEYSTORE }} >> ./gradle.properties + echo -e KEYSTORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }} >> ./gradle.properties + echo -e KEY_ALIAS=${{ secrets.KEY_ALIAS }} >> ./gradle.properties + echo -e KEY_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }} >> ./gradle.properties + + - name: Generate App APK + run: | + ./gradlew bundleExperimentalPlayRelease --no-daemon + + - name: Upload sourcemaps to Bugsnag + run: | + npx bugsnag-source-maps upload-react-native \ + --api-key=${{ secrets.BUGSNAG_KEY }} \ + --app-version-code=${{ github.event.number }} \ + --platform android \ + --source-map=app/build/generated/sourcemaps/react/experimentalPlay/release/app.bundle.map \ + --bundle app/build/generated/assets/react/experimentalPlay/release/app.bundle + + - name: Store Artifacts + uses: actions/upload-artifact@v3 + with: + name: app.bundle-${{ github.event.number }} + path: app/build/generated/assets/react/experimentalPlay/release/app.bundle diff --git a/.github/workflow-ios-experimental.yml b/.github/workflow-ios-experimental.yml new file mode 100644 index 000000000..8cf8c4a71 --- /dev/null +++ b/.github/workflow-ios-experimental.yml @@ -0,0 +1,71 @@ +name: Build iOS + +on: + pull_request: + types: ['labeled'] + +jobs: + build-android: + if: contains(github.event.pull_request.labels.*.name, 'ios-build') + + name: Build iOS + runs-on: macos-latest + environment: develop + defaults: + run: + working-directory: ios + + steps: + - name: Check out Git repository + uses: actions/checkout@v3 + + - uses: c-hive/gha-yarn-cache@v2 + + - name: Install dependencies + run: yarn install --prefer-offline + + - name: Setup Ruby (bundle) + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + bundler-cache: true + - run: bundle install + + - name: Restore Pods cache + uses: actions/cache@v2 + with: + path: | + ios/Pods + ~/Library/Caches/CocoaPods + ~/.cocoapods + key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }} + restore-keys: | + ${{ runner.os }}-pods- + + - name: Install Pods + run: pod install --repo-update && cd .. + + - name: Set version + run: agvtool new-version -all ${{ github.run_number }} + + - name: Set Keys + run: | + /usr/libexec/PlistBuddy -c "Set :bugsnag:apiKey ${{ secrets.BUGSNAG_KEY }}" ./RocketChatRN/Info.plist + /usr/libexec/PlistBuddy -c "Set :bugsnag:apiKey ${{ secrets.BUGSNAG_KEY }}" ./ShareRocketChatRN/Info.plist + /usr/libexec/PlistBuddy -c "Set IS_OFFICIAL NO" ./RocketChatRN/Info.plist + /usr/libexec/PlistBuddy -c "Set IS_OFFICIAL NO" ./ShareRocketChatRN/Info.plist + /usr/libexec/PlistBuddy -c "Set IS_OFFICIAL NO" ./NotificationService/Info.plist + + - name: Decode P8 + run: echo ${{ secrets.APP_STORE_CONNECT_API_BASE64 }} | base64 --decode > ./fastlane/app_store_connect_api_key.p8 + + - name: Run fastlane + run: fastlane ios build_experimental + + - name: Store Artifacts + uses: actions/upload-artifact@v3 + with: + name: Rocket.Chat.${{ github.event.number }}.ipa + path: | + Rocket.Chat.ipa + Rocket.Chat.app.dSYM.zip diff --git a/.github/workflow-test-and-lint.yml b/.github/workflow-test-and-lint.yml new file mode 100644 index 000000000..294f67f77 --- /dev/null +++ b/.github/workflow-test-and-lint.yml @@ -0,0 +1,26 @@ +name: Test and Lint + +on: [push] + +jobs: + test-and-lint: + name: Test and lint + runs-on: ubuntu-latest + + steps: + - name: Check out Git repository + uses: actions/checkout@v2 + + - uses: c-hive/gha-yarn-cache@v2 + + - name: Install dependencies + run: yarn install --prefer-offline + + - name: Lint + run: yarn lint + + - name: Test + run: yarn test -w 8 + + - name: Codecov + run: yarn codecov