Skip to content

Commit

Permalink
Continuous deployment scripts (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
roryf authored Dec 6, 2023
1 parent bda7434 commit 2671621
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 45 deletions.
6 changes: 1 addition & 5 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
EXPO_APPLICATION_SERVICES_PROJECT_ID=""

STA_API_BASE_URL=""
STA_API_VERSION="v1"
STA_API_KEY=""

FEATURES_ENABLED=events,profileScreen
FEATURES_ENABLED=events,profileScreen
43 changes: 43 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
on:
push:
branches:
- main

name: 🚀 build Expo Go preview

jobs:
preview:
runs-on: ubuntu-latest
env:
STA_API_BASE_URL: https://the-sta.com
STA_API_VERSION: v1
FEATURES_ENABLED: events,profileScreen
steps:
- name: 🏗 Setup repo
uses: actions/checkout@v4
- name: 🏗 Setup Node
uses: actions/setup-node@v4
with:
node-version: 18.14
cache: 'npm'
- name: 🏗 Setup EAS
uses: expo/expo-github-action@v7
with:
eas-version: latest
token: ${{ secrets.EXPO_ACCESS_TOKEN }}
- name: 📦 Install dependencies
run: npm ci
- name: 🚀 Create preview
uses: expo/expo-github-action/preview@v8
id: preview
with:
command: eas update --auto
comment: false
# TODO
# - name: 💬 Comment in Slack
# uses: slackapi/[email protected]
# env:
# SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }}
# with:
# channel-id: deployments
# slack-message: 'New deployment is ready!\n- Preview: ${{ steps.preview.outputs.qr }}'
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
push:
tags:
- v**

name: 🚀 build and upload to app stores

jobs:
release:
name: Release
runs-on: ubuntu-latest
env:
STA_API_BASE_URL: https://the-sta.com
STA_API_VERSION: v1
FEATURES_ENABLED: ""
steps:
- name: 🏗 Setup repo
uses: actions/checkout@v4
- name: 🏗 Setup Node
uses: actions/setup-node@v4
with:
node-version: 18.14
cache: 'npm'
- name: 📦 Install dependencies
run: npm ci
- name: 🏗 Setup EAS
uses: expo/expo-github-action@v7
with:
eas-version: latest
token: ${{ secrets.EXPO_ACCESS_TOKEN }}
- name: 🚀 Build app
run: eas build --non-interactive --platform all --auto-submit --no-wait
38 changes: 18 additions & 20 deletions DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ These are the one-time setup steps you need to do in order to get ready to deplo

**All devs on the team can deploy the app** -- it should be something we all usually incorporate into any pull request where we make a change to the front-end app.

**There are two versions of the app we can deploy** -- one for internal testing (TestFlight for iOS, Google Play Store *internal track* for Android) and one for public release (App Store for iOS, Google Play Store *production track* for Android). The internal testing versions are for the Volunteer app team to download and test before we release the app to the public. The public release versions are for anyone to download from the app stores.
**There are two versions of the app we can deploy** -- one for internal testing (TestFlight for iOS, Google Play Store _internal track_ for Android) and one for public release (App Store for iOS, Google Play Store _production track_ for Android). The internal testing versions are for the Volunteer app team to download and test before we release the app to the public. The public release versions are for anyone to download from the app stores.

**We use [Expo Application Services (EAS)](https://expo.dev/eas)** to build and deploy the app. We are using the free tier which gives us 30 builds per calendar month (15 iOS, 15 Android -- so it's really 15 new deployments). This includes test builds (the Google Play test version and TestFlight) and production builds, it's all the same total.

Expand All @@ -37,7 +37,7 @@ There are also settings in the main Expo config file `app.config.ts` -- look for
## Deployment process

**As a general rule you're strongly encouraged to deploy changes as part of any pull request that updates the front-end app** by following the steps below. **But we also just need to be careful not to hit the 15 deployments (30 builds)) limit,** so if there has been a high frequency of approved pull requests this month or your pull request is only a very minor change to the front-end app, you might not want to update the app version and do a new deployment. If you're not sure, check [how many builds have already been done this month](https://expo.dev/accounts/scottishtecharmy/settings/billing) (and if you're still unsure ask the team on Slack).
**As a general rule you're strongly encouraged to deploy changes as part of any pull request that updates the front-end app** by following the steps below. **But we also just need to be careful not to hit the 15 deployments (30 builds)) limit,** so if there has been a high frequency of approved pull requests this month or your pull request is only a very minor change to the front-end app, you might not want to update the app version and do a new deployment. If you're not sure, check [how many builds have already been done this month](https://expo.dev/accounts/scottishtecharmy/settings/billing) (and if you're still unsure ask the team on Slack).

### Screenshots

Expand Down Expand Up @@ -67,66 +67,64 @@ There are also settings in the main Expo config file `app.config.ts` -- look for
> If you aren't already logged into Expo Application Services (EAS), you'll be asked to login. Ask another team member for the STA's Expo Application Services login details.
> If you get a message saying *EAS project not configured. Existing EAS project found for @scottishtecharmy/volunteer-app Configure this project?* Stop the build process. You need to add `EXPO_APPLICATION_SERVICES_PROJECT_ID` to your `.env` file. Ask another team member for the value of this variable.
> If you get an error saying `Error reading Expo config ... Cannot find module 'dotenv/config'` you may need to reinstall the `dotenv` package. In the `app` directory run `npx expo install dotenv` (if that doesn't fix it try `npm install dotenv`) (If you get warnings, but not errors, when reinstalling this package - don't worry.)
> If you get an error saying `Error reading Expo config ... Cannot find module 'dotenv/config'` you may need to reinstall the `dotenv` package. In the `app` directory run `npx expo install dotenv` (if that doesn't fix it try `npm install dotenv`) (If you get warnings, but not errors, when reinstalling this package - don't worry.)
> Builds can take some time (sometimes 10-20 minutes, sometimes more than an hour, depending on how busy EAS servers are), but you can check the exact status of a build and the different steps that are taking place in the Expo Application Services dashboard -- follow the URL you'll see in your terminal after you run one of the build commands below (ask another team member for the Expo Application Services login details). You can also see there if there are any errors.
9. Once the build is complete, ignore the QR code and if you get a message asking *Install and run the Android build on an emulator?* say **no**
9. Once the build is complete, ignore the QR code and if you get a message asking _Install and run the Android build on an emulator?_ say **no**

### Submit to the Google Play Store

You've created an Android build and it's stored in the cloud with EAS. Now we need to submit it to the Google Play Store.
You've created an Android build and it's stored in the cloud with EAS. Now we need to submit it to the Google Play Store.

10. Make sure you use the right submit command. If you want to **publish the app to the internal test track** (for the Volunteer app team only to download) use `npm run submit-android-testing` -- or to **publish the app to production** (for people to download publicly from the Google Play Store) use `npm run submit-android-production`

11. When asked *What would you like to submit?* choose *Select a build from EAS*. Then use arrow keys to choose the build from the list that you created with the build steps above, and press enter.
11. When asked _What would you like to submit?_ choose _Select a build from EAS_. Then use arrow keys to choose the build from the list that you created with the build steps above, and press enter.

12. Wait for the build to be submitted.

13. Once it's finished, check in the [Google Play Console](https://play.google.com/console) that the new version of the app has successfully been added (*Volunteer app > Release > Internal testing* or *Volunteer app > Release > Production*) -- you should see the new version number next to 'Latest release' under 'Track summary'.
13. Once it's finished, check in the [Google Play Console](https://play.google.com/console) that the new version of the app has successfully been added (_Volunteer app > Release > Internal testing_ or _Volunteer app > Release > Production_) -- you should see the new version number next to 'Latest release' under 'Track summary'.

> Google Play Store reviews the release before it's made public -- check the status of the release in the Google Play Console. If it's not yet available to download, check back later.
> Google Play Store reviews the release before it's made public -- check the status of the release in the Google Play Console. If it's not yet available to download, check back later.
14. If you have an Android phone, download the updated version of the app ([see instructions](README.md#updating-to-the-latest-version-of-the-app)) and double check it's all working as expected.

### Build the iOS version

15. Make sure you are on the right branch locally and have pulled the latest code before you go any further.

> If you are deploying a production release, you should be on the `main` branch. If you are deploying a test release, you should be on a release branch.
> If you are deploying a production release, you should be on the `main` branch. If you are deploying a test release, you should be on a release branch.
> Do `git pull` to make sure you have pulled the latest changes from GitHub, including the pull request you merged in.
> Do `git pull` to make sure you have pulled the latest changes from GitHub, including the pull request you merged in.
16. In the `app` directory run `npm run build-ios` (it's the same command if you are creating a build either for TestFlight internal testing or for production - releasing the app to the public)

> The next few steps below cover iOS-specific issues. See also the notes under step 7. above (Android build) about logging into Expo Application Services (EAS), installing extra packages, and some other issues you might also run into during the iOS build process.
> The next few steps below cover iOS-specific issues. See also the notes under step 7. above (Android build) about logging into Expo Application Services (EAS), installing extra packages, and some other issues you might also run into during the iOS build process.
17. If asked *Do you want to log in to your Apple account?* say **yes.** Follow the steps to log into your account and when asked to select a Team and a Provider choose Scottish Tech Army.
17. If asked _Do you want to log in to your Apple account?_ say **yes.** Follow the steps to log into your account and when asked to select a Team and a Provider choose Scottish Tech Army.

> If you get an error message similar to `Failed to register bundle identifier` or `Apple 403 detected - Access forbidden` try logging in to your [App Store Account](https://appstoreconnect.apple.com/) (or [App Developer account](https://developer.apple.com/) if you have one) -- look around in your account, there may be some updated terms and conditions you need to accept before you can try running the build command again. If you can't see anything you need to accept, it may be that Alistair needs to accept some new terms & conditions in his [Apple developer account]( https://developer.apple.com/account/) -- ask him (or ask Joanna to ask him) to check.
> If you get an error message similar to `Failed to register bundle identifier` or `Apple 403 detected - Access forbidden` try logging in to your [App Store Account](https://appstoreconnect.apple.com/) (or [App Developer account](https://developer.apple.com/) if you have one) -- look around in your account, there may be some updated terms and conditions you need to accept before you can try running the build command again. If you can't see anything you need to accept, it may be that Alistair needs to accept some new terms & conditions in his [Apple developer account](https://developer.apple.com/account/) -- ask him (or ask Joanna to ask him) to check.
18. If asked if you want to generate a new Distribution Certificate and/or Provisioning Profile (if you've deployed recently you may not get asked this), say **yes**

19. If asked *Would you like to set up Push Notifications for your project?* say **no**
19. If asked _Would you like to set up Push Notifications for your project?_ say **no**

20. Wait for the build process to complete

### Submit to TestFlight / the App Store

You've created an iOS build and it's stored in the cloud with EAS. Now we need to submit it to TestFlight / the App Store.
You've created an iOS build and it's stored in the cloud with EAS. Now we need to submit it to TestFlight / the App Store.

21. Make sure you use the right submit command. If you want to **publish the app to TestFlight for internal testing** (for the Volunteer app team only to download) use `npm run submit-ios-testing` -- or to **publish the app to production** (for people to download publicly from the App Store) use `npm run submit-ios-production`

22. When asked *What would you like to submit?* choose *Select a build from EAS*. Then use arrow keys to choose the build from the list that you created with the build steps above, and press enter.
22. When asked _What would you like to submit?_ choose _Select a build from EAS_. Then use arrow keys to choose the build from the list that you created with the build steps above, and press enter.

23. Wait for the build to be submitted.

24. Check in [App Store Connect](https://appstoreconnect.apple.com/apps) that the new version of the app has successfully been uploaded and processed (Apps > STA Volunteer App > TestFlight or Apps > STA Volunteer App > App Store) -- you should see the new build number below the latest version.

> Apple perform some automated checks on a build after it's been submitted, these can take 10-20 minutes. If you don't see your build appear in the list Apple might have found some problems with it. Check your email to see if you have a message from Apple, if not ask Joanna if she has.
> Apple perform some automated checks on a build after it's been submitted, these can take 10-20 minutes. If you don't see your build appear in the list Apple might have found some problems with it. Check your email to see if you have a message from Apple, if not ask Joanna if she has.
> Check that the new build (matching the build number in App Store Connect to the version number you set in `package.json` e.g. `1.0.25`) has been published. When we submitted the first version of the app Joanna had to submit it to the App Store manually for review -- this may need to happen again for new production releases.
> Check that the new build (matching the build number in App Store Connect to the version number you set in `package.json` e.g. `1.0.25`) has been published. When we submitted the first version of the app Joanna had to submit it to the App Store manually for review -- this may need to happen again for new production releases.
25. If you submitted a test version of the app (for TestFlight), you have an iPhone and you're part of the iOS beta test group, you should get a notification on your phone from TestFlight that a new version is available to test. Download the updated version of the app to your iPhone ([see instructions](README.md#updating-to-the-latest-version-of-the-app)).
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ If you're using Visual Studio Code for development, it's recommended that you:
5. Copy the `.env.example` file in the api root folder and name your new file `.env` in the same folder -- e.g. using the command `cp .env.example .env` Set the value of `STA_API_BASE_URL` to the tunnelled URL of your local API server (the one you made a note of in step 8 above).

6. Ask on Slack for a member of the team to send you the value to use for `EXPO_APPLICATION_SERVICES_PROJECT_ID`.

> For security reasons, the `EXPO_APPLICATION_SERVICES_PROJECT_ID` value is not stored in this repo.
7. Run Expo using `npm start` This will run some commands and then it show you a QR code in your terminal.
6. Run Expo using `npm start` This will run some commands and then it show you a QR code in your terminal.

> You may get an automatic prompt to install `@expo/ngrok` or another package -- if so, type `y` to install it.
Expand Down
9 changes: 8 additions & 1 deletion app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
expo: {
name: 'STA Volunteers',
slug: 'volunteer-app',
owner: 'scottish-tech-army',
version,
orientation: 'portrait',
icon: './assets/sta-icon.png',
Expand All @@ -23,6 +24,12 @@ module.exports = {
backgroundColor: '#ffffff',
},
assetBundlePatterns: ['**/*'],
updates: {
url: 'https://u.expo.dev/9cd93ab4-ee33-43d1-a995-e4f8531553e2',
},
runtimeVersion: {
policy: 'sdkVersion',
},
android: {
adaptiveIcon: {
foregroundImage: './assets/sta-icon.png',
Expand Down Expand Up @@ -59,7 +66,7 @@ module.exports = {
apiKey: process.env.BUGSNAG_API_KEY,
},
eas: {
projectId: process.env.EXPO_APPLICATION_SERVICES_PROJECT_ID,
projectId: '9cd93ab4-ee33-43d1-a995-e4f8531553e2',
},
},
hooks: {
Expand Down
11 changes: 4 additions & 7 deletions eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@
},
"build": {
"production": {
"distribution": "store",
"autoIncrement": true
}
},
"submit": {
"preview": {
"android": {
"track": "internal"
}
},
"production": {
"android": {
"track": "production"
"track": "internal"
},
"ios": {
"ascAppId": "1632619020"
"ascAppId": "1632619020",
"appleTeamId": "48N3J4V5KM"
}
}
}
Expand Down
8 changes: 1 addition & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@
"lint-ci": "eslint . -c .eslintrc.ci.js --ext .js,.jsx,.ts,.tsx",
"type-check": "tsc",
"prepare": "husky install .husky",
"lint-app": "lint-staged --quiet",
"build-android": "echo \"Building Android app\" && npx eas-cli build --platform android --profile production",
"build-ios": "echo \"Building iOS app\" && npx eas-cli build --platform ios --profile production",
"submit-android-testing": "echo \"Submitting Android app for internal testing \" && npx eas-cli submit --platform android --profile preview",
"submit-android-production": "echo \"❗ Submitting Android *** PRODUCTION *** app\" && npx eas-cli submit --platform android --profile production",
"submit-ios-testing": "echo \"Submitting iOS app for TestFlight \" && npx eas-cli submit --platform ios --profile preview",
"submit-ios-production": "echo \"❗ Submitting iOS *** PRODUCTION *** app\" && npx eas-cli submit --platform ios --profile production"
"lint-app": "lint-staged --quiet"
},
"dependencies": {
"@bugsnag/expo": "^48.0.0",
Expand Down

0 comments on commit 2671621

Please sign in to comment.