Skip to content

Commit c3ca6a5

Browse files
authored
Add support for keystore file input (#9)
* feat: add support for keystore-file directly for signed builds * docs: add info about keystore-file support * add additional input validation * add working-directory for remaining steps for consistency
1 parent 1a7d52d commit c3ca6a5

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535
github-token: ${{ secrets.GITHUB_TOKEN }}
3636
# For release builds, add these:
3737
# sign: true
38+
# Option 1: Use keystore file directly
39+
# keystore-file: 'path/to/your-keystore.jks'
40+
# Option 2: Use base64 encoded keystore (alternative to keystore-file)
3841
# keystore-base64: ${{ secrets.KEYSTORE_BASE64 }}
3942
# keystore-store-file: 'your-keystore.jks'
4043
# keystore-store-password: ${{ secrets.KEYSTORE_STORE_PASSWORD }}
@@ -53,6 +56,7 @@ jobs:
5356
| `variant` | Build variant (debug/release) | No | `debug` |
5457
| `sign` | Whether to sign the build with keystore | No | - |
5558
| `re-sign` | Re-sign the APK with new JS bundle | No | `false` |
59+
| `keystore-file` | Path to the keystore file | No | - |
5660
| `keystore-base64` | Base64 encoded keystore file | No | - |
5761
| `keystore-store-file` | Keystore store file name | No | - |
5862
| `keystore-store-password` | Keystore store password | No | - |

action.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ inputs:
3737
keystore-base64:
3838
description: 'Base64 version of the release keystore'
3939
required: false
40+
keystore-file:
41+
description: 'Path to the keystore file'
42+
required: false
4043
keystore-store-file:
4144
description: 'Keystore store file name'
4245
required: false
@@ -68,8 +71,14 @@ runs:
6871
- name: Validate Inputs
6972
run: |
7073
if [ "${{ inputs.sign }}" == "true" ]; then
71-
if [ -z "${{ inputs.keystore-base64 }}" ]; then
72-
echo "Input 'keystore-base64' is required for signed builds."
74+
if [ -z "${{ inputs.keystore-file }}" ] && [ -z "${{ inputs.keystore-base64 }}" ]; then
75+
echo "Either 'keystore-file' or 'keystore-base64' is required for signed builds."
76+
exit 1
77+
fi
78+
79+
# Validate keystore file actually exists if provided
80+
if [ -n "${{ inputs.keystore-file }}" ] && [ ! -f "${{ inputs.keystore-file }}" ]; then
81+
echo "Keystore file '${{ inputs.keystore-file }}' does not exist."
7382
exit 1
7483
fi
7584
@@ -116,7 +125,6 @@ runs:
116125
mkdir -p .rock/cache
117126
echo "{\"githubToken\": \"${{ inputs.github-token }}\"}" > .rock/cache/project.json
118127
shell: bash
119-
120128
# We create PR-related artifacts to avoid overwriting the main artifact with new JS bundle
121129
- name: Check if PR-related artifact exists
122130
if: ${{ github.event_name == 'pull_request' && inputs.re-sign == 'true' }}
@@ -131,7 +139,7 @@ runs:
131139
echo "ARTIFACT_NAME=$(echo "$OUTPUT" | jq -r '.name')" >> $GITHUB_ENV
132140
fi
133141
shell: bash
134-
142+
135143
- name: Check if regular artifact exists
136144
if: ${{ !env.ARTIFACT_NAME }}
137145
run: |
@@ -145,7 +153,6 @@ runs:
145153
echo "ARTIFACT_NAME=$(echo "$OUTPUT" | jq -r '.name')" >> $GITHUB_ENV
146154
fi
147155
shell: bash
148-
149156
- name: Set Artifact Name (if not set)
150157
if: ${{ !env.ARTIFACT_NAME }}
151158
run: |
@@ -193,8 +200,13 @@ runs:
193200
- name: Decode and store keystore file
194201
if: ${{ !env.ARTIFACT_URL && inputs.sign }}
195202
run: |
196-
echo "${{ inputs.keystore-base64 }}" | base64 --decode > $ANDROID_SOURCE_DIR/$APP_NAME/release.keystore
203+
if [ -n "${{ inputs.keystore-file }}" ]; then
204+
cp "${{ inputs.keystore-file }}" $ANDROID_SOURCE_DIR/$APP_NAME/release.keystore
205+
else
206+
echo "${{ inputs.keystore-base64 }}" | base64 --decode > $ANDROID_SOURCE_DIR/$APP_NAME/release.keystore
207+
fi
197208
shell: bash
209+
working-directory: ${{ inputs.working-directory }}
198210

199211
- name: Build Android
200212
if: ${{ !env.ARTIFACT_URL }}
@@ -212,7 +224,7 @@ runs:
212224
echo APK_PATH $APK_PATH
213225
echo "ARTIFACT_PATH=$APK_PATH" >> $GITHUB_ENV
214226
shell: bash
215-
227+
216228
- name: Download and Unpack APK
217229
if: ${{ env.ARTIFACT_URL && inputs.re-sign == 'true' && github.event_name == 'pull_request' }}
218230
run: |
@@ -240,7 +252,6 @@ runs:
240252
echo "ARTIFACT_ID=$(echo "$OUTPUT" | jq -r '.id')" >> $GITHUB_ENV
241253
fi
242254
shell: bash
243-
244255
# Special case for GitHub, as it doesn't support uploading through the API
245256
- name: Upload Artifact to GitHub
246257
id: upload-artifact
@@ -279,6 +290,7 @@ runs:
279290
rm $HOME/.gradle/gradle.properties
280291
rm $ANDROID_SOURCE_DIR/$APP_NAME/release.keystore
281292
shell: bash
293+
working-directory: ${{ inputs.working-directory }}
282294

283295
- name: Post Build
284296
if: ${{ github.event_name == 'pull_request' && inputs.comment-bot == 'true' }}

0 commit comments

Comments
 (0)