Skip to content

Commit 968a0a6

Browse files
authored
Merge pull request #40 from ryanw-mobile/chore/gradle-fix
Gradle fix and update readme
2 parents 38ef4d6 + da1a7ad commit 968a0a6

File tree

2 files changed

+85
-32
lines changed

2 files changed

+85
-32
lines changed

README.md

Lines changed: 85 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,108 @@
11
# Android CI/CD Pipeline Template Repository <br/>[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/)
22

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.
44

5-
## Workflow Overview
5+
## How to Build
66

7-
The `.github/workflows/tag_create_release.yml` file defines the CI/CD pipeline. It performs the following actions:
7+
### Without Keystore (Debug Builds)
88

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)
1424

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
1628

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:
2030

21-
## Usage
31+
#### 1. Environment Variables (For CI)
2232

23-
To trigger the workflow and create a new release:
33+
Provide the following environment variables (e.g. in GitHub Secrets):
2434

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`.
2735
```
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
2886
git tag release/1.0.0
2987
git push origin release/1.0.0
3088
```
3189

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.
3591

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
3793

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
3998

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)
41100

42-
## Contributing
101+
The workflow uses a GitHub token with `repo` scope to publish releases. Store it as a repository secret:
43102

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+
```
45106

46107
## License
47108

app/build.gradle.kts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,6 @@ private fun BaseAppModuleExtension.setupSigningAndBuildTypes() {
243243
setOutputFileName()
244244
}
245245

246-
create("demo") {
247-
matchingFallbacks += listOf("debug")
248-
applicationIdSuffix = ".demo"
249-
isMinifyEnabled = false
250-
isDebuggable = true
251-
setOutputFileName()
252-
}
253-
254246
getByName("release") {
255247
isShrinkResources = true
256248
isMinifyEnabled = true

0 commit comments

Comments
 (0)