85 lines
2.1 KiB
Bash
Executable file
85 lines
2.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Packages already-built release artifacts into release/<label>/.
|
|
# Label is required as the first CLI argument.
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$ROOT_DIR"
|
|
|
|
label="${1:-}"
|
|
if [[ -z "$label" ]]; then
|
|
echo "Usage: bash tool/package_release.sh <release-label>" >&2
|
|
echo "Example: bash tool/package_release.sh v3.0.1" >&2
|
|
exit 1
|
|
fi
|
|
|
|
app_name="car64"
|
|
release_dir="release/${label}"
|
|
mkdir -p "$release_dir"
|
|
|
|
copied_files=()
|
|
|
|
copy_if_exists() {
|
|
local src="$1"
|
|
local dst="$2"
|
|
if [[ -f "$src" ]]; then
|
|
cp -f "$src" "$dst"
|
|
copied_files+=("$(basename "$dst")")
|
|
fi
|
|
}
|
|
|
|
copy_ipa_if_exists() {
|
|
local ipa_file
|
|
ipa_file="$(find build -type f -name "*.ipa" 2>/dev/null | head -n 1 || true)"
|
|
if [[ -n "$ipa_file" && -f "$ipa_file" ]]; then
|
|
local dst="${release_dir}/${app_name}-${label}-ios.ipa"
|
|
cp -f "$ipa_file" "$dst"
|
|
copied_files+=("$(basename "$dst")")
|
|
fi
|
|
}
|
|
|
|
copy_if_exists "build/app/outputs/flutter-apk/app-release.apk" \
|
|
"${release_dir}/${app_name}-${label}-android.apk"
|
|
copy_if_exists "build/app/outputs/bundle/release/app-release.aab" \
|
|
"${release_dir}/${app_name}-${label}-android.aab"
|
|
copy_ipa_if_exists
|
|
|
|
if [[ ${#copied_files[@]} -eq 0 ]]; then
|
|
echo "No release artifacts found. Build APK/AAB/IPA first." >&2
|
|
exit 1
|
|
fi
|
|
|
|
(
|
|
cd "$release_dir"
|
|
: > SHA256SUMS.txt
|
|
for f in "${copied_files[@]}"; do
|
|
sha256sum "$f" >> SHA256SUMS.txt
|
|
done
|
|
)
|
|
|
|
commit="$(git rev-parse --short HEAD)"
|
|
branch="$(git rev-parse --abbrev-ref HEAD)"
|
|
date_utc="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
|
|
|
{
|
|
echo "# Release ${label}"
|
|
echo
|
|
echo "Commit: ${commit}"
|
|
echo "Branch: ${branch}"
|
|
echo "Generated: ${date_utc}"
|
|
echo
|
|
echo "Files:"
|
|
for f in "${copied_files[@]}"; do
|
|
echo "- ${f}"
|
|
done
|
|
echo "- SHA256SUMS.txt"
|
|
echo
|
|
echo "Notes:"
|
|
echo "- APK is for direct Android install/testing."
|
|
echo "- AAB is for Google Play submission."
|
|
echo "- IPA is for Apple distribution workflows and is not always directly installable."
|
|
} > "${release_dir}/MANIFEST.md"
|
|
|
|
echo "Packaged ${#copied_files[@]} artifact(s) in ${release_dir}"
|
|
ls -lh "$release_dir"
|