Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,21 @@ jobs:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD || secrets.KEYSTORE_PASSWORD }}
run: |
EFFECTIVE_KEY_PASSWORD="$KEY_PASSWORD"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 The Roast: This PR exists to "fall back to KEYSTORE_PASSWORD when KEY_PASSWORD is missing OR too short." The incremental diff just deleted the "too short" half. If KEY_PASSWORD is set to a short stub, GitHub's secrets.KEY_PASSWORD || secrets.KEYSTORE_PASSWORD binding still wins — it only falls back on empty/null, never on short-but-truthy — so the workflow now hard-fails with "must be at least 6 characters" instead of falling back to KEYSTORE_PASSWORD. You removed the exact safety net for the scenario you set out to fix.

🩹 The Fix: Restore the fallback before the guard:

EFFECTIVE_KEY_PASSWORD="$KEY_PASSWORD"
if [ -z "$EFFECTIVE_KEY_PASSWORD" ] || [ ${#EFFECTIVE_KEY_PASSWORD} -lt 6 ]; then
  EFFECTIVE_KEY_PASSWORD="$KEYSTORE_PASSWORD"
fi
if [ -z "$EFFECTIVE_KEY_PASSWORD" ] || [ ${#EFFECTIVE_KEY_PASSWORD} -lt 6 ]; then
  echo "::error::Signing key password must be at least 6 characters. Check KEY_PASSWORD/KEYSTORE_PASSWORD secrets."
  exit 1
fi

📏 Severity: warning


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kilocode-bot fix it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix has been applied successfully. Here's a summary of what was done:

Applied Fix

The Cloud Agent session modified .github/workflows/android-build.yml (lines 60-67) to restore the KEYSTORE_PASSWORD fallback logic that was previously removed. The keystore step now uses a two-check validation pattern as requested:

EFFECTIVE_KEY_PASSWORD=$KEY_PASSWORD
if [ -z $EFFECTIVE_KEY_PASSWORD ] || [ ${#EFFECTIVE_KEY_PASSWORD} -lt 6 ]; then
  EFFECTIVE_KEY_PASSWORD=$KEYSTORE_PASSWORD
fi
if [ -z $EFFECTIVE_KEY_PASSWORD ] || [ ${#EFFECTIVE_KEY_PASSWORD} -lt 6 ]; then
  echo ::error::Signing key password must be at least 6 characters. Check KEY_PASSWORD/KEYSTORE_PASSWORD secrets.
  exit 1
fi
echo "::add-mask::$EFFECTIVE_KEY_PASSWORD"
echo "EFFECTIVE_KEY_PASSWORD=$EFFECTIVE_KEY_PASSWORD" >> "$GITHUB_ENV"

Verification

  • ✅ Fallback restoration: When KEY_PASSWORD is empty or short, the code falls back to KEYSTORE_PASSWORD before erroring
  • ✅ Early fail: If neither password meets the 6-character minimum, the workflow fails with a clear error message
  • ✅ Password masking: EFFECTIVE_KEY_PASSWORD is masked with ::add-mask:: and exported via $GITHUB_ENV for downstream reuse
  • ✅ Consistent usage: The resolved EFFECTIVE_KEY_PASSWORD is used in keystore generation (keytool -keypass), the Gradle release build step (${{ env.EFFECTIVE_KEY_PASSWORD }}), and the apksigner step (${{ env.EFFECTIVE_KEY_PASSWORD }})

Per policy, no PR was created with this change — it was applied directly to the existing branch. You can verify the change in the PR thread.

if [ -z "$EFFECTIVE_KEY_PASSWORD" ] || [ ${#EFFECTIVE_KEY_PASSWORD} -lt 6 ]; then
echo "::error::Signing key password must be at least 6 characters. Check KEY_PASSWORD/KEYSTORE_PASSWORD secrets."
exit 1
fi
Comment thread
JWEB0689 marked this conversation as resolved.
Resolved
echo "::add-mask::$EFFECTIVE_KEY_PASSWORD"
echo "EFFECTIVE_KEY_PASSWORD=$EFFECTIVE_KEY_PASSWORD" >> "$GITHUB_ENV"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. Multiline key passwords stop apk builds 🐞 Bug ☼ Reliability

The keystore step writes EFFECTIVE_KEY_PASSWORD to $GITHUB_ENV using a single-line assignment,
which cannot preserve a password containing a newline. If a valid signing secret contains a newline,
the environment file is rejected or a truncated password reaches apksigner, while keytool
created the key with the full password.
Agent Prompt
## Issue description
A valid signing password containing a newline cannot be exported using the new single-line `$GITHUB_ENV` assignment, so later signing cannot use the same password as keystore creation.
## Fix Focus Areas
- .github/workflows/android-build.yml[60-69]
- .github/workflows/android-build.yml[92-108]
## Recommended Fix
Write the resolved password using GitHub's multiline environment-file syntax with a delimiter that cannot occur in the value. Keep the downstream signing steps reading that resolved value.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Fix the code for this review comment.

When a review comment includes a suggested change, apply the suggestion exactly.

Do not make changes beyond what is described in the linked review comment.

keytool -genkey -v \
-keystore keystore.jks \
-alias "$KEY_ALIAS" \
-keyalg RSA \
-keysize 2048 \
-validity 10000 \
-storepass "$KEYSTORE_PASSWORD" \
-keypass "$KEY_PASSWORD" \
-keypass "$EFFECTIVE_KEY_PASSWORD" \
Comment thread
JWEB0689 marked this conversation as resolved.
Resolved
Comment thread
JWEB0689 marked this conversation as resolved.
Resolved
-dname "CN=KernelCrafter, OU=App, O=KernelCrafter, L=Unknown, ST=Unknown, C=US"
- name: Make gradlew executable
working-directory: android
Expand All @@ -76,13 +83,13 @@ jobs:
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS || 'kernelcrafter' }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
KEY_PASSWORD: ${{ env.EFFECTIVE_KEY_PASSWORD }}

- name: Locate, Align, and Sign APK
env:
KEY_ALIAS: ${{ secrets.KEY_ALIAS || 'kernelcrafter' }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD || secrets.KEYSTORE_PASSWORD }}
KEY_PASSWORD: ${{ env.EFFECTIVE_KEY_PASSWORD }}
run: |
mkdir -p dist
APK_UNSIGNED=$(find android/app/build/outputs/apk/release -name "*.apk" | head -1)
Expand Down
Loading