Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions .github/workflows/eas-build-prod.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/workflows/eas-build-qa.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/workflows/eas-build-staging.yml

This file was deleted.

44 changes: 25 additions & 19 deletions .github/workflows/eas-build.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
# 🔗 Links:
# Source file: https://github.com/rootstrap/react-native-template/blob/master/.github/actions/eas-build/action.yml
# Source file: https://github.com/rootstrap/react-native-template/blob/master/.github/workflows/eas-build.yml
# EAS Build docs: https://docs.expo.dev/eas-update/github-actions/

# ✍️ Description:
# This is a composite action, which means it can be used in other actions.
# This action is used to trigger an EAS Build for a specific environment (development, staging, production).
# This workflow is used to trigger a build on EAS.
# Can be triggered manually from the actions tab.

# This action accepts those inputs:
# `APP_ENV`, which is used to generate an APK for a specific environment (development, staging, production). We use staging by default.
# `AUTO_SUBMIT`, false by default, set to true if you want to automatically submit your build to stores.
# `EXPO_TOKEN`, required, access token for your Expo account. https://expo.dev/settings/access-tokens
# `VERSION`, required, version of the app to build. used as the build message.
# `ANDROID`, true by default, set to true if you don't want to trigger build for Android.
# `IOS`, false by default, set to true if you want to trigger build for IOS.
# `environment`, which is used to generate a build for a specific environment (development, staging, QA, production). We use staging by default.
# `android`, true by default, set to true if you don't want to trigger build for Android.
# `ios`, false by default, set to true if you want to trigger build for IOS.

# Before triggering the build, we run a pre-build script to generate the necessary native folders based on the APP_ENV.
# Based on the ANDROID and IOS inputs, we trigger the build for the corresponding platform with the corresponding flags.

# 👀 Example usage:
# - name: ⏱️ EAS Build
# uses: ./.github/actions/eas-build
# with:
# environment: staging
# EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
# VERSION: ${{ github.event.release.tag_name }}
# IOS: false
# 🚨 GITHUB SECRETS REQUIRED:
# - EXPO_TOKEN: Expo token to authenticate with EAS
# - You can get it from https://expo.dev/settings/access-tokens

name: 'Setup EAS Build + Trigger Build'
name: 'EAS Build (Android & IOS) (EAS)'

on:
workflow_dispatch:
inputs:
environment:
type: choice
description: 'environment (one of): development, staging, production'
description: 'Environment'
required: true
default: 'staging'
options:
- development
- staging
- qa
- production
android:
type: boolean
description: 'Build for Android'
required: true
default: true
ios:
type: boolean
description: 'Build for iOS'
required: true
default: true

jobs:
Build:
Expand Down Expand Up @@ -69,7 +73,9 @@ jobs:
run: pnpm prebuild:${{ inputs.environment }}

- name: 📱 Run Android Build
if: ${{ inputs.android == true }}
run: pnpm build:${{ inputs.environment }}:android --non-interactive --no-wait --message "Build ${{ inputs.environment }}"

- name: 📱 Run IOS Build
if: ${{ inputs.ios == true }}
run: pnpm build:${{ inputs.environment }}:ios --non-interactive --no-wait --message "Build ${{ inputs.environment }}"
12 changes: 11 additions & 1 deletion env.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,18 @@ const scriptIsEnvironmentDependant = ENVIRONMENT_DEPENDANT_SCRIPTS.some(
);

// Check if the environment file has to be validated for the current running script and build method
const isBuilding = isEASBuild || isLocalBuild;
const isRunning = process.env.npm_lifecycle_script?.includes('expo run');
const shouldValidateEnv =
(isEASBuild || isLocalBuild) && scriptIsEnvironmentDependant;
(isBuilding && scriptIsEnvironmentDependant) || isRunning;

console.log({
npm_lifecycle_script: process.env.npm_lifecycle_script,
scriptIsEnvironmentDependant,
isLocalBuild,
isEASBuild,
shouldValidateEnv,
});

const easEnvironmentFileVariable = `ENVIRONMENT_FILE_${APP_ENV.toUpperCase()}`;
const easEnvironmentFilePath = process.env[easEnvironmentFileVariable];
Expand Down
28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,33 @@
"scripts": {
"start": "cross-env EXPO_NO_DOTENV=1 expo start",
"prebuild": "cross-env EXPO_NO_DOTENV=1 pnpm expo prebuild",
"start:development": "cross-env APP_ENV=development pnpm run start",
"prebuild:development": "cross-env APP_ENV=development pnpm run prebuild",
"android": "cross-env EXPO_NO_DOTENV=1 expo run:android",
"ios": "cross-env EXPO_NO_DOTENV=1 expo run:ios",
"xcode": "xed -b ios",
"doctor": "npx expo-doctor@latest",
"preinstall": "npx only-allow pnpm",
"build:development:android": "cross-env APP_ENV=development EXPO_NO_DOTENV=1 eas build --profile development --platform android ",
"build:development:ios": "cross-env APP_ENV=development EXPO_NO_DOTENV=1 eas build --profile development --platform ios",
"start:staging": "cross-env APP_ENV=staging pnpm run start",
"start:qa": "cross-env APP_ENV=qa pnpm run start",
"prebuild:staging": "cross-env APP_ENV=staging pnpm run prebuild",
"prebuild:qa": "cross-env APP_ENV=qa pnpm run prebuild",
"android:staging": "cross-env APP_ENV=staging pnpm run android",
"android:qa": "cross-env APP_ENV=qa pnpm run android",
"ios:staging": "cross-env APP_ENV=staging pnpm run ios",
"build:staging:android": "cross-env APP_ENV=staging EXPO_NO_DOTENV=1 eas build --profile staging --platform android ",
"build:staging:ios": "cross-env APP_ENV=staging EXPO_NO_DOTENV=1 eas build --profile staging --platform ios",
"start:qa": "cross-env APP_ENV=qa pnpm run start",
"prebuild:qa": "cross-env APP_ENV=qa pnpm run prebuild",
"android:qa": "cross-env APP_ENV=qa pnpm run android",
"ios:qa": "cross-env APP_ENV=qa pnpm run ios",
"build:qa:ios": "cross-env APP_ENV=qa EXPO_NO_DOTENV=1 eas build --profile qa --platform ios",
"build:qa:android": "cross-env APP_ENV=qa EXPO_NO_DOTENV=1 eas build --profile qa --platform android ",
"start:production": "cross-env APP_ENV=production pnpm run start",
"prebuild:production": "cross-env APP_ENV=production pnpm run prebuild",
"android:production": "cross-env APP_ENV=production pnpm run android",
"ios:production": "cross-env APP_ENV=production pnpm run ios",
"build:development:ios": "cross-env APP_ENV=development EXPO_NO_DOTENV=1 eas build --profile development --platform ios",
"build:development:android": "cross-env APP_ENV=development EXPO_NO_DOTENV=1 eas build --profile development --platform android ",
"build:staging:ios": "cross-env APP_ENV=staging EXPO_NO_DOTENV=1 eas build --profile staging --platform ios",
"build:qa:ios": "cross-env APP_ENV=qa EXPO_NO_DOTENV=1 eas build --profile qa --platform ios",
"build:staging:android": "cross-env APP_ENV=staging EXPO_NO_DOTENV=1 eas build --profile staging --platform android ",
"build:qa:android": "cross-env APP_ENV=qa EXPO_NO_DOTENV=1 eas build --profile qa --platform android ",
"build:production:ios": "cross-env APP_ENV=production EXPO_NO_DOTENV=1 eas build --profile production --platform ios",
"build:production:android": "cross-env APP_ENV=production EXPO_NO_DOTENV=1 eas build --profile production --platform android ",
"build:production:ios": "cross-env APP_ENV=production EXPO_NO_DOTENV=1 eas build --profile production --platform ios",
"xcode": "xed -b ios",
"doctor": "npx expo-doctor@latest",
"preinstall": "npx only-allow pnpm",
"postinstall": "husky install",
"app-release": "cross-env SKIP_BRANCH_PROTECTION=true np --no-publish --no-cleanup --no-release-draft --message 'chore: release template v%s'",
"version": "git add .",
Expand Down