Skip to content

Commit 7ca49f1

Browse files
authored
Merge pull request #49 from rootstrap/build/eas_refactor_eas_build_git_hub_actions
build(eas): refactor EAS build GitHub Actions
2 parents bd9f890 + 2e5d698 commit 7ca49f1

File tree

6 files changed

+51
-170
lines changed

6 files changed

+51
-170
lines changed

.github/workflows/eas-build-prod.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/eas-build-qa.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/eas-build-staging.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/eas-build.yml

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

55
# ✍️ Description:
6-
# This is a composite action, which means it can be used in other actions.
7-
# This action is used to trigger an EAS Build for a specific environment (development, staging, production).
6+
# This workflow is used to trigger a build on EAS.
7+
# Can be triggered manually from the actions tab.
8+
89
# This action accepts those inputs:
9-
# `APP_ENV`, which is used to generate an APK for a specific environment (development, staging, production). We use staging by default.
10-
# `AUTO_SUBMIT`, false by default, set to true if you want to automatically submit your build to stores.
11-
# `EXPO_TOKEN`, required, access token for your Expo account. https://expo.dev/settings/access-tokens
12-
# `VERSION`, required, version of the app to build. used as the build message.
13-
# `ANDROID`, true by default, set to true if you don't want to trigger build for Android.
14-
# `IOS`, false by default, set to true if you want to trigger build for IOS.
10+
# `environment`, which is used to generate a build for a specific environment (development, staging, QA, production). We use staging by default.
11+
# `android`, true by default, set to true if you don't want to trigger build for Android.
12+
# `ios`, false by default, set to true if you want to trigger build for IOS.
1513

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

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

28-
name: 'Setup EAS Build + Trigger Build'
21+
name: 'EAS Build (Android & IOS) (EAS)'
2922

3023
on:
3124
workflow_dispatch:
3225
inputs:
3326
environment:
3427
type: choice
35-
description: 'environment (one of): development, staging, production'
28+
description: 'Environment'
3629
required: true
3730
default: 'staging'
3831
options:
3932
- development
4033
- staging
34+
- qa
4135
- production
36+
android:
37+
type: boolean
38+
description: 'Build for Android'
39+
required: true
40+
default: true
41+
ios:
42+
type: boolean
43+
description: 'Build for iOS'
44+
required: true
45+
default: true
4246

4347
jobs:
4448
Build:
@@ -69,7 +73,9 @@ jobs:
6973
run: pnpm prebuild:${{ inputs.environment }}
7074

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

7479
- name: 📱 Run IOS Build
80+
if: ${{ inputs.ios == true }}
7581
run: pnpm build:${{ inputs.environment }}:ios --non-interactive --no-wait --message "Build ${{ inputs.environment }}"

env.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,18 @@ const scriptIsEnvironmentDependant = ENVIRONMENT_DEPENDANT_SCRIPTS.some(
4141
);
4242

4343
// Check if the environment file has to be validated for the current running script and build method
44+
const isBuilding = isEASBuild || isLocalBuild;
45+
const isRunning = process.env.npm_lifecycle_script?.includes('expo run');
4446
const shouldValidateEnv =
45-
(isEASBuild || isLocalBuild) && scriptIsEnvironmentDependant;
47+
(isBuilding && scriptIsEnvironmentDependant) || isRunning;
48+
49+
console.log({
50+
npm_lifecycle_script: process.env.npm_lifecycle_script,
51+
scriptIsEnvironmentDependant,
52+
isLocalBuild,
53+
isEASBuild,
54+
shouldValidateEnv,
55+
});
4656

4757
const easEnvironmentFileVariable = `ENVIRONMENT_FILE_${APP_ENV.toUpperCase()}`;
4858
const easEnvironmentFilePath = process.env[easEnvironmentFileVariable];

package.json

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,33 @@
66
"scripts": {
77
"start": "cross-env EXPO_NO_DOTENV=1 expo start",
88
"prebuild": "cross-env EXPO_NO_DOTENV=1 pnpm expo prebuild",
9+
"start:development": "cross-env APP_ENV=development pnpm run start",
10+
"prebuild:development": "cross-env APP_ENV=development pnpm run prebuild",
911
"android": "cross-env EXPO_NO_DOTENV=1 expo run:android",
1012
"ios": "cross-env EXPO_NO_DOTENV=1 expo run:ios",
11-
"xcode": "xed -b ios",
12-
"doctor": "npx expo-doctor@latest",
13-
"preinstall": "npx only-allow pnpm",
13+
"build:development:android": "cross-env APP_ENV=development EXPO_NO_DOTENV=1 eas build --profile development --platform android ",
14+
"build:development:ios": "cross-env APP_ENV=development EXPO_NO_DOTENV=1 eas build --profile development --platform ios",
1415
"start:staging": "cross-env APP_ENV=staging pnpm run start",
15-
"start:qa": "cross-env APP_ENV=qa pnpm run start",
1616
"prebuild:staging": "cross-env APP_ENV=staging pnpm run prebuild",
17-
"prebuild:qa": "cross-env APP_ENV=qa pnpm run prebuild",
1817
"android:staging": "cross-env APP_ENV=staging pnpm run android",
19-
"android:qa": "cross-env APP_ENV=qa pnpm run android",
2018
"ios:staging": "cross-env APP_ENV=staging pnpm run ios",
19+
"build:staging:android": "cross-env APP_ENV=staging EXPO_NO_DOTENV=1 eas build --profile staging --platform android ",
20+
"build:staging:ios": "cross-env APP_ENV=staging EXPO_NO_DOTENV=1 eas build --profile staging --platform ios",
21+
"start:qa": "cross-env APP_ENV=qa pnpm run start",
22+
"prebuild:qa": "cross-env APP_ENV=qa pnpm run prebuild",
23+
"android:qa": "cross-env APP_ENV=qa pnpm run android",
2124
"ios:qa": "cross-env APP_ENV=qa pnpm run ios",
25+
"build:qa:ios": "cross-env APP_ENV=qa EXPO_NO_DOTENV=1 eas build --profile qa --platform ios",
26+
"build:qa:android": "cross-env APP_ENV=qa EXPO_NO_DOTENV=1 eas build --profile qa --platform android ",
2227
"start:production": "cross-env APP_ENV=production pnpm run start",
2328
"prebuild:production": "cross-env APP_ENV=production pnpm run prebuild",
2429
"android:production": "cross-env APP_ENV=production pnpm run android",
2530
"ios:production": "cross-env APP_ENV=production pnpm run ios",
26-
"build:development:ios": "cross-env APP_ENV=development EXPO_NO_DOTENV=1 eas build --profile development --platform ios",
27-
"build:development:android": "cross-env APP_ENV=development EXPO_NO_DOTENV=1 eas build --profile development --platform android ",
28-
"build:staging:ios": "cross-env APP_ENV=staging EXPO_NO_DOTENV=1 eas build --profile staging --platform ios",
29-
"build:qa:ios": "cross-env APP_ENV=qa EXPO_NO_DOTENV=1 eas build --profile qa --platform ios",
30-
"build:staging:android": "cross-env APP_ENV=staging EXPO_NO_DOTENV=1 eas build --profile staging --platform android ",
31-
"build:qa:android": "cross-env APP_ENV=qa EXPO_NO_DOTENV=1 eas build --profile qa --platform android ",
32-
"build:production:ios": "cross-env APP_ENV=production EXPO_NO_DOTENV=1 eas build --profile production --platform ios",
3331
"build:production:android": "cross-env APP_ENV=production EXPO_NO_DOTENV=1 eas build --profile production --platform android ",
32+
"build:production:ios": "cross-env APP_ENV=production EXPO_NO_DOTENV=1 eas build --profile production --platform ios",
33+
"xcode": "xed -b ios",
34+
"doctor": "npx expo-doctor@latest",
35+
"preinstall": "npx only-allow pnpm",
3436
"postinstall": "husky install",
3537
"app-release": "cross-env SKIP_BRANCH_PROTECTION=true np --no-publish --no-cleanup --no-release-draft --message 'chore: release template v%s'",
3638
"version": "git add .",

0 commit comments

Comments
 (0)