feat: add release build with signing
Made-with: Cursor
This commit is contained in:
74
build.sh
74
build.sh
@@ -184,8 +184,80 @@ manage_keystore() {
|
||||
create_keystore
|
||||
}
|
||||
|
||||
copy_apk() {
|
||||
local build_type="$1"
|
||||
local version
|
||||
version="$(get_version_name)"
|
||||
|
||||
local source_apk="app/build/outputs/apk/$build_type/app-$build_type.apk"
|
||||
|
||||
if [[ ! -f "$source_apk" ]]; then
|
||||
error "APK not found at $source_apk"
|
||||
return 1
|
||||
fi
|
||||
|
||||
ensure_dist_dir
|
||||
|
||||
local dest_name="radio247-v${version}-${build_type}.apk"
|
||||
local dest_path="$DIST_DIR/$dest_name"
|
||||
|
||||
cp "$source_apk" "$dest_path"
|
||||
|
||||
local size
|
||||
size="$(du -h "$dest_path" | cut -f1 | xargs)"
|
||||
|
||||
echo ""
|
||||
success "Build complete!"
|
||||
echo ""
|
||||
echo -e " ${BOLD}APK:${NC} $dest_path"
|
||||
echo -e " ${BOLD}Size:${NC} $size"
|
||||
echo ""
|
||||
echo -e " ${DIM}Share this file with anyone — they can install it${NC}"
|
||||
echo -e " ${DIM}on Android 9+ by opening the APK on their device.${NC}"
|
||||
}
|
||||
|
||||
build_release() {
|
||||
info "Preparing release build..."
|
||||
echo ""
|
||||
|
||||
if [[ ! -f "$KEYSTORE_FILE" ]]; then
|
||||
warn "No keystore found. You need one to sign a release APK."
|
||||
echo ""
|
||||
local yn
|
||||
read -rp "Create one now? (y/n) " yn
|
||||
case $yn in
|
||||
[Yy]*) create_keystore || return 1 ;;
|
||||
*) return 0 ;;
|
||||
esac
|
||||
echo ""
|
||||
fi
|
||||
|
||||
local password
|
||||
read -rsp "Keystore password: " password
|
||||
echo ""
|
||||
echo ""
|
||||
|
||||
info "Building release APK... (this may take a minute)"
|
||||
echo ""
|
||||
|
||||
local store_file
|
||||
store_file="$(cd "$(dirname "$KEYSTORE_FILE")" && pwd)/$(basename "$KEYSTORE_FILE")"
|
||||
|
||||
if ./gradlew assembleRelease \
|
||||
-Pandroid.injected.signing.store.file="$store_file" \
|
||||
-Pandroid.injected.signing.store.password="$password" \
|
||||
-Pandroid.injected.signing.key.alias="$KEY_ALIAS" \
|
||||
-Pandroid.injected.signing.key.password="$password"; then
|
||||
|
||||
copy_apk "release"
|
||||
else
|
||||
echo ""
|
||||
error "Build failed. Check the output above for details."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Placeholder functions — implemented in subsequent tasks
|
||||
build_release() { warn "Not yet implemented"; }
|
||||
build_debug() { warn "Not yet implemented"; }
|
||||
clean_build() { warn "Not yet implemented"; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user