From 3faf6eba6f0f7c9aba97a62bf47ed23a7c621565 Mon Sep 17 00:00:00 2001 From: Dan Yalg Date: Thu, 20 Jul 2023 10:49:24 +1000 Subject: [PATCH] Adding eas scripts --- .github/actions/setup-monorepo/action.yml | 46 +++++++++++++ .github/workflows/eas-build.yml | 82 +++++++++++++++++++++++ .github/workflows/eas-cleanup.yml | 61 +++++++++++++++++ .github/workflows/eas-update.yml | 72 ++++++++++++++++++++ 4 files changed, 261 insertions(+) create mode 100644 .github/actions/setup-monorepo/action.yml create mode 100644 .github/workflows/eas-build.yml create mode 100644 .github/workflows/eas-cleanup.yml create mode 100644 .github/workflows/eas-update.yml diff --git a/.github/actions/setup-monorepo/action.yml b/.github/actions/setup-monorepo/action.yml new file mode 100644 index 0000000..99d7e1d --- /dev/null +++ b/.github/actions/setup-monorepo/action.yml @@ -0,0 +1,46 @@ +name: Setup Monorepo +description: Prepare and install everything for the monorepo + +inputs: + node-version: + description: Version of Node to use + default: 18.x + + eas-version: + description: Version of EAS CLI to use + default: latest + + expo-token: + description: Expo token to authenticate with + required: false + +runs: + using: composite + steps: + - name: 🏗 Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + cache: yarn + cache-dependency-path: './yarn.lock' + + - name: 🏗 Setup Expo + uses: expo/expo-github-action@v8 + with: + eas-version: ${{ inputs.eas-version }} + token: ${{ inputs.expo-token }} + + - name: 📦 Instal Deps + run: yarn install + shell: bash + + - name: ♻️ Restore Cache + uses: actions/cache@v3 + with: + key: turbo-${{ runner.os }}-${{ github.sha }} + restore-keys: | + turbo-${{ runner.os }} + path: | + node_modules/.cache/turbo + apps/*/.turbo + packages/*/.turbo diff --git a/.github/workflows/eas-build.yml b/.github/workflows/eas-build.yml new file mode 100644 index 0000000..1ce59e5 --- /dev/null +++ b/.github/workflows/eas-build.yml @@ -0,0 +1,82 @@ +name: EAS Build + +on: + workflow_dispatch: + inputs: + platform: + description: Platform to build for (all/android/ios) + type: choice + required: true + default: all + options: + - all + - android + - ios + profile: + description: EAS Profile + type: choice + required: true + default: dev-client-sim-build + options: + - dev-client-sim-build + - bundled-sim-build + - development + - staging + - production + versionBumpType: + description: 'Version Bump Type (only set for prod builds)' + required: true + default: 'none' + type: choice + options: + - none + - patch + - minor + - major + +env: + WORKING_DIRECTORY: apps/mobile + DOTENV_KEY: ${{ secrets.DOTENV_KEY }} + +jobs: + mobile: + runs-on: ubuntu-latest + steps: + - name: 🏗 Setup Repo + uses: actions/checkout@v3 + + - name: 🏗 Setup Monorepo + uses: ./.github/actions/setup-monorepo + with: + expo-token: ${{ secrets.EXPO_CI_TOKEN }} + + - name: ⬆️ Bump App Version - Patch + if: ${{ github.event.inputs.versionBumpType == 'patch' }} + working-directory: ${{ env.WORKING_DIRECTORY }} + run: ./scripts/bump_version.sh -p + + - name: ⬆️ Bump App Version - Minor + if: ${{ github.event.inputs.versionBumpType == 'minor' }} + working-directory: ${{ env.WORKING_DIRECTORY }} + run: ./scripts/bump_version.sh -m + + - name: ⬆️ Bump App Version - Major + if: ${{ github.event.inputs.versionBumpType == 'major' }} + working-directory: ${{ env.WORKING_DIRECTORY }} + run: ./scripts/bump_version.sh -M + + - name: 👷 Commit Changes + if: ${{ github.event.inputs.versionBumpType != 'none' }} + uses: EndBug/add-and-commit@v9 + with: + author_name: Dan Yalg + author_email: dan@thecodingforge.com.au + message: 'Automated Version Bump' + add: 'apps/mobile/app.json' + + - name: 👷 Build Mobile Packages + run: yarn run build:mobile + + - name: 🚀 EAS Build Mobile + working-directory: ${{ env.WORKING_DIRECTORY }} + run: eas build --non-interactive --no-wait --platform ${{ github.event.inputs.platform }} --profile ${{ github.event.inputs.profile }} diff --git a/.github/workflows/eas-cleanup.yml b/.github/workflows/eas-cleanup.yml new file mode 100644 index 0000000..634e61c --- /dev/null +++ b/.github/workflows/eas-cleanup.yml @@ -0,0 +1,61 @@ +name: EAS Cleanup + +on: + pull_request: + types: + - closed + +jobs: + changes: + timeout-minutes: 10 + runs-on: ubuntu-latest + outputs: + mobile: ${{ steps.filter.outputs.mobile }} + steps: + - uses: actions/checkout@v3 + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + mobile: + - 'apps/mobile/**' + + - run: echo ${{ steps.filter.outputs.mobile }} + + cleanup: + needs: changes + if: ${{ needs.changes.outputs.mobile == 'true' }} + timeout-minutes: 10 + name: Cleanup Preview Channel and Branch + runs-on: ubuntu-latest + defaults: + run: + working-directory: apps/mobile + steps: + - name: 🏗 Setup Repo + uses: actions/checkout@v3 + + # if we are on the develpoment, staging or main branches, then exit early + - name: Check Branch + if: ${{ github.head_ref == 'development' || github.head_ref == 'staging' || github.head_ref == 'main' }} + run: exit 0 + + - name: 🏗 Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: yarn + cache-dependency-path: './yarn.lock' + + - name: 🏗 Setup Expo + uses: expo/expo-github-action@v8 + with: + expo-version: latest + eas-version: latest + token: ${{ secrets.EXPO_CI_TOKEN }} + + - name: 🗑️ Delete Channel + run: eas channel:delete ${{ github.head_ref }} --non-interactive + + - name: 🗑️ Delete Branch + run: eas branch:delete ${{ github.head_ref }} --non-interactive diff --git a/.github/workflows/eas-update.yml b/.github/workflows/eas-update.yml new file mode 100644 index 0000000..f6aadf3 --- /dev/null +++ b/.github/workflows/eas-update.yml @@ -0,0 +1,72 @@ +name: EAS Update + +on: + pull_request: + types: [opened, reopened, synchronize] + +concurrency: + group: ${{ github.head_ref }} + cancel-in-progress: true + +jobs: + changes: + timeout-minutes: 10 + runs-on: ubuntu-latest + outputs: + mobile: ${{ steps.filter.outputs.mobile }} + steps: + - uses: actions/checkout@v3 + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + mobile: + - 'apps/mobile/**' + + - run: echo ${{ steps.filter.outputs.mobile }} + + update-mobile: + needs: changes + if: ${{ needs.changes.outputs.mobile == 'true' }} + runs-on: ubuntu-latest + steps: + - name: 🏗 Setup Repo + uses: actions/checkout@v3 + + - name: 🏗 Setup Monorepo + uses: ./.github/actions/setup-monorepo + with: + expo-token: ${{ secrets.EXPO_CI_TOKEN }} + + - name: 👷 Build Mobile Packages + run: yarn run build:mobile + + - name: 🕵️ Pull Env Vars + working-directory: apps/mobile + run: npx dotenv-vault pull development -m ${{ secrets.DOTENV_ME }} + env: + DOTENV_KEY: ${{ secrets.DOTENV_KEY }} + # https://github.com/expo/expo-github-action/issues/221 + + - name: 😷 Expo Doctor + working-directory: apps/mobile + run: npx expo-doctor + + - name: 🚀 EAS Update Mobile + continue-on-error: true + uses: expo/expo-github-action/preview@v8 + with: + working-directory: apps/mobile + command: eas update --auto --branch ${{ github.head_ref }} --non-interactive + + mobile-update-ignored: + timeout-minutes: 5 + needs: changes + if: ${{ needs.changes.outputs.mobile == 'false' }} + runs-on: ubuntu-latest + steps: + - name: Comment PR + uses: marocchino/sticky-pull-request-comment@v2 + with: + message: | + :no_entry: This PR does not contain changes to the mobile app. No Expo Preview Deployment will be created.