From e6644ad6dd8a4dd7ef77b5d205268b9303648a5c Mon Sep 17 00:00:00 2001 From: Sai Krishna Vennamaneni Date: Wed, 1 Apr 2026 02:44:32 +0530 Subject: [PATCH] ci: add CI/CD pipeline with lint, test, and EAS build stages --- .github/workflows/ci.yml | 22 ++++++++ .github/workflows/eas-preview.yml | 37 +++++++++++++ .github/workflows/eas-production.yml | 64 +++++++++++++++++++++ CI_CD.md | 83 ++++++++++++++++++++++++++++ 4 files changed, 206 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/eas-preview.yml create mode 100644 .github/workflows/eas-production.yml create mode 100644 CI_CD.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..629cba9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +name: CI + +on: + push: + branches: [main, staging] + pull_request: + branches: [main] + +jobs: + lint-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + - run: npm ci + - name: Lint + run: npx expo lint + - name: Test + run: npx jest --ci --coverage diff --git a/.github/workflows/eas-preview.yml b/.github/workflows/eas-preview.yml new file mode 100644 index 0000000..62af8bb --- /dev/null +++ b/.github/workflows/eas-preview.yml @@ -0,0 +1,37 @@ +name: EAS Preview Build + +on: + pull_request: + branches: [main] + +jobs: + lint-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + - run: npm ci + - name: Lint + run: npx expo lint + - name: Test + run: npx jest --ci + + preview-build: + needs: lint-and-test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + - run: npm ci + - uses: expo/expo-github-action@v8 + with: + eas-version: latest + token: ${{ secrets.EXPO_TOKEN }} + - name: Build preview + run: eas build --platform android --profile preview --non-interactive diff --git a/.github/workflows/eas-production.yml b/.github/workflows/eas-production.yml new file mode 100644 index 0000000..70a8143 --- /dev/null +++ b/.github/workflows/eas-production.yml @@ -0,0 +1,64 @@ +name: EAS Production Build + +on: + workflow_dispatch: + inputs: + platform: + description: "Platform to build" + required: true + default: "android" + type: choice + options: + - android + - ios + - all + submit: + description: "Submit to store after build" + required: false + default: false + type: boolean + +jobs: + lint-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + - run: npm ci + - name: Lint + run: npx expo lint + - name: Test + run: npx jest --ci + + production-build: + needs: lint-and-test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + - run: npm ci + - uses: expo/expo-github-action@v8 + with: + eas-version: latest + token: ${{ secrets.EXPO_TOKEN }} + - name: Build production + run: | + if [ "${{ inputs.platform }}" = "all" ]; then + eas build --platform all --profile production --non-interactive + else + eas build --platform ${{ inputs.platform }} --profile production --non-interactive + fi + - name: Submit to store + if: ${{ inputs.submit }} + run: | + if [ "${{ inputs.platform }}" = "all" ]; then + eas submit --platform all --non-interactive + else + eas submit --platform ${{ inputs.platform }} --non-interactive + fi diff --git a/CI_CD.md b/CI_CD.md new file mode 100644 index 0000000..f59e6a7 --- /dev/null +++ b/CI_CD.md @@ -0,0 +1,83 @@ +# CI/CD Pipeline + +## Overview + +Three GitHub Actions workflows handle CI checks and EAS builds. No VM deployment — builds are handled by Expo Application Services (EAS). + +## Architecture + +``` +Push to any branch ──▶ ci.yml ──▶ lint + test +PR to main ──▶ eas-preview.yml ──▶ lint + test ──▶ EAS preview build (Android APK) +Manual trigger ──▶ eas-production.yml ──▶ lint + test ──▶ EAS production build ──▶ (optional) store submit +``` + +## Workflows + +### 1. CI (`ci.yml`) + +Runs on every push to `main`/`staging` and on PRs to `main`. + +- `npm ci` +- `npx expo lint` (ESLint via expo config) +- `npx jest --ci --coverage` + +### 2. EAS Preview Build (`eas-preview.yml`) + +Runs on PRs to `main`. First runs lint + test, then builds. + +- Uses `expo/expo-github-action@v8` to set up EAS CLI +- `eas build --platform android --profile preview --non-interactive` +- Produces an internal-distribution APK for testing +- Build URL appears in the GitHub Actions logs and on [expo.dev](https://expo.dev) + +### 3. EAS Production Build (`eas-production.yml`) + +Manual trigger only (`workflow_dispatch`). Options: + +| Input | Type | Description | +|-------|------|-------------| +| `platform` | choice | `android`, `ios`, or `all` | +| `submit` | boolean | Whether to submit to Play Store / App Store after build | + +Flow: +1. Lint + test +2. `eas build --platform PLATFORM --profile production --non-interactive` +3. (If submit=true) `eas submit --platform PLATFORM --non-interactive` + +## EAS Profiles (from `eas.json`) + +| Profile | Distribution | Use | +|---------|-------------|-----| +| `development` | internal | Dev client builds | +| `preview` | internal | PR preview APKs | +| `production` | store | Play Store / App Store releases | + +## GitHub Secrets Required + +| Secret | Value | +|--------|-------| +| `EXPO_TOKEN` | Personal access token from [expo.dev](https://expo.dev) → Account Settings → Access Tokens (owner: `madhyamakist`) | + +## How to Get `EXPO_TOKEN` + +1. Log in to [expo.dev](https://expo.dev) as the `madhyamakist` account +2. Go to **Account Settings → Access Tokens** +3. Create a new token with a descriptive name (e.g., `github-actions`) +4. Copy the token and add it as a GitHub secret named `EXPO_TOKEN` + +## Running Locally + +```bash +# Lint +npx expo lint + +# Test +npx jest + +# Preview build +eas build --platform android --profile preview + +# Production build +eas build --platform android --profile production +```