-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor E2E tests, generate readme (#29)
* Refactor E2E test structure * Update license, gitignore * Generate readme * Address PR comments [STEP-1214]
- Loading branch information
Showing
6 changed files
with
335 additions
and
475 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.bitrise* | ||
_tmp | ||
_tmp | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,127 @@ | ||
# Android Build | ||
|
||
Builds your Android project with gradle. | ||
[![Step changelog](https://shields.io/github/v/release/bitrise-steplib/bitrise-step-android-build?include_prereleases&label=changelog&color=blueviolet)](https://github.com/bitrise-steplib/bitrise-step-android-build/releases) | ||
|
||
## How to use this Step | ||
Builds your Android project with Gradle. | ||
|
||
Can be run directly with the [bitrise CLI](https://github.com/bitrise-io/bitrise), | ||
just `git clone` this repository, `cd` into it's folder in your Terminal/Command Line | ||
and call `bitrise run test`. | ||
<details> | ||
<summary>Description</summary> | ||
|
||
*Check the `bitrise.yml` file for required inputs which have to be | ||
added to your `.bitrise.secrets.yml` file!* | ||
|
||
Step by step: | ||
The Step builds your Android project on Bitrise with Gradle commands: it installs all dependences that are listed in the project's `build.gradle` file, and builds and exports either an APK or an AAB. | ||
Once the file is exported, it is available for other Steps in your Workflow. | ||
|
||
1. Open up your Terminal / Command Line | ||
2. `git clone` the repository | ||
3. `cd` into the directory of the step (the one you just `git clone`d) | ||
5. Create a `.bitrise.secrets.yml` file in the same directory of `bitrise.yml` - the `.bitrise.secrets.yml` is a git ignored file, you can store your secrets in | ||
6. Check the `bitrise.yml` file for any secret you should set in `.bitrise.secrets.yml` | ||
* Best practice is to mark these options with something like `# define these in your .bitrise.secrets.yml`, in the `app:envs` section. | ||
7. Once you have all the required secret parameters in your `.bitrise.secrets.yml` you can just run this step with the [bitrise CLI](https://github.com/bitrise-io/bitrise): `bitrise run test` | ||
You can select the module and the variant you want to use for the build. | ||
|
||
An example `.bitrise.secrets.yml` file: | ||
### Configuring the Step | ||
|
||
``` | ||
envs: | ||
- A_SECRET_PARAM_ONE: the value for secret one | ||
- A_SECRET_PARAM_TWO: the value for secret two | ||
``` | ||
1. Make sure the **Project Location** input points to the root directory of your Android project. | ||
1. In the **Module** input, set the module that you want to build. | ||
|
||
You can find the available modules in Android Studio. | ||
|
||
1. In the **Variant** input, set the variant that you want to build. | ||
|
||
You can find the available variants in Android Studio. | ||
|
||
1. In the **Build type** input, select the file type you want to build. | ||
|
||
The options are: | ||
- `apk` | ||
- `aab` | ||
|
||
1. In the **Options** input group, you can set more advanced configuration options for the Step: | ||
|
||
- In the **App artifact (.apk, .aab) location pattern** input, you can tell the Step where to look for the APK or AAB files in your project to export them. | ||
For the vast majority of Android projects, the default values do NOT need to be changed. | ||
|
||
- In the **Additional Gradle Arguments**, you can add additional command line arguments to the Gradle task. Read more about [Gradle's Command Line Interface](https://docs.gradle.org/current/userguide/command_line_interface.html). | ||
|
||
- The **Set the level of cache** input allows you to set what will be cached during the build: everything, dependencies only, or nothing. | ||
|
||
### Troubleshooting | ||
|
||
Be aware that an APK or AAB built by the Step is still unsigned: code signing is performed either in Gradle itself or by other Steps. To be able to deploy your APK or AAB to an online store, you need code signing. | ||
|
||
If you want to build a custom module or variant, always check that the value you set in the respective input is correct. A typo means your build will fail; if the module or variant does not exist in Android Studio, the build will fail. | ||
|
||
### Useful links | ||
|
||
## How to create your own step | ||
- [Getting started with Android apps](https://devcenter.bitrise.io/getting-started/getting-started-with-android-apps/) | ||
- [Deploying Android apps](https://devcenter.bitrise.io/deploy/android-deploy/deploying-android-apps/) | ||
- [Generating and deploying Android app bundles](https://devcenter.bitrise.io/deploy/android-deploy/generating-and-deploying-android-app-bundles/) | ||
- [Gradle's Command Line Interface](https://docs.gradle.org/current/userguide/command_line_interface.html) | ||
|
||
1. Create a new git repository for your step (**don't fork** the *step template*, create a *new* repository) | ||
2. Copy the [step template](https://github.com/bitrise-steplib/step-template) files into your repository | ||
3. Fill the `step.sh` with your functionality | ||
4. Wire out your inputs to `step.yml` (`inputs` section) | ||
5. Fill out the other parts of the `step.yml` too | ||
6. Provide test values for the inputs in the `bitrise.yml` | ||
7. Run your step with `bitrise run test` - if it works, you're ready | ||
### Related Steps | ||
|
||
__For Step development guidelines & best practices__ check this documentation: [https://github.com/bitrise-io/bitrise/blob/master/_docs/step-development-guideline.md](https://github.com/bitrise-io/bitrise/blob/master/_docs/step-development-guideline.md). | ||
- [Gradle Runner](https://www.bitrise.io/integrations/steps/gradle-runner) | ||
- [Android Sign](https://www.bitrise.io/integrations/steps/sign-apk) | ||
- [Install missing Android SDK components](https://www.bitrise.io/integrations/steps/install-missing-android-tools) | ||
</details> | ||
|
||
**NOTE:** | ||
## 🧩 Get started | ||
|
||
If you want to use your step in your project's `bitrise.yml`: | ||
Add this step directly to your workflow in the [Bitrise Workflow Editor](https://devcenter.bitrise.io/steps-and-workflows/steps-and-workflows-index/). | ||
|
||
1. git push the step into it's repository | ||
2. reference it in your `bitrise.yml` with the `git::PUBLIC-GIT-CLONE-URL@BRANCH` step reference style: | ||
You can also run this step directly with [Bitrise CLI](https://github.com/bitrise-io/bitrise). | ||
|
||
### Examples | ||
|
||
Build an APK from the debug variant: | ||
|
||
```yaml | ||
- android-build: | ||
inputs: | ||
- variant: debug | ||
- app_type: apk | ||
``` | ||
- git::https://github.com/user/my-step.git@branch: | ||
title: My step | ||
inputs: | ||
- my_input_1: "my value 1" | ||
- my_input_2: "my value 2" | ||
Build a release AAB: | ||
```yaml | ||
- android-build: | ||
inputs: | ||
- variant: release | ||
- app_type: aab | ||
``` | ||
You can find more examples of step reference styles | ||
in the [bitrise CLI repository](https://github.com/bitrise-io/bitrise/blob/master/_examples/tutorials/steps-and-workflows/bitrise.yml#L65). | ||
## How to contribute to this Step | ||
## ⚙️ Configuration | ||
<details> | ||
<summary>Inputs</summary> | ||
| Key | Description | Flags | Default | | ||
| --- | --- | --- | --- | | ||
| `project_location` | The root directory of your Android project. For example, where your root build gradle file exist (also gradlew, settings.gradle, and so on) | required | `$BITRISE_SOURCE_DIR` | | ||
| `module` | Set the module that you want to build. To see your available modules, please open your project in Android Studio and go in [Project Structure] and see the list on the left. | | | | ||
| `variant` | Set the variant(s) that you want to build. To see your available variants, please open your project in Android Studio and go in [Project Structure] -> variants section. You can set multiple variants separated by `\n` character. For instance: `- variant: myvariant1\nmyvariant2`. | | | | ||
| `build_type` | Set the build type that you want to build. | required | `apk` | | ||
| `app_path_pattern` | Will find the APK or AAB files - depending on the **Build type** input - with the given pattern.<br/> Separate patterns with a newline. **Note**<br/> The Step will export only the selected artifact type even if the filter would accept other artifact types as well. | required | `*/build/outputs/apk/*.apk */build/outputs/bundle/*.aab` | | ||
| `cache_level` | `all` - The Step will cache build cache and the dependencies `only_deps` - The Step will cache dependencies only `none` - The Step will not cache anything | required | `only_deps` | | ||
| `arguments` | Extra arguments passed to the gradle task | | | | ||
| `apk_path_pattern` | This input is **DEPRECATED** - use the App location pattern input instead Will find the APK files with the given pattern. | | | | ||
</details> | ||
|
||
<details> | ||
<summary>Outputs</summary> | ||
|
||
1. Fork this repository | ||
2. `git clone` it | ||
3. Create a branch you'll work on | ||
4. To use/test the step just follow the **How to use this Step** section | ||
5. Do the changes you want to | ||
6. Run/test the step before sending your contribution | ||
* You can also test the step in your `bitrise` project, either on your Mac or on [bitrise.io](https://www.bitrise.io) | ||
* You just have to replace the step ID in your project's `bitrise.yml` with either a relative path, or with a git URL format | ||
* (relative) path format: instead of `- original-step-id:` use `- path::./relative/path/of/script/on/your/Mac:` | ||
* direct git URL format: instead of `- original-step-id:` use `- git::https://github.com/user/step.git@branch:` | ||
* You can find more example of alternative step referencing at: https://github.com/bitrise-io/bitrise/blob/master/_examples/tutorials/steps-and-workflows/bitrise.yml | ||
7. Once you're done just commit your changes & create a Pull Request | ||
| Environment Variable | Description | | ||
| --- | --- | | ||
| `BITRISE_APK_PATH` | This output will include the path of the generated APK after filtering based on the filter inputs. If the build generates more than one APK which fulfills the filter inputs, this output will contain the last one's path. | | ||
| `BITRISE_APK_PATH_LIST` | This output will include the paths of the generated APKs after filtering based on the filter inputs. The paths are separated with `\|` character, for example, `app-armeabi-v7a-debug.apk\|app-mips-debug.apk\|app-x86-debug.apk` | | ||
| `BITRISE_AAB_PATH` | This output will include the path of the generated AAB after filtering based on the filter inputs. If the build generates more than one AAB which fulfills the filter inputs, this output will contain the last one's path. | | ||
| `BITRISE_AAB_PATH_LIST` | This output will include the paths of the generated AABs after filtering based on the filter inputs. The paths are separated with `\|` character, for example, `app--debug.aab\|app-mips-debug.aab` | | ||
| `BITRISE_MAPPING_PATH` | This output will include the path of the generated mapping.txt. If more than one mapping.txt exist in the project, this output will contain the last one's path. | | ||
</details> | ||
|
||
## 🙋 Contributing | ||
|
||
## Share your own Step | ||
We welcome [pull requests](https://github.com/bitrise-steplib/bitrise-step-android-build/pulls) and [issues](https://github.com/bitrise-steplib/bitrise-step-android-build/issues) against this repository. | ||
|
||
You can share your Step or step version with the [bitrise CLI](https://github.com/bitrise-io/bitrise). If you use the `bitrise.yml` included in this repository, all you have to do is: | ||
For pull requests, work on your changes in a forked repository and use the Bitrise CLI to [run step tests locally](https://devcenter.bitrise.io/bitrise-cli/run-your-first-build/). | ||
|
||
1. In your Terminal / Command Line `cd` into this directory (where the `bitrise.yml` of the step is located) | ||
1. Run: `bitrise run test` to test the step | ||
1. Run: `bitrise run audit-this-step` to audit the `step.yml` | ||
1. Check the `share-this-step` workflow in the `bitrise.yml`, and fill out the | ||
`envs` if you haven't done so already (don't forget to bump the version number if this is an update | ||
of your step!) | ||
1. Then run: `bitrise run share-this-step` to share the step (version) you specified in the `envs` | ||
1. Send the Pull Request, as described in the logs of `bitrise run share-this-step` | ||
Learn more about developing steps: | ||
|
||
That's all ;) | ||
- [Create your own step](https://devcenter.bitrise.io/contributors/create-your-own-step/) | ||
- [Testing your Step](https://devcenter.bitrise.io/contributors/testing-and-versioning-your-steps/) |
Oops, something went wrong.