Skip to content

Commit 7860269

Browse files
committed
Feedback, finish Android page
1 parent 343e423 commit 7860269

File tree

4 files changed

+108
-73
lines changed

4 files changed

+108
-73
lines changed

jekyll/_cci2/authorize-google-cloud-sdk.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,30 @@ Otherwise, follow the [Google Cloud SDK installation instructions](https://cloud
3636

3737
Before you can use any tools in the Google Cloud SDK, you must authorize `gcloud`. Google offers two types of authorization: user accounts and service accounts. Because you are installing the Cloud SDK on CircleCI, the service account is the appropriate choice.
3838

39-
### 1. Create a service account
39+
### a. Create a service account
4040
{: #create-a-service-account }
4141

4242
Create a service account by following Steps 1-3 of [Google's instructions](https://cloud.google.com/sdk/docs/authorizing#authorizing_with_a_service_account). Remember to download the JSON-formatted key file.
4343

44-
### 2. Add a key file
44+
### b. Add a key file
4545
{: #add-a-key-file }
4646

4747
Add the key file to CircleCI as a [project environment variable](/docs/set-environment-variable/#set-an-environment-variable-in-a-project). In this example, the variable is named `GCLOUD_SERVICE_KEY`. Using this particular name is not required, but it will be used throughout the examples in this document.
4848

49-
### 3. Add environment variables
49+
### c. Add environment variables
5050
{: #add-env-vars }
5151

5252
For convenience, add two more environment variables to your CircleCI project:
5353

5454
- `GOOGLE_PROJECT_ID`: the ID of your GCP project.
5555
- `GOOGLE_COMPUTE_ZONE`: the default [compute zone](https://cloud.google.com/compute/docs/regions-zones/).
5656

57-
#### Add granular permissions
58-
{: #add-granular-permissions }
59-
6057
If you are having issues pushing container images to GCR you may need more granular permissions than the default `service account` provides. You can grant permission changes in the Cloud Storage [IAM Console](https://console.cloud.google.com/iam-admin/iam/project).
61-
58+
<br/>
59+
<br/>
6260
Refer to the Cloud Storage [permission documentation](https://cloud.google.com/storage/docs/access-control/iam-permissions)
6361
to learn more about Identity and Access Management (IAM) permissions.
62+
{: class="alert alert-info" }
6463

6564
## 3. Authenticate to Google Container Registry
6665
{: #authenticate-to-google-container-registry }
@@ -91,7 +90,7 @@ jobs:
9190
password: $GCLOUD_SERVICE_KEY # JSON service account you created, do not encode to base64
9291
```
9392

94-
**Note:** If base64 encoding is required for your particular workflow, use the following command:
93+
If base64 encoding is required for your particular workflow, use the following command:
9594

9695
```shell
9796
cat <file> | base64 -w 0
@@ -118,7 +117,6 @@ jobs:
118117
gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE}
119118
```
120119

121-
**Note:**
122120
If you are using a custom base image, ensure that you have the most recent components by adding the following command before authorizing the SDK.
123121

124122
```shell

jekyll/_cci2/deploy-android-applications.adoc

Lines changed: 97 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,33 @@ In this how-to guide, you will learn how to automatically deploy your Android ap
2121
To complete this tutorial, you will need the following:
2222

2323
- An Android project, built using link:https://gradle.org/[Gradle].
24-
- Your Android project set up in CircleCI. If this is your first time setting up a project in CircleCI, refer to our <<getting-started#,Quickstart Guide>> for a walkthrough.
24+
- Your Android project set up in CircleCI. If this is your first time setting up a project in CircleCI, refer to our xref:getting-started#[Quickstart guide] for a walkthrough.
2525
- Fastlane installed and granted access to Google Play Store using credentials from your Google Developers service account. You may follow the instructions to install, set up, and configure fastlane supply in the link:https://docs.fastlane.tools/getting-started/android/setup/[Fastlane Android setup documentation].
2626

2727
NOTE: In the Fastlane setup, you will download a credentials file from your Google Developers service account. This tutorial assumes that you have saved this file in the `fastlane` folder as `api.json`.
2828

29-
This tutorial also walks you through how to use the Android orb for deployment. You are not required to be familiar with the Android orb for this tutorial, but we recommend reading the <<orb-intro#,Orb introduction page>> if you have not used CircleCI orbs before. Alternatively, this tutorial also shows you how to deploy your project without using the orb.
29+
This tutorial also walks you through how to use the Android orb for deployment. You are not required to be familiar with the Android orb for this tutorial, but we recommend reading the xref:orb-intro#[Orb introduction page] if you have not used CircleCI orbs before. Alternatively, this tutorial also shows you how to deploy your project without using the orb.
3030

3131
[#configure-fastlane-for-deployment-to-google-play-store]
3232
== 1. Configure Fastlane for deployment to Google Play Store
3333

34-
. Navigate to your `fastlane` directory and open `Fastfile`. This file is used to configure the tasks you can execute with Fastlane. If you open the file, you will observe four different blocks:
35-
+
34+
To configure Fastlane for deployment, you will need to configure tasks and update the Play Store lane.
35+
36+
[#configure-tasks]
37+
=== a. Configure tasks
38+
39+
Navigate to your `fastlane` directory and open `Fastfile`. This file is used to configure the tasks you can execute with Fastlane. If you open the file, you will observe four different blocks:
40+
3641
- `before_all`: This is where you specify instructions to be performed before a lane is executed.
37-
+
3842
- `lane`: This is where you define an actual task you want to perform, such as deploying to the Play Store. You can define as many lanes as you want.
39-
+
4043
- `after_all`: This block is called when the executed lane was successful.
41-
+
4244
- `error`: This block will be called if an error occurs in any of the other blocks.
4345

44-
. The Fastfile already comes with a `playstore` lane that generates a release build and deploys it to the Play Store. You will modify this lane. In the Fastfile, update the `playstore` lane like so:
45-
+
46+
[#update-play-store-lane]
47+
=== b. Update Play Store lane
48+
49+
The Fastfile already comes with a `playstore` lane that generates a release build and deploys it to the Play Store. You will modify this lane. In the Fastfile, update the `playstore` lane like so:
50+
4651
```
4752
lane :playstore do
4853
gradle(task: "bundle")
@@ -52,16 +57,19 @@ lane :playstore do
5257
)
5358
end
5459
```
55-
+
60+
5661
This lane will run `gradle bundle` and generate an `app-release.aab` (Android App Bundle), and then deploy the bundle to the internal track of your project in the Google Play Console.
5762

5863
[#prepare-your-app-for-deployment]
5964
== 2. Prepare your app for deployment
6065

61-
Next, you will make some updates to your app to prepare it for deployment. You will have to add a release signing config to your app-module `build.gradle` file. This enables Fastlane to use the same keystore you used in generating earlier releases of your app to also generate subsequent releases.
66+
To prepare your app for deployment, you will need to add a release signing configuration to your app-module `build.gradle` file. This enables Fastlane to use the same keystore you used in generating earlier releases of your app to also generate subsequent releases.
67+
68+
[#add-signingconfig-snippet]
69+
=== a. Add signingConfigs snippet
70+
71+
Add the following `signingConfigs` snippet to your app-module `build.gradle` file:
6272

63-
. Add the `signingConfigs` snippet to your app-module `build.gradle`:
64-
+
6573
```
6674
android {
6775
signingConfigs {
@@ -75,11 +83,14 @@ android {
7583
...
7684
}
7785
```
78-
+
86+
7987
NOTE: For this tutorial, you will be generating a `keystore` and `keystore.properties` at runtime. You can replace the fields with your actual passwords and information for local deployment, but we strongly advise to *not* upload these credentials to a remote repository. If you need help generating a keystore for your application, you may refer to the link:https://developer.android.com/studio/publish/app-signing#generate-key[Android user guide].
8088

81-
. Update the `buildTypes` section of the `build.gradle` file like so:
82-
+
89+
[#update-buildtypes]
90+
=== b. Update buildTypes
91+
92+
Update the `buildTypes` section of your `build.gradle` file:
93+
8394
```
8495
buildTypes {
8596
release {
@@ -88,11 +99,14 @@ buildTypes {
8899
}
89100
}
90101
```
91-
+
102+
92103
With this, you have configured the app to use a specific keystore. Next, you will create functions in your `build.gradle` file to help you generate build numbers for your app versions.
93104

94-
. Add the following snippet just before the `android` section of your app-module `build.gradle` file:
95-
+
105+
[#add-android-snippet]
106+
=== c. Add snippet before android section
107+
108+
Add the following snippet just before the `android` section of your app-module `build.gradle` file:
109+
96110
```
97111
ext.versionMajor = 1
98112
ext.versionMinor = 0
@@ -122,12 +136,15 @@ private String generateVersionName() {
122136
return versionName
123137
}
124138
```
125-
+
139+
126140
In this snippet, you added variables that hold your app version values. You then added two methods, `generateVersionCode` and `generateVersionName` to generate the version code and version name based on how the app version value changes. This helps to give your app a unique and progressive way of generating your version code when you modify your app versions.
127-
+
141+
128142
Note that you will need to update at least one parameter of the version for every deployment. Fastlane fails if a version code is reused.
129143

130-
. Update these properties in the `defaultConfig` section of the `build.gradle` file like so:
144+
[#update-defaultconfig]
145+
=== d. Update properties in defaultConfig
146+
147+
Update the following properties in the `defaultConfig` section of the `build.gradle` file:
131148

132149
```
133150
defaultConfig {
@@ -141,32 +158,39 @@ defaultConfig {
141158
Now your android app is able to be bundled and deployed on your local machine.
142159

143160
[#set-up-circleci-deployment]
144-
== 3. Set up CircleCI Deployment
161+
== 3. Set up CircleCI deployment
162+
163+
To set up CircleCI deployment, you will need to take a few security measures.
164+
165+
[#convert-keystore-to-base64]
166+
=== a. Convert your keystore to base64
167+
168+
You need to convert your keystore to base64 to safely access it in CircleCI. You can do this conversion in the terminal using the following command:
145169

146-
. You need to convert your keystore to base64 to safely access it in CircleCI. You can do this conversion in the terminal using the following command:
147-
+
148170
```shell
149171
$ base64 your_key_store
150172
```
151-
+
173+
152174
Save the output somewhere easily accessible for the next step.
153175

154-
. Next, you need to set <<env-vars#,environment variables>> for deployment through CircleCI.
155-
+
176+
[#set-env-vars]
177+
=== b. Set environment variables
178+
179+
Next, you need to set xref:env-vars#[environment variables] for deployment through CircleCI.
180+
156181
Open your Android project in the link:https://app.circleci.com/[CircleCI web app] and select *Project Settings*. Navigate to *Environment Variables* and add the following variables:
157-
+
182+
158183
- `$BASE64_KEYSTORE` - Your base64 keystore, generated in the previous step
159-
+
160184
- `$GOOGLE_PLAY_KEY` - The contents of your `api.json` file, generated from the Fastlane install before starting this tutorial
161-
+
162185
- `$RELEASE_KEY_ALIAS` - Your key alias
163-
+
164186
- `$RELEASE_KEY_PASSWORD` - Your key password
165-
+
166187
- `$RELEASE_STORE_PASSWORD` - Your keystore password
167188

168-
. Add the following snippet to your `build.gradle` file. This allows you to import your keystore properties from a `keystore.properties` that will be generated at runtime.
169-
+
189+
[#import-keystore-properties]
190+
=== c. Import keystore properties
191+
192+
Add the following snippet to your `build.gradle` file. This allows you to import your keystore properties from a `keystore.properties` that will be generated at runtime.
193+
170194
```
171195
def keyStorePropertiesFile = rootProject.file("keystore.properties")
172196
def keyStoreProperties = new Properties()
@@ -176,7 +200,7 @@ android {
176200
...
177201
}
178202
```
179-
+
203+
180204
[NOTE]
181205
====
182206
You can also create a `keystore.properties` file in your project directory for local bundling and deployment, if you wish. Do *not* push this file or your keystore to a remote repository.
@@ -196,12 +220,12 @@ Now, you need to configure `.circleci/config.yml` to decrypt your keystore, gene
196220
If you have not already done so, create a `.circleci` folder in the root of your project repository. Inside the `.circleci` folder, create a `config.yml` file.
197221

198222
[#set-up-config-with-the-android-orb]
199-
== 4a. Set up config with the Android orb
223+
== 4a. Set up configuration with the Android orb
200224

201-
Using the Android orb gives you two options for deploying to the Google Play Store. You can either use the deploy-to-play-store job from the orb, or run each command individually in a job.
225+
Using the Android orb gives you two options for deploying to the Google Play Store. You can either use the `deploy-to-play-store` job from the orb, or run each command individually in a job.
202226

203227
[#use-the-deploy-to-play-store-job]
204-
=== i. Use the deploy-to-play-store job
228+
=== a. Use the deploy-to-play-store job
205229

206230
To deploy using the deploy-to-play-store job you just need to add a `android/deploy-to-play-store` job to your list of jobs in your workflow.
207231

@@ -234,10 +258,10 @@ workflows:
234258
fastlane-working-directory: '.'
235259
```
236260

237-
NOTE: The executor has no default value and must be set in the config.
261+
NOTE: The executor has no default value and must be set in the configuration.
238262

239263
[#run-each-command-individually]
240-
=== ii. Run each command individually
264+
=== b. Run each command individually
241265

242266
To run each command individually in your workflow, you will need to add the following commands:
243267

@@ -250,7 +274,7 @@ Additionally, you need to run either `npm install` or `yarn install` using the N
250274

251275
As with the deploy-to-play-store approach, you will not need to set the parameters `base64-keystore`, `release-key-alias`, `release-key-password`, `release-store-password`, and `google-play-key`, if you had created environment variables as outlined earlier in this tutorial.
252276

253-
Below is an example config of this approach:
277+
Below is an example configuration of this approach:
254278

255279
```yaml
256280
orbs:
@@ -281,57 +305,70 @@ jobs:
281305
lane-name: internal
282306
```
283307
[#set-up-config-without-the-android-orb]
284-
== 4b. Set up config without the Android Orb
308+
== 4b. Set up configuration without the Android orb
309+
310+
If you would prefer to not use the Android orb, you can follow the configuration directions below.
311+
312+
[#decrypt-keystore]
313+
=== a. Decrypt keystore from base64
314+
315+
Add the following command to your deployment job in `.circleci/config.yml` to decrypt your keystore from the base64 environment variable set earlier (`$BASE64_KEYSTORE`).
285316

286-
. Add the following command to your deployment job in `.circleci/config.yml` to decrypt your keystore from the base64 environment variable set earlier (`$BASE64_KEYSTORE`).
287-
+
288317
```yaml
289318
run:
290319
name: Decode Android key store
291320
command: echo $BASE64_KEYSTORE | base64 -d | tee keystore android/app/keystore > /dev/null
292321
```
293322

294-
. Next, you need to generate a `keystore.properties` file in order to publish your work to the Google Play Store.
295-
+
323+
[#generate-keystore-properties-file]
324+
=== b. Generate a keystore.properties file
325+
326+
Next, you need to generate a `keystore.properties` file in order to publish your work to the Google Play Store.
327+
296328
To do so, you need to create another environment variable named `$RELEASE_KEYSTORE`, that points to the location of the decrypted keystore.
297-
+
329+
298330
Add the following command to your deployment job:
299-
+
331+
300332
```yaml
301333
run:
302334
name: Create keystore.properties
303335
command: cd android && printf 'releaseKeyAlias=%s\nreleaseKeyPassword=%s\nreleaseKeyStore=%s\nreleaseStorePassword=%s' \
304336
$RELEASE_KEY_ALIAS $RELEASE_KEY_PASSWORD $RELEASE_KEYSTORE $RELEASE_STORE_PASSWORD > keystore.properties
305337
```
306338

307-
. Finally, you need to create your Google Play API key from your `api.json` You have already saved the value with an environment variable `$GOOGLE_PLAY_KEY`, so you can refer to this variable and write the api.json file at runtime, instead of uploading it to a remote repository.
308-
+
339+
[#create-google-play-api-key]
340+
=== c. Create Google Play API key
341+
342+
Finally, you need to create your Google Play API key from your `api.json` You have already saved the value with an environment variable `$GOOGLE_PLAY_KEY`, so you can refer to this variable and write the api.json file at runtime, instead of uploading it to a remote repository.
343+
309344
Add the following command to the job:
310-
+
345+
311346
```yaml
312347
run:
313348
name: Create Google Play key
314349
command: echo $GOOGLE_PLAY_KEY > google-play-key.json
315350
```
316351

317-
. To now deploy your app, you need to add your fastlane steps. To do this you only need to add a command that runs `fastlane my_deployment_lane`; in this case, the command looks like this:
318-
+
352+
[#deploy-app]
353+
=== d. Deploy your app
354+
355+
To now deploy your app, you need to add your Fastlane steps. To do this you only need to add a command that runs `fastlane my_deployment_lane`; in this case, the command looks like this:
356+
319357
```yaml
320358
run: fastlane playstore
321359
```
322-
+
360+
323361
NOTE: You may need to install Fastlane on the image you are running your pipeline on. To do this, run `sudo gem install fastlane`.
324-
+
362+
325363
Fastlane recommends using Bundler in this step. If you choose to use Bundler, you will need to add another step to install Bundler:
326-
+
364+
327365
```
328366
run: sudo gem install fastlane
329367
```
330-
+
368+
331369
Then, replace the `run: fastlane playstore` step with `run: bundle exec fastlane playstore`.
332370

333371
[#next-steps]
334372
== Next steps
335373

336-
- A <<deploy-ios-applications#,guide to deploying iOS apps>> is also available.
337-
- Visit the xref:deployment-overview.adoc[Deployment overview] for a general introduction on deployment with CircleCI, as well as examples for specific deployment targets such as Google Cloud Platform, AWS, and Heroku.
374+
- xref:deploy-ios-applications#[Deploy iOS apps]

jekyll/_cci2/deploy-ios-applications.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ Once this is complete you will need to generate an API token to allow Fastlane t
341341
5. Go to your project settings in CircleCI and create a new environment variable named `VS_API_TOKEN` with the value of the API Key.
342342

343343
### 3. Fastlane configuration
344-
{: #fastlane-configuration }
344+
{: #fastlane-configuration-vs-app }
345345

346346
Below is an example of a lane that distributes beta app builds to Visual Studio App Center. Both the username of your App Center account and an API Token with "Full Access" is required to upload the binary to App Center.
347347

@@ -387,7 +387,7 @@ end
387387
2. On the Preferences page, go to the API Key section and copy your API Key.
388388
3. Go to your project settings in CircleCI and create a new environment variable named `TESTFAIRY_API_KEY` with the value of the API Key
389389

390-
### 1. Fastlane configuration
390+
### Fastlane configuration
391391
{: #fastlane-configuration }
392392

393393
To configure uploading to TestFairy within Fastlane, see the following example:

0 commit comments

Comments
 (0)