Skip to content

Commit

Permalink
update app build process (#2142)
Browse files Browse the repository at this point in the history
* update app build process

* Update package.json

* create scrips to configure mobile and update github action workflow

---------

Co-authored-by: Ruslan K <[email protected]>
  • Loading branch information
Sergemuhundu and evereq authored Feb 1, 2024
1 parent e7c0b14 commit 5755938
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 110 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/mobile.apps.android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ jobs:
run: |
yarn build:mobile
- name: Generate app.json and replace placeholders
run: |
cd apps/mobile && yarn config:mobile
env:
EXPO_PROJECT_SLUG: ${{ secrets.EXPO_PROJECT_SLUG }}
EXPO_PROJECT_NAME: ${{ secrets.EXPO_PROJECT_NAME }}
EXPO_PROJECT_OWNER: ${{ secrets.EXPO_PROJECT_OWNER }}
EXPO_PROJECT_ID: ${{ secrets.EXPO_PROJECT_ID }}

- name: Build on EAS
run: cd apps/mobile && eas build --platform android --non-interactive

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/mobile.apps.ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ jobs:
run: |
yarn build:mobile
- name: Generate app.json and replace placeholders
run: |
cd apps/mobile && yarn config:mobile
env:
EXPO_PROJECT_SLUG: ${{ secrets.EXPO_PROJECT_SLUG }}
EXPO_PROJECT_NAME: ${{ secrets.EXPO_PROJECT_NAME }}
EXPO_PROJECT_OWNER: ${{ secrets.EXPO_PROJECT_OWNER }}
EXPO_PROJECT_ID: ${{ secrets.EXPO_PROJECT_ID }}

- name: Build on EAS
run: cd apps/mobile && eas build --platform ios --non-interactive

Expand Down
37 changes: 37 additions & 0 deletions .scripts/configure.mobile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as fs from 'fs';
import * as path from 'path';
import * as dotenv from 'dotenv';

dotenv.config(); // Load environment variables from .env file

const templatePath = path.join(__dirname, '../apps/mobile/app.template.json');
const appJsonPath = path.join(__dirname, '../apps/mobile/app.json');

fs.copyFile(templatePath, appJsonPath, (err) => {
if (err) {
console.error('Error copying template file:', err);
return;
}

fs.readFile(appJsonPath, 'utf8', (err, appData) => {
if (err) {
console.error('Error reading app.json file:', err);
return;
}

const updatedData = appData
.replace(/\$EXPO_PROJECT_SLUG/g, process.env.EXPO_PROJECT_SLUG)
.replace(/\$EXPO_PROJECT_NAME/g, process.env.EXPO_PROJECT_NAME)
.replace(/\$EXPO_PROJECT_OWNER/g, process.env.EXPO_PROJECT_OWNER)
.replace(/\$EXPO_PROJECT_ID/g, process.env.EXPO_PROJECT_ID);

fs.writeFile(appJsonPath, updatedData, (err) => {
if (err) {
console.error('Error writing app.json file:', err);
return;
}

console.log('app.json generated successfully!');
});
});
});
4 changes: 4 additions & 0 deletions apps/mobile/.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ INVITE_CALLBACK_URL=https://app.ever.team/auth/passcode
EXPO_PUBLIC_SENTRY_DSN=
SENTRY_ORG=ever-co
SENTRY_PROJECT=ever-teams-mobile
EXPO_PROJECT_SLUG=ever-teams-mobile
EXPO_PROJECT_NAME=Ever Teams Mobile
EXPO_PROJECT_OWNER=everco
EXPO_PROJECT_ID=2ff924e4-7a91-4b23-9db9-7453a8063bb0
4 changes: 4 additions & 0 deletions apps/mobile/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ INVITE_CALLBACK_URL=https://app.ever.team/auth/passcode
EXPO_PUBLIC_SENTRY_DSN=
SENTRY_ORG=ever-co
SENTRY_PROJECT=ever-teams-mobile
EXPO_PROJECT_SLUG=ever-teams-mobile
EXPO_PROJECT_NAME=Ever Teams Mobile
EXPO_PROJECT_OWNER=everco
EXPO_PROJECT_ID=2ff924e4-7a91-4b23-9db9-7453a8063bb0
4 changes: 2 additions & 2 deletions apps/mobile/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,5 @@ yarn-error.log
.expo/
web-build/
dist/

# @end expo-cli
/app.json
# @end expo-cli
92 changes: 0 additions & 92 deletions apps/mobile/app.json

This file was deleted.

91 changes: 91 additions & 0 deletions apps/mobile/app.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{"name": "$EXPO_PROJECT_SLUG",
"displayName": "$EXPO_PROJECT_NAME",
"expo": {
"name": "$EXPO_PROJECT_NAME",
"slug": "$EXPO_PROJECT_SLUG",
"version": "0.1.0",
"orientation": "portrait",
"icon": "./assets/images/ever-teams-logo.png",
"splash": {
"image": "./assets/images/splash-ever-teams.png",
"resizeMode": "cover",
"backgroundColor": "#ffffff"
},
"owner": "$EXPO_PROJECT_OWNER",
"updates": {
"fallbackToCacheTimeout": 0,
"url": "https://u.expo.dev/$EXPO_PROJECT_ID"
},
"jsEngine": "hermes",
"assetBundlePatterns": ["**/*"],
"plugins": [
[
"expo-media-library",
{
"photosPermission": "Allow $(PRODUCT_NAME) to access your photos.",
"savePhotosPermission": "Allow $(PRODUCT_NAME) to save photos.",
"isAccessMediaLocationEnabled": true
}
],
"sentry-expo",
[
"expo-build-properties",
{
"android": {
"enableProguardInReleaseBuilds": true,
"extraProguardRules": "-keep public class com.horcrux.svg.** {*;}",
"allowBackup": false
}
}
]
],
"android": {
"icon": "./assets/images/app-icon-android-legacy-ever-teams.png",
"package": "ever.team",
"adaptiveIcon": {
"foregroundImage": "./assets/images/app-icon-android-adaptive-foreground-ever.png",
"backgroundImage": "./assets/images/app-icon-android-adaptive-background.png"
},
"splash": {
"image": "./assets/images/splash-ever-teams.png",
"resizeMode": "cover",
"backgroundColor": "#ffffff"
},
"permissions": [
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.ACCESS_MEDIA_LOCATION"
]
},
"ios": {
"icon": "./assets/images/app-icon-ios-ever-teams.png",
"supportsTablet": true,
"bundleIdentifier": "co.ever.teams",
"splash": {
"image": "./assets/images/splash-ever-teams.png",
"tabletImage": "./assets/images/splash-logo-ever-teams-ios-tablet.png",
"resizeMode": "cover",
"backgroundColor": "#ffffff"
},
"infoPlist": {
"NSCameraUsageDescription": "This app uses the camera to scan barcodes on event tickets.",
"NSPhotoLibraryUsageDescription": "Allow $(PRODUCT_NAME) to access your photos.",
"NSPhotoLibraryAddUsageDescription": "Allow $(PRODUCT_NAME) to save photos."
}
},
"web": {
"favicon": "./assets/images/app-icon-web-favicon.png",
"splash": {
"image": "./assets/images/splash-logo-web-ever-teams.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
}
},
"extra": {
"eas": {
"projectId": "$EXPO_PROJECT_ID"
}
},
"runtimeVersion": "exposdk:48.0.0"
}
}
34 changes: 18 additions & 16 deletions apps/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
},
"private": true,
"scripts": {
"start": "expo start --dev-client",
"ios": "yarn react-native run-ios",
"android": "yarn react-native run-android --active-arch-only",
"test:detox": "yarn detox test -c ios.sim.debug",
"build:detox": "yarn detox build -c ios.sim.debug",
"ci:test:detox": "yarn detox test -c ios.sim.release -l verbose --cleanup",
"ci:build:detox": "yarn detox build -c ios.sim.release",
"start": "yarn config:mobile && expo start --dev-client",
"ios": "yarn config:mobile && yarn react-native run-ios",
"android": "yarn config:mobile && yarn react-native run-android --active-arch-only",
"test:detox": "yarn config:mobile && yarn detox test -c ios.sim.debug",
"build:detox": "yarn config:mobile && yarn detox build -c ios.sim.debug",
"ci:test:detox": "yarn config:mobile && yarn detox test -c ios.sim.release -l verbose --cleanup",
"ci:build:detox": "yarn config:mobile && yarn detox build -c ios.sim.release",
"build": "yarn compile",
"compile": "yarn tsc --noEmit -p . --pretty",
"format": "yarn prettier --write \"app/**/*.{js,jsx,json,md,ts,tsx}\"",
Expand All @@ -25,18 +25,20 @@
"test:watch": "yarn jest --watch",
"adb": "yarn adb reverse tcp:9090 tcp:9090 && adb reverse tcp:3000 tcp:3000 && adb reverse tcp:9001 tcp:9001 && adb reverse tcp:8081 tcp:8081",
"postinstall": "node ./bin/postInstall",
"bundle:ios": "yarn react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios",
"bundle:android": "yarn react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
"bundle:ios": "yarn config:mobile && yarn react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios",
"bundle:android": "yarn config:mobile && yarn react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
"release:ios": "echo 'Not implemented yet: release:ios. Use Xcode. More info: https://reactnative.dev/docs/next/publishing-to-app-store'",
"release:android": "cd android && rm -rf app/src/main/res/drawable-* && ./gradlew assembleRelease && cd - && echo 'APK generated in ./android/app/build/outputs/apk/release/app-release.apk'",
"release:android": "yarn config:mobile && cd android && rm -rf app/src/main/res/drawable-* && ./gradlew assembleRelease && cd - && echo 'APK generated in ./android/app/build/outputs/apk/release/app-release.apk'",
"clean": "yarn npx react-native-clean-project",
"clean-all": "yarn npx react-native clean-project-auto",
"expo:start": "yarn expo start",
"expo:android": "yarn expo start --android",
"expo:ios": "yarn expo start --ios",
"expo:web": "yarn expo start --web",
"expo:build:detox": "yarn detox build -c ios.sim.expo",
"expo:test:detox": "./bin/downloadExpoApp.sh && yarn detox test --configuration ios.sim.expo"
"expo:start": "yarn config:mobile && yarn expo start",
"expo:android": "yarn config:mobile && yarn expo start --android",
"expo:ios": "yarn config:mobile && yarn expo start --ios",
"expo:web": "yarn config:mobile && yarn expo start --web",
"expo:build:detox": "yarn config:mobile && yarn detox build -c ios.sim.expo",
"expo:test:detox": "yarn config:mobile && ./bin/downloadExpoApp.sh && yarn detox test --configuration ios.sim.expo",
"eas:build": "yarn yarn config:mobile && && eas build",
"config:mobile": "yarn ts-node ../../.scripts/configure.mobile.ts"
},
"overrides": {
"react-error-overlay": "6.0.9"
Expand Down

0 comments on commit 5755938

Please sign in to comment.