|
1 | 1 | # Android CI/CD Pipeline Template Repository <br/>[](https://renovatebot.com/) |
2 | 2 |
|
3 | | -This repository contains a GitHub Actions workflow that automates the build and release process for an Android application. The workflow compiles the application, generates APK and AAB files, and creates a new GitHub release with these files attached. It is triggered by tagging a commit with a specific pattern (`release/*`). |
| 3 | +This repository provides a template setup for Android apps with a fully working GitHub Actions workflow for CI/CD. It builds both APK and AAB outputs, and can optionally sign and release them via GitHub Releases. |
4 | 4 |
|
5 | | -## Workflow Overview |
| 5 | +## How to Build |
6 | 6 |
|
7 | | -The `.github/workflows/tag_create_release.yml` file defines the CI/CD pipeline. It performs the following actions: |
| 7 | +### Without Keystore (Debug Builds) |
8 | 8 |
|
9 | | -1. Checks out the code. |
10 | | -2. Sets up the JDK environment. |
11 | | -3. Builds the APK and AAB files using Gradle. |
12 | | -4. Creates a GitHub release. |
13 | | -5. Attaches the APK and AAB files to the GitHub release. |
| 9 | +By default, debug builds do not require a keystore. You can run: |
| 10 | + |
| 11 | +```bash |
| 12 | +./gradlew assembleDebug |
| 13 | +``` |
| 14 | + |
| 15 | +or build the debug AAB: |
| 16 | + |
| 17 | +```bash |
| 18 | +./gradlew bundleDebug |
| 19 | +``` |
| 20 | + |
| 21 | +No signing config is required unless you explicitly build a release variant. |
| 22 | + |
| 23 | +### With Keystore (Release Builds) |
14 | 24 |
|
15 | | -## Prerequisites |
| 25 | +Signing configuration is only triggered when: |
| 26 | +- the task includes "Release" or "Bundle" |
| 27 | +- or the environment variable `CI=true` is set |
16 | 28 |
|
17 | | -- Android Studio project set up with Gradle. |
18 | | -- JDK 21 configured in the project. |
19 | | -- A `release` branch or appropriate branch strategy to initiate the release process. |
| 29 | +There are two ways to supply the keystore: |
20 | 30 |
|
21 | | -## Usage |
| 31 | +#### 1. Environment Variables (For CI) |
22 | 32 |
|
23 | | -To trigger the workflow and create a new release: |
| 33 | +Provide the following environment variables (e.g. in GitHub Secrets): |
24 | 34 |
|
25 | | -1. Ensure your changes are merged into the `main` or `release` branch (as per your project's branching strategy). |
26 | | -2. Tag the commit you want to release with a `release/*` pattern, e.g., `release/1.0.0`. |
27 | 35 | ``` |
| 36 | +KEYSTORE_LOCATION=./keystore.jks |
| 37 | +CI_ANDROID_KEYSTORE_ALIAS=yourAlias |
| 38 | +CI_ANDROID_KEYSTORE_PASSWORD=yourKeystorePassword |
| 39 | +CI_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD=yourPrivateKeyPassword |
| 40 | +``` |
| 41 | + |
| 42 | +#### 2. `keystore.properties` File (For Local Builds) |
| 43 | + |
| 44 | +Create a `keystore.properties` file at the root: |
| 45 | + |
| 46 | +```properties |
| 47 | +alias=yourAlias |
| 48 | +pass=yourPrivateKeyPassword |
| 49 | +store=path/to/keystore.jks |
| 50 | +storePass=yourKeystorePassword |
| 51 | +``` |
| 52 | + |
| 53 | +Then build: |
| 54 | + |
| 55 | +```bash |
| 56 | +./gradlew bundleRelease |
| 57 | +``` |
| 58 | + |
| 59 | +### Output Format |
| 60 | + |
| 61 | +Release builds are timestamped using the format: |
| 62 | + |
| 63 | +``` |
| 64 | +<app-name>-<buildType>-<versionName>-<yyyyMMdd-HHmmss>.apk |
| 65 | +``` |
| 66 | + |
| 67 | +This applies to both APK and AAB artifacts. |
| 68 | + |
| 69 | +## Workflow Overview |
| 70 | + |
| 71 | +The `.github/workflows/tag_create_release.yml` file defines the CI/CD pipeline. It performs the following: |
| 72 | + |
| 73 | +1. Checks out the code. |
| 74 | +2. Sets up JDK 21. |
| 75 | +3. Builds the APK and AAB using Gradle. |
| 76 | +4. Creates a GitHub Release. |
| 77 | +5. Uploads the outputs as release assets. |
| 78 | + |
| 79 | +Trigger the workflow by tagging a commit with the format: `release/*`, e.g. `release/1.2.3`. |
| 80 | + |
| 81 | +### Usage |
| 82 | + |
| 83 | +To trigger the CI pipeline: |
| 84 | + |
| 85 | +```bash |
28 | 86 | git tag release/1.0.0 |
29 | 87 | git push origin release/1.0.0 |
30 | 88 | ``` |
31 | 89 |
|
32 | | -3. The workflow will be triggered automatically, building the application and creating a new release named after the tag, with the APK and AAB files attached. |
33 | | - |
34 | | -## Configuration |
| 90 | +GitHub Actions will build the release and publish it with assets. |
35 | 91 |
|
36 | | -You may need to adjust the `tag_create_release.yml` workflow file to match your project's specific requirements, such as changing the JDK version or modifying the Gradle build tasks. |
| 92 | +### Configuration Summary |
37 | 93 |
|
38 | | -## Personal Access Token (PAT) |
| 94 | +- JDK 21 and Kotlin configured via toolchain |
| 95 | +- Code style enforced via Detekt, Kover, and Kotlinter |
| 96 | +- Compose support with BOM and previews |
| 97 | +- Managed device test runner for CI |
39 | 98 |
|
40 | | -This workflow uses a Personal Access Token (PAT) with `repo` scope for creating releases. Store your PAT in the repository's secrets with the name `PAT_FOR_RELEASES`. |
| 99 | +### Personal Access Token (PAT) |
41 | 100 |
|
42 | | -## Contributing |
| 101 | +The workflow uses a GitHub token with `repo` scope to publish releases. Store it as a repository secret: |
43 | 102 |
|
44 | | -Contributions to this project are welcome! Please fork the repository, make your changes, and submit a pull request. |
| 103 | +``` |
| 104 | +PAT_FOR_RELEASES |
| 105 | +``` |
45 | 106 |
|
46 | 107 | ## License |
47 | 108 |
|
|
0 commit comments