DEV Community

George Pamfilis
George Pamfilis

Posted on

Trigger Expo Build GitLab CI - Snippet

Here is a snippet I use to trigger my apps to build. I have them set to manual because it costs money with Expo.

.gitlab-ci.yml snippet

eas_build_internal_android_developv2:
  stage: build-mobile
  image: node:16.17.0

  script:
    - npm install -g expo-cli
    - npm install -g eas-cli
    - cd mobileapp
    - npm i
    - EXPO_TOKEN=$EXPO_EAS_TOKEN eas build -p android --profile develop --no-wait

  only:
    refs:
      - develop
    changes:
      - mobileapp/**/* 
  when: manual

eas_build_internal_android_productionv2:
  stage: build-mobile
  image: node:16.17.0

  script:
    - npm install -g expo-cli
    - npm install -g eas-cli
    - cd mobileapp
    - npm i
    - EXPO_TOKEN=$EXPO_EAS_TOKEN eas build -p android --profile production --no-wait
  only:
    refs:
      - main
    changes:
      - mobileapp/**/* 
  when: manual

Enter fullscreen mode Exit fullscreen mode

eas.json

{
  "cli": {
    "version": ">= 2.2.1"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "env": {
        "EXPO_PUBLIC_BACKEND_DOMAIN": "https://something.ngrok-free.app"
      },
      "channel": "local",
      "distribution": "internal",
      "android": {
        "buildType": "apk"
      }
    },
    "develop": {
      "channel": "develop",
      "env": {
        "EXPO_PUBLIC_BACKEND_DOMAIN": "https://apidev.something.com",
        "EXPO_PUBLIC_GROWTHBOOK_CLIENT_KEY": ""
      },
      "distribution": "internal",
      "android": {
        "buildType": "apk"
      }
    },
    "production": {
      "env": {
        "EXPO_PUBLIC_BACKEND_DOMAIN": "https://api.something.com",
        "EXPO_PUBLIC_GROWTHBOOK_CLIENT_KEY": ""
      },
      "channel": "main",
      "distribution": "internal",
      "android": {
        "buildType": "apk"
      }
    }
  },
  "submit": {
    "production": {}
  }
}

Enter fullscreen mode Exit fullscreen mode

Might be also helpfull

app.json


{
  "expo": {
    "name": "mobileapp",
    "slug": "mobileapp",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/something.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/splash_v2.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/splash_v2.png",
        "backgroundColor": "#ffffff"
      },
      "package": "com.something.someone"
    },
    "web": {
      "favicon": "./assets/something.png"
    },
    "plugins": ["expo-router"],

    "extra": {
      "router": {
        "origin": false
      },
      "eas": {
        "projectId": "something"
      }
    },
    "runtimeVersion": {
      "policy": "appVersion"
    },
    "updates": {
      "url": "https://u.expo.dev/something"
    }
  }
}

Enter fullscreen mode Exit fullscreen mode

babel.config.js

module.exports = function (api) {
  api.cache(true);
  return {
    presets: ["babel-preset-expo"],
    plugins: [
      [
        "module:react-native-dotenv",
        {
          moduleName: "@env",
          path: ".env",
          blacklist: null,
          whitelist: null,
          safe: false,
          allowUndefined: true,
        },
      ],
    ],
  };
};

Enter fullscreen mode Exit fullscreen mode

Sentry mobile image

Improving mobile performance, from slow screens to app start time

Based on our experience working with thousands of mobile developer teams, we developed a mobile monitoring maturity curve.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay