Constraint: SRS-118 and SRS-119 require a Linux release package and an Android release AAB, and the current workspace also needs the sibling oboe-rs checkout for Cargo manifest loading. Rejected: Keep release packaging as ad-hoc local knowledge | CI and contributors would still miss the required artifacts and hit the missing oboe-rs prerequisite. Confidence: medium Scope-risk: moderate Directive: If the oboe-rs fork path changes or is vendored, update the helper scripts and workflow checkout steps together. Tested: bash -n tools/build-linux-deb.sh tools/build-android-aab.sh; python3 YAML parse for .github/workflows/ci.yml, .github/workflows/bench-advisory.yml, .github/workflows/bench-baseline-update.yml; git diff --check Not-tested: End-to-end flutter build linux --release; end-to-end flutter build appbundle --release; GitHub Actions runtime execution
117 lines
3.2 KiB
Bash
Executable File
117 lines
3.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
APP_DIR="$REPO_ROOT/apps/chanora_flutter"
|
|
PUBSPEC="$APP_DIR/pubspec.yaml"
|
|
OBOE_DIR="$(cd "$REPO_ROOT/.." && pwd)/oboe-rs"
|
|
DIST_DIR="$REPO_ROOT/dist/android"
|
|
TMP_DIR=""
|
|
|
|
cleanup() {
|
|
if [[ -n "$TMP_DIR" && -d "$TMP_DIR" ]]; then
|
|
rm -rf "$TMP_DIR"
|
|
fi
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
require_cmd() {
|
|
local cmd=$1
|
|
if ! command -v "$cmd" >/dev/null 2>&1; then
|
|
echo "ERROR: required command '$cmd' is not on PATH." >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
require_file() {
|
|
local path=$1
|
|
local label=$2
|
|
if [[ ! -f "$path" ]]; then
|
|
echo "ERROR: missing $label at $path" >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
ensure_release_signing() {
|
|
if [[ -n "${CHANORA_RELEASE_STORE_FILE:-}" ]]; then
|
|
local missing=()
|
|
[[ -n "${CHANORA_RELEASE_STORE_PASSWORD:-}" ]] || missing+=("CHANORA_RELEASE_STORE_PASSWORD")
|
|
[[ -n "${CHANORA_RELEASE_KEY_ALIAS:-}" ]] || missing+=("CHANORA_RELEASE_KEY_ALIAS")
|
|
[[ -n "${CHANORA_RELEASE_KEY_PASSWORD:-}" ]] || missing+=("CHANORA_RELEASE_KEY_PASSWORD")
|
|
if (( ${#missing[@]} > 0 )); then
|
|
printf 'ERROR: release signing is partially configured; missing %s\n' "${missing[*]}" >&2
|
|
exit 1
|
|
fi
|
|
require_file "$CHANORA_RELEASE_STORE_FILE" "release keystore"
|
|
return
|
|
fi
|
|
|
|
require_cmd keytool
|
|
TMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/chanora-android-aab.XXXXXX")"
|
|
|
|
export CHANORA_RELEASE_STORE_FILE="$TMP_DIR/chanora-release.keystore"
|
|
export CHANORA_RELEASE_STORE_PASSWORD="${CHANORA_RELEASE_STORE_PASSWORD:-chanora-ci}"
|
|
export CHANORA_RELEASE_KEY_ALIAS="${CHANORA_RELEASE_KEY_ALIAS:-chanora-ci}"
|
|
export CHANORA_RELEASE_KEY_PASSWORD="${CHANORA_RELEASE_KEY_PASSWORD:-$CHANORA_RELEASE_STORE_PASSWORD}"
|
|
|
|
keytool -genkeypair \
|
|
-storetype PKCS12 \
|
|
-keystore "$CHANORA_RELEASE_STORE_FILE" \
|
|
-storepass "$CHANORA_RELEASE_STORE_PASSWORD" \
|
|
-keypass "$CHANORA_RELEASE_KEY_PASSWORD" \
|
|
-alias "$CHANORA_RELEASE_KEY_ALIAS" \
|
|
-keyalg RSA \
|
|
-keysize 2048 \
|
|
-validity 3650 \
|
|
-dname "CN=Chanora CI,O=Chanora,OU=Engineering,L=Seoul,S=Seoul,C=KR" \
|
|
-noprompt >/dev/null 2>&1
|
|
|
|
printf 'Generated ephemeral Android release keystore: %s\n' "$CHANORA_RELEASE_STORE_FILE"
|
|
}
|
|
|
|
main() {
|
|
require_cmd flutter
|
|
require_file "$PUBSPEC" "Flutter pubspec"
|
|
|
|
if [[ ! -f "$OBOE_DIR/Cargo.toml" ]]; then
|
|
cat >&2 <<EOF
|
|
ERROR: missing sibling oboe-rs checkout at:
|
|
$OBOE_DIR
|
|
|
|
This repository's Android-targeted Rust manifest currently depends on a local
|
|
oboe-rs fork. Clone it before running this script:
|
|
|
|
git clone https://github.com/edisonjwa/oboe-rs.git "$OBOE_DIR"
|
|
EOF
|
|
exit 1
|
|
fi
|
|
|
|
ensure_release_signing
|
|
|
|
local app_version
|
|
app_version="$(sed -n 's/^version:[[:space:]]*//p' "$PUBSPEC" | head -n1)"
|
|
if [[ -z "$app_version" ]]; then
|
|
echo "ERROR: could not read version from $PUBSPEC" >&2
|
|
exit 1
|
|
fi
|
|
|
|
(
|
|
cd "$APP_DIR"
|
|
flutter pub get
|
|
flutter build appbundle --release
|
|
)
|
|
|
|
local source_aab="$APP_DIR/build/app/outputs/bundle/release/app-release.aab"
|
|
require_file "$source_aab" "Android release app bundle"
|
|
|
|
mkdir -p "$DIST_DIR"
|
|
local output="$DIST_DIR/chanora-${app_version}-release.aab"
|
|
cp "$source_aab" "$output"
|
|
|
|
printf 'Built Android release bundle: %s\n' "$output"
|
|
}
|
|
|
|
main "$@"
|