SuperAPI AI 工具集

expo-build

部署与运维

查看项目

更新于 10-16 06:08

技能介绍

用途

该技能适用于使用 EAS(Expo Application Services)Build 构建和部署 Expo 应用的场景,涵盖构建配置、开发构建、生产构建以及应用商店提交。

主要能力

EAS Build 配置

通过 eas.json 定义构建配置,示例:

{
  "cli": {
    "version": ">= 5.9.0"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "ios": {
        "simulator": true
      }
    },
    "preview": {
      "distribution": "internal"
    },
    "production": {
      "autoIncrement": true
    }
  },
  "submit": {
    "production": {}
  }
}

构建命令

# Development build
eas build --profile development --platform ios
eas build --profile development --platform android

# Preview build
eas build --profile preview --platform all

# Production build
eas build --profile production --platform all

# Local build
eas build --profile production --platform ios --local

开发构建

{
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "env": {
        "NODE_ENV": "development"
      }
    }
  }
}

环境变量

{
  "build": {
    "production": {
      "env": {
        "APP_ENV": "production",
        "API_URL": "https://api.myapp.com"
      }
    },
    "staging": {
      "env": {
        "APP_ENV": "staging",
        "API_URL": "https://staging-api.myapp.com"
      }
    }
  }
}

密钥管理

# Set secrets
eas secret:create --scope project --name API_KEY --value your_api_key
eas secret:create --scope project --name GOOGLE_SERVICES_JSON --value "$(cat google-services.json)" --type file

# List secrets
eas secret:list

在 eas.json 中使用:

{
  "build": {
    "production": {
      "env": {
        "API_KEY": "$(EAS_SECRET_API_KEY)"
      }
    }
  }
}

版本管理

{
  "build": {
    "production": {
      "autoIncrement": true,
      "ios": {
        "buildNumber": "1"
      },
      "android": {
        "versionCode": 1
      }
    }
  }
}

构建钩子

{
  "build": {
    "production": {
      "prebuild": "npm run generate-assets",
      "postbuild": "npm run cleanup"
    }
  }
}

多环境构建

{
  "build": {
    "development": {
      "developmentClient": true,
      "channel": "development",
      "distribution": "internal"
    },
    "staging": {
      "channel": "staging",
      "distribution": "internal",
      "ios": {
        "bundleIdentifier": "com.myapp.staging"
      },
      "android": {
        "package": "com.myapp.staging"
      }
    },
    "production": {
      "channel": "production",
      "autoIncrement": true
    }
  }
}

自定义原生代码

{
  "build": {
    "production": {
      "ios": {
        "buildConfiguration": "Release"
      },
      "android": {
        "gradleCommand": ":app:bundleRelease"
      }
    }
  }
}

应用商店提交

# iOS
eas submit --platform ios

# Android
eas submit --platform android

提交配置示例:

{
  "submit": {
    "production": {
      "ios": {
        "appleId": "your.apple.id@example.com",
        "ascAppId": "1234567890",
        "appleTeamId": "AB12CD34EF"
      },
      "android": {
        "serviceAccountKeyPath": "./service-account.json",
        "track": "production"
      }
    }
  }
}

构建监控

# View build status
eas build:list

# View specific build
eas build:view [build-id]

# Cancel build
eas build:cancel [build-id]

反模式

不要将密钥提交到配置中:

// Bad - Secrets in eas.json
{
  "build": {
    "production": {
      "env": {
        "API_KEY": "sk_live_1234567890"
      }
    }
  }
}

应使用 EAS Secrets:

eas secret:create --scope project --name API_KEY --value sk_live_1234567890

不要跳过版本递增:

// Bad - Manual version management
{
  "build": {
    "production": {
      "autoIncrement": false
    }
  }
}

应启用自动递增:

// Good - Auto increment
{
  "build": {
    "production": {
      "autoIncrement": true
    }
  }
}

相关技能

expo-config:为构建配置应用。

expo-updates:构建后的 OTA 更新。

限制

资料未提供该技能的收费、价格、平台支持范围、具体效果或完整使用步骤等额外信息。