如何使用 GitLab 自动构建 REACT Native 应用程序

Mod*_*dHu 4 continuous-integration android apk ios react-native

我正在寻找一种使用 GitLab 管道自动构建 React Native 应用程序的 APK 的方法,我似乎无法在网络上找到不使用 Expo 的解决方案,您对如何做到这一点有任何想法吗?

我们有一个测试人员团队想要在真实设备上测试 APK,您知道如何实现这一目标(没有 Expo)吗?

Ujj*_*har 5

嘿,我已经使用 gitlab CI/CD 管道成功地自动化了 React Native 构建应用程序。 您需要在项目的根目录中创建“.gitlab-ci.yml”文件并添加以下脚本,并且可以根据您的需要进行更改

before_script:
  - yarn install --frozen-lockfile #--frozen-lockfile to make sure we will have the same packages version

stages:
  - build

build project:
  stage: build
  image: reactnativecommunity/react-native-android
  cache:
    key:
      files:
        - yarn.lock
    paths:
      - node_modules
    policy: pull #`pull` the jobs pull the cache at the beginning but do not push the changes again.
  script:
    - yarn build:apk # is the scripts defined in your package.json as "cd android #&& ./gradlew assembleRelease"
    - yarn install --pure-lockfile --cache-folder .yarn
    
  artifacts:
    paths:
      - android/app/build/outputs/apk/release/app-release.apk
Run Code Online (Sandbox Code Playgroud)

如果您有任何问题请告诉我