feat(build): add tasks for packaging release artifacts and building Android app
This commit is contained in:
parent
c7e33ab682
commit
de9beb889b
2 changed files with 115 additions and 0 deletions
30
.vscode/tasks.json
vendored
30
.vscode/tasks.json
vendored
|
|
@ -52,6 +52,36 @@
|
||||||
],
|
],
|
||||||
"dependsOrder": "parallel",
|
"dependsOrder": "parallel",
|
||||||
"problemMatcher": []
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Package Release Artifacts (Explicit Label)",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "bash",
|
||||||
|
"args": [
|
||||||
|
"tool/package_release.sh",
|
||||||
|
"${input:releaseVersion}"
|
||||||
|
],
|
||||||
|
"group": "build",
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Build Android + Package Release (Prompt)",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "bash",
|
||||||
|
"args": [
|
||||||
|
"-lc",
|
||||||
|
"flutter build apk --release --dart-define-from-file=.env/flutter_defines.json && flutter build appbundle --release --dart-define-from-file=.env/flutter_defines.json && bash tool/package_release.sh ${input:releaseVersion}"
|
||||||
|
],
|
||||||
|
"group": "build",
|
||||||
|
"problemMatcher": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"id": "releaseVersion",
|
||||||
|
"type": "promptString",
|
||||||
|
"description": "Release label/version (for example: v3.0.1)",
|
||||||
|
"default": "v3.0.1"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
85
tool/package_release.sh
Executable file
85
tool/package_release.sh
Executable file
|
|
@ -0,0 +1,85 @@
|
||||||
|
#!/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"
|
||||||
Loading…
Reference in a new issue