This article will guide you through building Expo application for deployment to GPC and Test Flight
If you dont have expo-dev-client you need to install it for development builds:
npx expo install expo-dev-client
-
Create eas account on https://expo.dev/eas
-
install eas globally on your machine
npm install -g eas-cli
-
login into eas account
eas login
-
configure project for Eas build
eas build:configure
-
modify your eas.json to include env variables and types of packages you want built
"cli": {
"version": ">= 12.5.2",
"appVersionSource": "remote"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal",
"env": {
"EXPO_PUBLIC_API": "https://your-api-address.com"
}
},
"preview": {
"distribution": "internal",
"buildType": "apk",
"env": {
"EXPO_PUBLIC_API": "https://your-api-address.com"
}
},
"preview-apk": {
"android": {
"buildType": "apk"
}
"distribution": "internal",
"env": {
"EXPO_PUBLIC_API": "https://your-api-address.com"
}
},
"production": {
"autoIncrement": true,
"env": {
"EXPO_PUBLIC_API": "https://your-api-address.com"
}
}
},
"submit": {
"production": {}
}
}
- run build with --local flag, this will create needed credentials for android and ios and store on eas server,
provide --profile(-e) and --platform(-p) or select platform in terminal, you can only build one platform at time locally
eas build -e production -p android —local
- add eas.json, credentials.json and credentials folder to .gitignore
- check docs for more details https://docs.expo.dev/build/setup/
In case of "error Distribution certificate with fingerprint xxxxxxxxxxx hasn't been imported successfully" follow steps presented here
This process uses remote credentials from EAS, you can read more details at managed credentials.
To use local credentials you need to follow steps outlined at using local credentials for CI.
My preferred workflow is to let EAS automaticly generate signature keys for android and apple apps, and then we can download them directly through eas credentials
into app and set CI tools to use local credentials if we dont want to use EAS hosted credentials.
Summarized setup steps
-
put keystore (android) and Distribution Certificate and Provisioning Profile (for ios) to .gitignore.
android/keystores/release.keystore
ios/certs/*
-
update eas.json to use local credentials, e.g:
"build": {
"amazon-production": {
"android": {
"credentialsSource": "local"
}
},
"google-production": {
"android": {
"credentialsSource": "remote"
}
}
}
}
- convert credentials.json to a base64-encoded string, set an environment variable to that value, and later decode it and restore the file on the CI.
base64 credentials.json
- set CI env variable CREDENTIALS_JSON_BASE64 to output from above command
- on CI restore base64 string to credentials.json
echo $CREDENTIALS_JSON_BASE64 | base64 -d > credentials.json
- repeat steps 3-5 for keystore, provisioning profile and distribution certificate so you can provide them to CI.
In case you need to build android app directly, you need to do following steps:
-
prebuild code with expo so you create android folder
npx expo prebuild --clean
-
create upload key and keystore, follow instructions here or use
keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
-
cd android && ./gradlew bundleRelease (builds .aap for play store or use assembleReleaase to build .apk)
-
in android/gradle.properties add
MY_UPLOAD_KEYSTORE_FILE=keystore.jks # or name of your keystore file
MY_UPLOAD_KEYSTORE_PASSWORD=YOUR_KEYSTORE_PASSWORD
MY_UPLOAD_KEY_ALIAS=YOUR_KEY_ALIAS
MY_UPLOAD_KEY_PASSWORD=YOUR_KEY_PASSWORD
- in android/app/build.gradle add inside signingConfigs
release {
if(project.hasProperty('MY_UPLOAD_KEYSTORE_FILE')) {
storeFile file(MY_UPLOAD_KEYSTORE_FILE)
storePassword MY_UPLOAD_KEYSTORE_PASSWORD
keyAlias MY_UPLOAD_KEY_ALIAS
keyPassword MY_UPLOAD_KEY_PASSWORD
}
}
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
under buildTypes.release.signingConfis.debug => signingConfigs.release
-
instead of step 5, you can follow this guide for keeping build keys secure
-
you can use android studio instead of step 3.
Read more about configuring eas.json on https://docs.expo.dev/build/eas-json/