4

I am looking for a way to build the APK of my React Native App automatically using a GitLab pipeline, I can't seem to find a solution on the web that does not use Expo, do you have any ideas on how to do this?

We have a team of testers who would like to test the APK on a real device, do you have any idea on how to achieve this (without Expo)?

1 Answer 1

5

Hey I've successfully automated react native build apps using gitlab CI/CD pipelines. You need to create ".gitlab-ci.yml" file in the root of your project and add below scripts and may change as per your needs.

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

let me know if you have any problems

Sign up to request clarification or add additional context in comments.

2 Comments

It gives me an error: Command "build:apk" not found. Did you come across this issue? I tried using npm too but throws an error nom command not found.
@Krunal script: yarn build: android is the script defined in your root package.json i.e you need to define in scripts as "cd android && ./gradlew assembleRelease"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.