Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Automated Expo PR Builds #340

Open
wants to merge 68 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
0493676
feat: expo upgrade
lakardion Mar 26, 2024
27ab9ac
Merge remote-tracking branch 'origin/main' into feature/expo-upgrade-50
lakardion Mar 26, 2024
c2a9710
feat(mobile) env variables and Nativewind v4
lakardion Mar 27, 2024
c53d665
chore(mobile) deprecate sentry-expo in favor of @sentry/react-native
lakardion Mar 27, 2024
1de7c96
chore: add metro config and unignore
lakardion Mar 27, 2024
06d1f52
Merge branch 'main' into feature/expo-upgrade-50
paribaker Apr 10, 2024
eebe320
update the bootstrapper pipeline to force the use of a new config
paribaker May 30, 2024
70d1063
merged main
Aug 12, 2024
2821356
fix vars
Aug 12, 2024
f5edc9b
fix conflict
Aug 12, 2024
bb3054c
updated the script to work from within the bs app
Aug 12, 2024
ef6c7a1
cp files run script
Aug 12, 2024
e1bceb9
fix directory issues
Aug 12, 2024
a4debde
remove unnecessary step
Aug 12, 2024
73b5002
try new dir
Aug 12, 2024
c48b69b
try new dir
Aug 12, 2024
4105a35
fix dir after switch
Aug 12, 2024
870cae4
checking again
Aug 12, 2024
0b11171
attempt #2
Aug 12, 2024
0d58905
check if script is running
Aug 12, 2024
f30419b
trying to see error
Aug 12, 2024
a956ec5
utypo
Aug 12, 2024
33dcde4
try and see output
Aug 12, 2024
f3a759f
try logs
Aug 12, 2024
5f3c0b3
check each var
Aug 13, 2024
19c4e8b
check each var
Aug 13, 2024
5b29825
clean up and move
Aug 13, 2024
7344ffd
skip if no var exists
Aug 13, 2024
d807245
confirm files
Aug 13, 2024
1e421ee
replaced original configs
Aug 13, 2024
7857661
updated the pipeline to use a newer version
Aug 13, 2024
3e9b3c9
change the directories
Aug 13, 2024
8376b18
not finding the configs
Aug 13, 2024
1f73d70
not finding the configs
Aug 13, 2024
0479a28
see cwd
Aug 13, 2024
ac1c91f
updated cwd
Aug 13, 2024
e57936f
fix dirs
Aug 13, 2024
b38b7aa
hard code dir
Aug 13, 2024
2289708
cwd
Aug 13, 2024
0519866
missing var
Aug 13, 2024
767f03e
remove logs add debugger
Aug 13, 2024
485952c
reset var on exit and default to es
Aug 13, 2024
bd639ce
switch to node instead of yarn
Aug 13, 2024
fdb343a
fix cache
Aug 13, 2024
6c75751
updated to remove cache
Aug 13, 2024
476ddf9
added cache
Aug 13, 2024
261d614
update names and readme
Aug 13, 2024
e2afa80
removed comment
Aug 15, 2024
8ef69ea
add dynamic PR builds
Aug 15, 2024
70fb752
updated the echo
Aug 15, 2024
72e4c2e
regex to get PR number
Aug 15, 2024
3417a66
forgot url
Aug 15, 2024
3f4fe15
added sheet with vars
Aug 15, 2024
0ad55e2
added vars sheet
Aug 15, 2024
9a5ebf9
updated app
Aug 15, 2024
5f5fdbd
updated to echo output
Aug 15, 2024
7ff342f
fix typo and set vars in one line
Aug 15, 2024
18f8ba9
try with vars again
Aug 15, 2024
68068fa
added missing echo
Aug 15, 2024
d58fe09
updated channels
Aug 15, 2024
a11d780
merged main
Aug 15, 2024
fd8e7c6
remove outputs as it is depcrecated
Aug 15, 2024
c369149
test with build
Aug 15, 2024
010c2f0
fix binding for channel
Aug 15, 2024
29629b5
fix binding for channel
Aug 15, 2024
d891503
fix env var
Aug 15, 2024
e01f729
fix build command
Aug 15, 2024
0528658
check if the issue is related to the profile
Aug 20, 2024
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
38 changes: 35 additions & 3 deletions .github/workflows/mobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,43 @@ jobs:
working-directory: ./my_project/mobile
run: npm install

- name: Set Variables
id: set-vars
run: |
echo "backend_url=${{ github.event.deployment_status.environment_url }}" >> $GITHUB_ENV
echo "PR_NUMBER=$(echo ${{ github.event.deployment_status.environment_url }} | grep -oP '(?<=pr-)\d+')" >> $GITHUB_ENV
echo "REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9._-]//g')" >> $GITHUB_ENV
echo "EXPO_CHANNEL=$(echo ${{ github.repository }}-$(echo ${{ github.event.deployment_status.environment_url }} | grep -oP '(?<=pr-)\d+') | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9._-]//g')" >> $GITHUB_ENV
- name: 🚀 Publish preview
working-directory: ./my_project/mobile
run: |
eas update --branch="${{ github.event.deployment_status.environment_url }}" --non-interactive --auto
echo "${{ env.BACKEND_SERVER_URL }} and ${{ github.event.deployment_status.environment_url }}"
eas update --branch=$EXPO_CHANNEL --non-interactive --auto
env:
EXPO_PUBLIC_BACKEND_SERVER_URL: "${{ github.event.deployment_status.environment_url }}"
EXPO_PUBLIC_ROLLBAR_ACCESS_TOKEN: "1a19e5da05b2435b802d5a81aba2bbd7"
EXPO_PUBLIC_ROLLBAR_ACCESS_TOKEN: "1a19e5da05b2435b802d5a81aba2bbd7"

- name: Update EAS Config
working-directory: ./my_project/mobile
run: |
jq --arg pr_number "$PR_NUMBER" --arg expo_channel "$EXPO_CHANNEL" '.build["review_" + $pr_number] = {
"developmentClient": true,
"distribution": "internal",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thought I had was, if we remove the channel here will we be able to use the statically defined config instead of dynamically creating a new entry?
The reason we are adding this entry is so that there will be a unique build for this PR that does not affect other PR's. However since this one is built on the fly in order to test it the user will have to:
Register their device, and update the cert to and then rebuild.

  1. eas device:create
  2. eas credentials ---> review_pr-#
  3. re build

"channel": $expo_channel,
"env": {
"BACKEND_SERVER_URL": "${{ github.event.deployment_status.environment_url }}",
"ROLLBAR_ACCESS_TOKEN": "1a19e5da05b2435b802d5a81aba2bbd7",
"SENTRY_DSN": "https://a7cea97f07ac42fa9e28800b037997c9@o4504899535962112.ingest.sentry.io/4504906332897280",
}
}' eas.json > tmp.$$.json && mv tmp.$$.json eas.json

- name: Display Updated EAS Config
working-directory: ./my_project/mobile
run: cat eas.json

# note: you will need to register your device first using eas device:create & eas credentials to test this
- name: 🔨 Build & Update App
working-directory: ./my_project/mobile

# eas build --platform ios --profile review_${PR_NUMBER} && eas update --branch=$EXPO_CHANNEL --non-interactive --auto
run: |
eas build --platform ios --profile production && eas update --branch=production --non-interactive --auto
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,25 @@ tox -e py -- -k test_default_configuration
[`pytest-cookies`]: https://pypi.python.org/pypi/pytest-cookies/
[`flake8`]: https://pypi.python.org/pypi/flake8/
[`PyPI`]: https://pypi.python.org/pypi


### Testing Review App Builds

Each build will first run `expo update` to create a testable version of your app in Expo Go for reviewers to test. Expo updates are typically quick and can allow testing of most functionality. When there is a need to test native code or React Native code that has not been ported to expo you will need to try out the development build.

Each push will also create a development build as well. This development build can be installed on any device and allows the user to test.

For iOS you will need to register your device and generate a new profile and then rebuild the app by commiting a change.


1. Visit the GH actions tag
2. Copy the eas.json that was created by the build
3. Paste it into your project
4. You will also need to refill the app.config.js
```
<PATH_TO_SCRIPTS>/scripts/setup_mobile_config.sh <YOUR_PATH>/tn-spa-bootstrapper/{{cookiecutter.project_slug}}/clients/mobile/react-native/app.config.js <YOUR_PATH>/tn-spa-bootstrapper/resources/app.config.vars.txt
```
5. run eas device:create if you have never added your device before
6. run eas credentials and select the new configuration for your device
7. Push a change to trigger the build!

4 changes: 2 additions & 2 deletions resources/app.config.vars.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ REPLACE_WITH_EXPO_APP_NAME=tn mobile bootstrapper
REPLACE_WITH_EXPO_APP_SLUG=tn-sample-app
REPLACE_WITH_EXPO_OWNER=thinknimble-bootstrapper
REPLACE_WITH_EXPO_APP_ID=ec1b86e2-2582-48cf-8a7a-c6d2772ba4f2
REPLACE_WITH_SENTRY_ORG=tn-bootstrapper
REPLACE_WITH_SENTRY_ORG=tn-spa
REPLACE_WITH_IOS_BUNDLE_ID=org.thinknimble.expo.bootstrapper
REPLACE_WITH_ANDROID_PACKAGE_ID=com.example.app
REPLACE_WITH_ANDROID_PACKAGE_ID=com.example.app
2 changes: 1 addition & 1 deletion resources/eas.vars.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ REPLACE_WITH_APPSTORE_CONNECT_APP_NAME=TN Bootsrapper RN
[email protected]
REPLACE_WITH_APPLESTORE_CONNECT_ID=6446805695
REPLACE_WITH_APPLE_TEAM_ID=6BNA6HFF6B
REPLACE_WITH_REVIEW_APP_SENTRY_PROJECT_NAME=tn-bootsrapper-rn
REPLACE_WITH_REVIEW_APP_SENTRY_PROJECT_NAME=tn-spa-staging

Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ declare const Config: {
sentryDSN: string
isExpoGo?: boolean
}

declare const vars :{
[key:string]: any
}
export default Config
export { vars }
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,13 @@ const ENV = () => {
}

const Config = { ...ENV() }
export default Config
export default Config

export const vars = {
BACKEND_SERVER_URL,
SENTRY_DSN,
ROLLBAR_ACCESS_TOKEN,
backendServerUrl,
rollbarAccessToken,
sentryDSN,
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ Recreate the provisioning profile <- **this step is required in order for the us
Rebuild the app <- **this step is required in order for the user to be able to install the app**


You must run a first time production build to set up appstore connect keys to be managed by Expo
You must run a first time production build, locally to set up appstore connect keys to be managed by Expo

`eas build --profile production`


**Google**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"channel": "development",
"env": {
"BACKEND_SERVER_URL": "<REPLACE_WITH_LOCAL_BACKEND_SERVER_URL>",
"BUILD_ENV": "development",
"ROLLBAR_ACCESS_TOKEN": "<REPLACE_WITH_LOCAL_ROLLBAR_TOKEN>",
"SENTRY_DSN": "<REPLACE_WITH_LOCAL_SENTRY_DSN>"
}
Expand All @@ -21,9 +20,7 @@
"channel": "review",
"env": {
"BACKEND_SERVER_URL": "<REPLACE_WITH_REVIEW_APP_BACKEND_SERVER_URL>",
"BUILD_ENV": "review",
"ROLLBAR_ACCESS_TOKEN": "<REPLACE_WITH_REVIEW_APP_ROLLBAR_TOKEN>",
"SENTRY_PROJECT_NAME": "<REPLACE_WITH_REVIEW_APP_SENTRY_PROJECT_NAME>",
"SENTRY_DSN": "<REPLACE_WITH_REVIEW_APP_SENTRY_DSN>"
}
},
Expand All @@ -33,7 +30,6 @@
"channel": "development",
"env": {
"BACKEND_SERVER_URL": "<REPLACE_WITH_LOCAL_BACKEND_SERVER_URL>",
"BUILD_ENV": "development",
"ROLLBAR_ACCESS_TOKEN": "<REPLACE_WITH_LOCAL_ROLLBAR_TOKEN>",
"SENTRY_DSN": "<REPLACE_WITH_LOCAL_SENTRY_DSN>"
},
Expand All @@ -46,7 +42,6 @@
"channel": "staging",
"env": {
"BACKEND_SERVER_URL": "<REPLACE_WITH_STAGING_BACKEND_SERVER_URL>",
"BUILD_ENV": "staging",
"ROLLBAR_ACCESS_TOKEN": "<REPLACE_WITH_STAGING_ROLLBAR_TOKEN>",
"SENTRY_DSN": "<REPLACE_WITH_STAGING_SENTRY_DSN>"
}
Expand All @@ -56,7 +51,6 @@
"autoIncrement": true,
"env": {
"BACKEND_SERVER_URL": "<REPLACE_WITH_PRODUCTION_BACKEND_SERVER_URL>",
"BUILD_ENV": "production",
"ROLLBAR_ACCESS_TOKEN": "<REPLACE_WITH_PRODUCTION_ROLLBAR_TOKEN>",
"SENTRY_DSN": "<REPLACE_WITH_PRODUCTION_SENTRY_DSN>"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Dimensions, Image, StyleSheet, View } from 'react-native'
import logo from '@assets/tn-logo.png'
import { Text } from '@components/text'
import { BButton } from '@components/Button'
import { SheetManager } from 'react-native-actions-sheet'
import { SHEET_NAMES } from '@components/sheets'
import { vars } from '../../Config'

const { height } = Dimensions.get('screen')

Expand All @@ -16,6 +20,14 @@ const styles = StyleSheet.create({
})

export const Main = () => {
const onOpenSheet = () => {
SheetManager.show(SHEET_NAMES.test, {
payload: {
input: JSON.stringify(vars),
},
})
}

return (
<View className="flex-grow items-center justify-center">
<View className="items-center justify-center">
Expand All @@ -26,6 +38,7 @@ export const Main = () => {
Welcome to my project
</Text>
</View>
<BButton label="Open sheet" onPress={onOpenSheet} variant="primary" />
</View>
)
}
Loading