Skip to content

Commit 8b6cb35

Browse files
graycreateclaude
andcommitted
refactor: use KEYSTORE_BASE64 as single source for keystore
- Update build.gradle to only use keystore.jks decoded from base64 - Remove all references to v2er.jks and ghui.jks files - Simplify signing configs: - Debug: uses default Android debug keystore - Release: uses keystore.jks decoded from KEYSTORE_BASE64 - GitHub variant: now uses debug signing - Update release pipeline to decode keystore to app/keystore.jks - Update SIGNING.md to reflect base64-only approach - Add explicit keystore.jks entries to .gitignore This ensures the keystore is only stored as a GitHub secret and never as a file in the repository. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 6f1d438 commit 8b6cb35

File tree

4 files changed

+44
-53
lines changed

4 files changed

+44
-53
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
env:
5858
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
5959
run: |
60-
echo "$KEYSTORE_BASE64" | base64 --decode > ghui.jks
60+
echo "$KEYSTORE_BASE64" | base64 --decode > app/keystore.jks
6161
6262
- name: Build release APK
6363
env:
@@ -66,7 +66,7 @@ jobs:
6666
GHUI_KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
6767
KEYSTORE_PATH: ${{ vars.ENABLE_SIGNING == 'true' && 'keystore.jks' || '' }}
6868
run: |
69-
if [ "${{ vars.ENABLE_SIGNING }}" = "true" ] && [ -f "ghui.jks" ]; then
69+
if [ "${{ vars.ENABLE_SIGNING }}" = "true" ] && [ -f "app/keystore.jks" ]; then
7070
echo "Building signed release APK"
7171
./gradlew assembleRelease --stacktrace
7272
else
@@ -77,7 +77,7 @@ jobs:
7777
- name: Clean up keystore
7878
if: always()
7979
run: |
80-
rm -f ghui.jks
80+
rm -f app/keystore.jks
8181
8282
- name: Upload release APK
8383
uses: actions/upload-artifact@v4
@@ -125,7 +125,7 @@ jobs:
125125
env:
126126
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
127127
run: |
128-
echo "$KEYSTORE_BASE64" | base64 --decode > ghui.jks
128+
echo "$KEYSTORE_BASE64" | base64 --decode > app/keystore.jks
129129
130130
- name: Build release bundle
131131
env:
@@ -134,7 +134,7 @@ jobs:
134134
GHUI_KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
135135
KEYSTORE_PATH: ${{ vars.ENABLE_SIGNING == 'true' && 'keystore.jks' || '' }}
136136
run: |
137-
if [ "${{ vars.ENABLE_SIGNING }}" = "true" ] && [ -f "ghui.jks" ]; then
137+
if [ "${{ vars.ENABLE_SIGNING }}" = "true" ] && [ -f "app/keystore.jks" ]; then
138138
echo "Building signed release bundle"
139139
./gradlew bundleRelease --stacktrace
140140
else
@@ -144,7 +144,7 @@ jobs:
144144
- name: Clean up keystore
145145
if: always()
146146
run: |
147-
rm -f ghui.jks
147+
rm -f app/keystore.jks
148148
149149
- name: Upload release bundle
150150
if: ${{ vars.ENABLE_SIGNING == 'true' }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99
*.icloud
1010
*.jks
1111
*.keystore
12-
*.base64.txt
12+
*.base64.txt
13+
keystore.jks
14+
app/keystore.jks

SIGNING.md

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,53 @@ This document explains how to set up signing for the V2er Android app.
44

55
## CI/CD Signing (GitHub Actions)
66

7-
The release pipeline automatically handles signing using GitHub secrets:
7+
The release pipeline uses GitHub secrets as the single source of truth for signing:
88

9-
1. **KEYSTORE_BASE64**: Base64-encoded keystore file
9+
1. **KEYSTORE_BASE64**: Base64-encoded keystore file (the only source for the keystore)
1010
2. **KEYSTORE_PASSWORD**: Password for the keystore
1111
3. **KEY_PASSWORD**: Password for the signing key
1212
4. **KEY_ALIAS**: Alias of the signing key
1313

1414
The pipeline will:
15-
1. Decode the keystore from the base64 secret
16-
2. Place it in the correct location (`ghui.jks`)
15+
1. Decode the keystore from the KEYSTORE_BASE64 secret
16+
2. Place it temporarily as `app/keystore.jks`
1717
3. Build signed APK/AAB files
1818
4. Clean up the keystore file after building
1919

2020
## Local Development
2121

22-
For local signing, you have two options:
23-
24-
### Option 1: Use Debug Signing (Recommended)
25-
Simply use the debug build variant, which uses Android's default debug keystore.
22+
For local development, use the debug build variant which uses Android's default debug keystore:
2623

2724
```bash
2825
./gradlew assembleDebug
2926
```
3027

31-
### Option 2: Set Up Release Signing
32-
1. Obtain the keystore file from the project maintainer
33-
2. Place it in the project root as `ghui.jks`
28+
If you need to test release builds locally:
29+
1. Obtain the base64-encoded keystore from the project maintainer
30+
2. Decode it and place it as `app/keystore.jks`:
31+
```bash
32+
echo "$KEYSTORE_BASE64" | base64 --decode > app/keystore.jks
33+
```
3434
3. Set environment variables:
3535
```bash
3636
export GHUI_KEYSTORE_PASSWORD="your-keystore-password"
3737
export GHUI_KEY_PASSWORD="your-key-password"
38+
export GHUI_KEY_ALIAS="your-key-alias" # Optional, defaults to "ghui"
3839
```
3940
4. Build the release variant:
4041
```bash
4142
./gradlew assembleRelease
4243
```
43-
44-
### Option 3: Use GitHub Variant
45-
The GitHub variant uses a test keystore with known credentials:
46-
- Keystore: `v2er.jks`
47-
- Password: `v2er.app`
48-
- Key alias: `v2er`
49-
- Key password: `v2er.app`
50-
51-
**Note**: This should only be used for testing, not for production releases.
44+
5. **Important**: Remove the keystore file after building:
45+
```bash
46+
rm app/keystore.jks
47+
```
5248

5349
## Security Notes
5450

51+
- The keystore is ONLY stored as a base64-encoded GitHub secret
5552
- Never commit keystore files to the repository
56-
- Keep keystore passwords secure and never share them publicly
57-
- The `.gitignore` file is configured to exclude all `.jks` and `.keystore` files
58-
- For production releases, always use the GitHub Actions release pipeline
53+
- Always clean up temporary keystore files after use
54+
- The `.gitignore` file excludes all `.jks` and `.keystore` files
55+
- For production releases, always use the GitHub Actions release pipeline
56+
- The GitHub build variant now uses debug signing for simplicity

app/build.gradle

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,32 @@ android {
1313
vectorDrawables.useSupportLibrary = true
1414
}
1515
signingConfigs {
16-
github {
17-
if (file("../v2er.jks").exists()) {
18-
storeFile file("../v2er.jks")
19-
storePassword "v2er.app"
20-
keyAlias "v2er"
21-
keyPassword "v2er.app"
22-
} else {
23-
// Fallback to debug signing if keystore is missing
24-
storeFile file("${System.getProperty('user.home')}/.android/debug.keystore")
25-
storePassword "android"
26-
keyAlias "androiddebugkey"
27-
keyPassword "android"
28-
}
16+
debug {
17+
// Use default debug keystore
2918
}
3019

3120
release {
32-
if (file("../ghui.jks").exists() && project.hasProperty("GHUI_KEYSTORE_PASSWORD") && project.hasProperty("GHUI_KEY_PASSWORD")) {
33-
storeFile file("../ghui.jks")
21+
// Release signing is only configured when keystore is provided via CI/CD
22+
// The keystore will be decoded from KEYSTORE_BASE64 and placed temporarily
23+
if (file("keystore.jks").exists() && project.hasProperty("GHUI_KEYSTORE_PASSWORD") && project.hasProperty("GHUI_KEY_PASSWORD")) {
24+
storeFile file("keystore.jks")
3425
storePassword GHUI_KEYSTORE_PASSWORD
35-
keyAlias "ghui"
26+
keyAlias project.hasProperty("GHUI_KEY_ALIAS") ? GHUI_KEY_ALIAS : "ghui"
3627
keyPassword GHUI_KEY_PASSWORD
3728
} else {
38-
// Use debug signing as fallback for local builds
39-
// CI/CD will provide the actual keystore
40-
storeFile file("${System.getProperty('user.home')}/.android/debug.keystore")
41-
storePassword "android"
42-
keyAlias "androiddebugkey"
43-
keyPassword "android"
29+
// For local builds without proper signing setup, use debug signing
30+
def debugSigningConfig = android.signingConfigs.debug
31+
storeFile debugSigningConfig.storeFile
32+
storePassword debugSigningConfig.storePassword
33+
keyAlias debugSigningConfig.keyAlias
34+
keyPassword debugSigningConfig.keyPassword
4435
}
4536
}
4637
}
4738

4839
buildTypes {
4940
github {
50-
signingConfig signingConfigs.github
41+
signingConfig signingConfigs.debug
5142
}
5243

5344
release {

0 commit comments

Comments
 (0)