CI/CD untuk Mobile — Mobile

CI/CD untuk Mobile App CI/CD di mobile lebih menantang dari web — build native butuh macOS (iOS), signing certificates, dan submit ke store. Untungnya EAS Build

CI/CD untuk Mobile App

CI/CD di mobile lebih menantang dari web — build native butuh macOS (iOS), signing certificates, dan submit ke store. Untungnya EAS Build dan GitHub Actions membuatnya manageable.

EAS Build di CI

# .github/workflows/mobile-ci.yml
name: Mobile CI/CD

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm test

  build:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - uses: expo/expo-github-action@v8
        with:
          eas-version: latest
          token: ${{ secrets.EXPO_TOKEN }}
      - run: npm ci
      # Build di cloud EAS (tidak perlu macOS runner!)
      - run: eas build --platform all --profile preview --non-interactive

Automated Submit

# Submit ke store setelah build production
  deploy:
    needs: build
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    steps:
      - uses: actions/checkout@v4
      - uses: expo/expo-github-action@v8
        with:
          eas-version: latest
          token: ${{ secrets.EXPO_TOKEN }}
      - run: npm ci
      - run: eas build --platform all --profile production --non-interactive
      - run: eas submit --platform all --non-interactive

OTA Update di CI

# Update JS tanpa rebuild native
# Cocok untuk hotfix dan perubahan kecil
  ota-update:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: expo/expo-github-action@v8
        with:
          eas-version: latest
          token: ${{ secrets.EXPO_TOKEN }}
      - run: npm ci
      - run: eas update --branch production --message "${{ github.event.head_commit.message }}"

Fastlane Alternative

# Fastlane: native CI/CD tool (Ruby-based)
# Cocok jika butuh kontrol lebih dari EAS

# Fastfile
platform :ios do
  lane :beta do
    increment_build_number
    build_app(scheme: "MyApp")
    upload_to_testflight
  end

  lane :release do
    build_app(scheme: "MyApp")
    upload_to_app_store(
      submit_for_review: true,
      automatic_release: true
    )
  end
end

platform :android do
  lane :beta do
    gradle(task: "assembleRelease")
    upload_to_play_store(track: "internal")
  end
end

Branching Strategy untuk Mobile

Secrets Management

# Jangan commit ke repo:
# - EXPO_TOKEN (untuk EAS CLI)
# - Apple credentials (ASC API Key)
# - Google Play service account JSON
# - Signing keystores

# Simpan di GitHub Secrets atau EAS Secrets:
eas secret:create --name SENTRY_DSN --value "https://[email protected]/123"

Best Practices

Yang akan kamu pelajari