Skip to content

Commit 61b874f

Browse files
kakulguptargabs
authored andcommitted
Proofing chapter builds (#29)
1 parent 268f478 commit 61b874f

File tree

3 files changed

+63
-63
lines changed

3 files changed

+63
-63
lines changed

11-devops/11.0-devops.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# DevOps
22

3-
Whenever we start a new project, after setting up the boilerplate, best practices suggest that we setup the continuous deployment so that the rest of the team could easily trigger and receive test builds of the latest app code.
4-
This way the testing team can easily receive the test builds without continuously bugging the developers.
3+
Whenever we start a new project, after setting up the boilerplate, best practices suggest that we set up the continuous deployment so that the team can easily trigger and receive test builds of the latest app code.
54

6-
Few basic requirements for a good devOps setup can be:
5+
This also makes it easier for the testing team to receive test builds without continuously bugging the developers.
6+
7+
A few basic requirements for a good DevOps setup can be:
78

89
- Lint and tests with coverage should run whenever a pull request is raised.
9-
- Every time we merge our changes to the master branch we want the CI process to build the code, run lint and tests, and then build and publish apps to be distributed to the internal team testers.
10-
- Each test build must have the a version and build number and it must be same on both Android and IOS for each version of code.
11-
- An email should be sent out to all testers when a new build is available.
12-
- Developers should also have the option to manually build on local machine quickly.
13-
- Ability to pass environment vairables to the scripts so that we can generate different builds for staging, preprod and production.
10+
- Every time changes are merged to the master branch, we want the CI process to build the code, run lint and tests, and then build and publish apps to be distributed to the internal testing team.
11+
- Each test build should have the same version and build number for Android and iOS builds, corresponding to each version of the code.
12+
- An email should be sent out to all testers whenever a new build is available.
13+
- Developers should also have the option to manually build on their local machines quickly.
14+
- Ability to pass environment variables to the scripts so that we can generate different builds for different development environments like staging, preprod, and production.
1415

1516
The following chapters would show step by step on how to achieve these.

11-devops/11.1-android-build-setup.md

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,47 @@
1-
# Android build scripts / setup
1+
# Android build scripts/setup
22

3-
In android builds are done via gradle.
4-
These are the few pre-requisites to build a release apk.
5-
- **BUILD_NAME** - The name that will be used by testers to identify the build, for example: '1.1.1', '1.0-alpha, etc.
6-
- **BUILD_NUMBER** - A unique integer number identifying the build. This is used by android to identify which build is the updated build. This should be a integer number. for example : 1, 111, 111, etc.
7-
- **ANDROID_APP_ID** - This is the unique app identifier which is used to identify the app uniquely in the play store or can be used to identify if the build is dev, pre prod or prod. These may look like these : com.app.notetaker-dev, com.app.notetaker-alpha.
3+
In Android, builds are done via Gradle.
4+
5+
These are a few pre-requisites to build a release apk.
6+
- **BUILD_NAME** - The name that will be used by testers to identify the build, for example: '1.1.1', '1.0-alpha', etc.
7+
- **BUILD_NUMBER** - A unique integer number identifying the build. This is used by Android to identify which build is the updated build. This should be an integer number, for example, 1, 111, 111, etc.
8+
- **ANDROID_APP_ID** - This is the unique app identifier which is used to identify the app uniquely in the Google Play Store or can be used to identify if the build is dev, preprod or prod. These app ids may look like this: com.app.notetaker-dev, com.app.notetaker-alpha.
89
- **ANDROID_KEYSTORE_FILE** - This is the keystore file used to sign the app.
910
- **ANDROID_KEYSTORE_PASSWORD** - This is the keystore password used while creating the keystore.
10-
- **ANDROID_KEY_ALIAS** - This is key alias used to create the keystore.
11-
- **ANDROID_KEY_PASSWORD** - This is the key password set for the key.
11+
- **ANDROID_KEY_ALIAS** - This is the alias used to create the keystore.
12+
- **ANDROID_KEY_PASSWORD** - This is the password set for the key.
1213

1314
### Release variants
1415

15-
Ideally every app has three release variants just like a typical backend application:
16-
- Dev build - The app which connects to the staging/dev backend Environment. This can also have additional libraries like test fairy.
17-
- Pre Prod build - The app which points to pre prod backend environment.This is usually very similar, if not identical to production app.
18-
- Prod build - The final apk which should be released to the play store.
16+
Ideally, every app has three release variants just like a typical backend application:
17+
- Dev build - The app which connects to the staging/dev backend environment. This can also include additional libraries like TestFairy.
18+
- Preprod build - The app which points to the preprod backend environment. This is usually very similar, if not identical to the production app.
19+
- Prod build - The final apk which should be released to the Play Store.
1920

2021
Hence, we would need three different key stores for three different variants.
2122

22-
### Lets get started
23+
### Let's get started
2324

24-
First step is to create a new keystore file.
25+
The first step is to create a new keystore file.
2526

2627
Use the following command to create a keystore.
2728
```sh
2829
keytool -genkey -v -keystore dev_release.keystore -alias dev-alias -keyalg RSA -keysize 2048 -validity 10000
2930
```
30-
You would be prompted to enter ANDROID_KEYSTORE_PASSWORD, ANDROID_KEY_ALIAS, ANDROID_KEY_PASSWORD and few other details.
31+
You would be prompted to enter ANDROID_KEYSTORE_PASSWORD, ANDROID_KEY_ALIAS, ANDROID_KEY_PASSWORD and a few other details.
32+
3133
Note these down somewhere and keep the keystore file safe.
3234

33-
The android documentation has the following warning:
35+
The Android documentation has the following warning:
3436
```
3537
Note about saving the keystore:
3638
37-
Once you publish the app on the Play Store, you will need to republish your app
38-
under a different package name (losing all downloads and ratings) if you
39-
want to change the signing key at any point.
40-
So backup your keystore and don't forget the passwords.
39+
Once you publish the app on the Play Store, you will need to republish your app under a different package name (losing all downloads and ratings) if you want to change the signing key at any point. So backup your keystore and don't forget the passwords.
4140
```
4241

4342
For the build to work the keystore file should be placed at `android/app/dev_release.keystore`.
4443

45-
*Make sure the keystore file is git ignored so that you dont checking the file into git*
44+
*Make sure the keystore file is git ignored so that you don't check the file into git*
4645

4746
Now, create the following script.
4847
>scripts/android/builder.sh
@@ -60,7 +59,7 @@ cd $cur_dir/../../android &&
6059
echo "APK will be present at android/app/build/outputs/apk/app-release.apk"
6160
```
6261

63-
Apart from this script we would need to modify:
62+
Apart from this script, we would also need to modify:
6463

6564
>android/app/build.gradle
6665
@@ -112,11 +111,11 @@ android {
112111
113112
```
114113

115-
The above script tells gradle to do
114+
The above script tells Gradle to
116115
1. clean
117116
2. build a release apk
118117

119-
Also all the important parameters are passed via environment variables.
118+
Also, all the important parameters are passed via environment variables.
120119
This ensures that we can:
121120
1. Build the apk manually by running
122121

@@ -126,15 +125,15 @@ This ensures that we can:
126125

127126
2. Setup the environment variables in CI platform so that the CI can build the apk without manual intervention. Keep in mind that typically every CI provides a unique build number that you can pass to the script for BUILD_NUMBER.
128127

129-
Woot! Its that simple to build a release apk for android.
128+
Woot! Its that simple to build a release apk for Android.
130129

131130
The built apk can be found at: `android/app/build/outputs/apk/app-release.apk`
132131

133132
### Windows users
134133

135-
If you are running Windows 10 64bit or higher you can enable Ubuntu bash shell on your systems and gain access to full bash command line and run the script there.
136-
More on that here : https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/
134+
If you are running Windows 10 64bit or higher you can enable Ubuntu bash shell on your systems and gain access to the full bash command line and run the script there.
135+
More on that here: https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/
137136

138-
Or you could install Cygwin on your system and run the scripts mentioned.
137+
Alternatively, you could install Cygwin on your system and run the scripts mentioned.
139138

140139
The code till here can be found on the **branch** [chapter/11/11.1](https://github.com/react-made-native-easy/note-taker/tree/chapter/11/11.1)

11-devops/11.2-ios-build-setup.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
# iOS build scripts / setup [WIP]
1+
# iOS build scripts/setup
22

3-
iOS builds via commandline are fairly much more complex as compared to android.
3+
iOS builds via command line are much more complex as compared to Android.
44

55

6-
>**Note: Build works only for Mac users.** Since apple requires that all the build be made on xcode itself, iOS apps can only be built on a mac machine.
6+
>**Note: Builds work only for Mac users.** Since Apple requires that all the builds be made on Xcode itself, iOS apps can only be built on a Mac machine.
77
88

99
These are the few pre-requisites to build a release ipa file.
10-
- **BUILD_NAME** - The name that will be used by testers to identify the build, for example: '1.1.1', '1.0-alpha, etc.
11-
- **BUILD_NUMBER** - A unique integer number identifying the build. This is used by android to identify which build is the updated build. This should be a integer number. for example : 1, 111, 111, etc.
12-
- **IOS_APP_ID** - This is the unique app identifier which is used to identify the app uniquely in the app store or can be used to identify if the build is dev, pre prod or prod. These may look like these : com.app.notetaker-dev, com.app.notetaker-alpha.
10+
- **BUILD_NAME** - The name that will be used by testers to identify the build, for example: '1.1.1', '1.0-alpha', etc.
11+
- **BUILD_NUMBER** - A unique integer number identifying the build. This is used by iOS to identify which build is the updated build. This should be an integer number. For example: 1, 111, 111, etc.
12+
- **IOS_APP_ID** - This is the unique app identifier which is used to identify the app uniquely in the App Store or it can be used to identify if the build is dev, preprod or prod. App ids may look like this: com.app.notetaker-dev, com.app.notetaker-alpha.
1313
- **IOS_CERTIFICATE** - This is the certificate file used to sign the app.
14-
- **IOS_CERTIFICATE_KEY** - This is the certificate password used while creating the certificate.
15-
- **IOS_PROVISION_PROFILE** - This is provision profile needed to build the app. This file mentions the capabilities / devices that are allowed to run the app.
14+
- **IOS_CERTIFICATE_KEY** - This is the password used while creating the certificate.
15+
- **IOS_PROVISION_PROFILE** - This is the provision profile needed to build the app. This file mentions the capabilities/devices that are allowed to run the app.
1616
- **IOS_EXPORT_OPTIONS_PLIST** - This is the options file needed to specify parameters for the build.
17-
- **IOS_SCHEME** - The scheme which should be used to build the ipa. Typically we will have different schemes per environment. For example: we can have local, preprod and a production scheme.
18-
- **IOS_CONFIGURATION** - This is the setting which specified if the build is DEBUG or RELEASE.
19-
- **PROJECT_NAME** - This is name of the project for example if your project name inside ios folder says SampleProject.xcworkspace or SampleProject.xcodeproj, then PROJECT_NAME=SampleProject .
17+
- **IOS_SCHEME** - The scheme which should be used to build the IPA. Typically, we will have different schemes per environment. For example, we can have a local, a preprod and a production scheme.
18+
- **IOS_CONFIGURATION** - This is the setting which specifies if the build is DEBUG or RELEASE.
19+
- **PROJECT_NAME** - This is the name of the project. For example, if your project name inside ios folder says SampleProject.xcworkspace or SampleProject.xcodeproj, then PROJECT_NAME=SampleProject .
2020

2121
### Release variants
2222

23-
Ideally every app has three release variants just like a typical backend application:
24-
- Dev build - The app which connects to the staging/dev backend Environment. This can also have additional libraries like test fairy.
25-
- Pre Prod build - The app which points to pre prod backend environment.This is usually very similar, if not identical to production app.
26-
- Prod build - The final ipa which should be released to the app store.
23+
Ideally, every app has three release variants just like a typical backend application:
24+
- Dev build - The app which connects to the staging/dev backend environment. This can also have additional libraries like TestFairy.
25+
- Pre-Prod build - The app which points to the preprod backend environment. This is usually very similar, if not identical to the production app.
26+
- Prod build - The final IPA which should be released to the App Store.
2727

2828
Hence, we would need three different `schemes` for three different variants.
2929

30-
A typical build process in iOS would have following steps:
31-
1. Getting the certificates and provisioning profiles from apple developer account.
30+
A typical build process in iOS would have the following steps:
31+
1. Getting the certificates and provisioning profiles from the Apple developer account.
3232
2. Adding the certificate to the default keychain and placing the provisioning profile at the location `~/Library/MobileDevice/Provisioning\ Profiles/`
33-
3. Archiving the project - Think of it as a executable zip of the project that can be run using XCode.
34-
4. Exporting the IPA - Think of it as exporting the archive to a format recognised by the iPhone.
33+
3. Archiving the project - Think of it as an executable zip of the project that can be run using Xcode.
34+
4. Exporting the IPA - Think of it as exporting the archive to a format recognized by an iPhone.
3535

36-
### Lets get started
36+
### Let's get started
3737

3838
1. Place the provisioning profile at `scripts/ios/profile/XYZ.mobileprovision`
3939
2. Place the certificate at `scripts/ios/certs/ABC.p12`
4040
3. Place an exportOptions file at `scripts/ios/exportOptions/exportOptions-dev.plist`
41-
Typically an exportOptions file looks like this :
41+
Typically, an exportOptions file looks like this :
4242
>scripts/ios/exportOptions/exportOptions-dev.plist
4343
4444
```xml
@@ -68,10 +68,10 @@ A typical build process in iOS would have following steps:
6868
</dict>
6969
</plist>
7070
```
71-
Make sure you put all the **above files** in the git ignore.
71+
Make sure you put all the **above files** in the gitignore.
7272

7373
4. Create the script:
74-
The below script will create a new keychain `ios-build` and will store the certificate in the keychain. Also, it will make the keychain the default one so that the xcode picks up the certificate from the new keychain. Then it will copy the provisioning profile in the correct directory so that xcode picks it up.
74+
The below script will create a new keychain `ios-build` and will store the certificate in the keychain. Also, it will make `ios-build` the default keychain so that Xcode picks up the certificate from it. Then it will copy the provisioning profile to the correct directory so that Xcode can pick it up.
7575

7676
>scripts/ios/keychain.sh
7777
@@ -92,7 +92,7 @@ A typical build process in iOS would have following steps:
9292
# Add it to the list
9393
security list-keychains -d user -s ios-build.keychain
9494

95-
echo "Making the ios-build keychain default ,so xcodebuild will use it for signing"
95+
echo "Making the ios-build keychain default, so xcodebuild will use it for signing"
9696
security default-keychain -s ios-build.keychain
9797

9898
echo "Unlocking the ios-build keychain"
@@ -109,13 +109,13 @@ A typical build process in iOS would have following steps:
109109
security set-key-partition-list -S apple-tool:,apple: -s -k "ios-build-password" ios-build.keychain
110110

111111
# Put the provisioning profile in place
112-
echo "Coping $IOS_PROVISION_PROFILE in place"
112+
echo "Copying $IOS_PROVISION_PROFILE in place"
113113
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
114114
cp "$cur_dir/profile/$IOS_PROVISION_PROFILE" ~/Library/MobileDevice/Provisioning\ Profiles/
115115
```
116116

117117
5. Create the script that does the build.
118-
This script will run the xcodebuild to first archive the project. Then it will generate the IPA file that can be used for installing the app onto an iPhone.
118+
This script will run the xcodebuild to first archive the project. Then it will generate the IPA file which can be used for installing the app onto an iPhone.
119119
>scripts/ios/builder.sh
120120
121121
```sh
@@ -159,7 +159,7 @@ A typical build process in iOS would have following steps:
159159
`PROJECT_NAME='NoteTaker' IOS_APP_ID='com.notetaker.app.ios' BUILD_NUMBER=11 BUILD_NAME=1.1.1 IOS_SCHEME='local' IOS_CONFIGURATION='RELEASE' IOS_EXPORT_OPTIONS_PLIST='exportOptions-dev.plist' sh ./scripts/ios/builder.sh`
160160

161161

162-
The build should take couple of minutes and you can find the final ipa file at:
162+
The build should take a couple of minutes and you can find the final ipa file at
163163
`ios/build/Products/IPA/`
164164

165165
The code till here can be found on the **branch** [chapter/11/11.2](https://github.com/react-made-native-easy/note-taker/tree/chapter/11/11.2)

0 commit comments

Comments
 (0)