Link published Android downloads with a universal APK fallback
This commit is contained in:
1 parent
ebabcc7d74
commit
d2bcc15768
3 files changed
+40
-6
No files matched your search
@@ -51,10 +51,24 @@ jobs:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
tag=$(gh api repos/waozixyz/inbe/releases/latest --jq .tag_name)
|
||||
version=${tag#v}
|
||||
python3 -c 'import re, sys; assert re.fullmatch(r"(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)", sys.argv[1]), "Invalid published release version"' "$version"
|
||||
echo "SITE_RELEASE_VERSION=$version" >> "$GITHUB_ENV"
|
||||
gh api repos/waozixyz/inbe/releases/latest > "$RUNNER_TEMP/inbe-published-release.json"
|
||||
python3 - "$RUNNER_TEMP/inbe-published-release.json" >> "$GITHUB_ENV" <<'PY'
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
release = json.loads(Path(sys.argv[1]).read_text())
|
||||
tag = release["tag_name"]
|
||||
version = tag.removeprefix("v")
|
||||
assert re.fullmatch(r"(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)", version), "Invalid published release version"
|
||||
assets = {asset["name"] for asset in release["assets"]}
|
||||
candidates = [f"inbe-{version}-arm64-v8a.apk", f"inbe-{version}.apk"]
|
||||
android = next((name for name in candidates if name in assets), None)
|
||||
assert android is not None, "Published release has no compatible Android APK"
|
||||
print(f"SITE_RELEASE_VERSION={version}")
|
||||
print(f"SITE_ANDROID_APK_ASSET={android}")
|
||||
PY
|
||||
|
||||
- name: Install Packages
|
||||
if: ${{ !inputs.released_web }}
|
||||
|
||||
@@ -46,6 +46,8 @@ expand_template_file() {
|
||||
sed \
|
||||
-e "s#\\\${version}#$version#g" \
|
||||
-e "s#\\\${asset_version}#$asset_version#g" \
|
||||
-e "s#\\\${android_apk_asset}#$android_apk_asset#g" \
|
||||
-e "s#\\\${android_apk_label}#$android_apk_label#g" \
|
||||
"$src" > "$dst"
|
||||
}
|
||||
|
||||
@@ -182,6 +184,20 @@ version=$(python3 "$root_dir/scripts/check-version.py" --print-version) || {
|
||||
}
|
||||
release_version=${SITE_RELEASE_VERSION:-$version}
|
||||
python3 -c 'import re, sys; assert re.fullmatch(r"(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)", sys.argv[1]), "Invalid download release version"' "$release_version"
|
||||
# Pages selects from the published release; local builds use the universal APK.
|
||||
android_apk_asset=${SITE_ANDROID_APK_ASSET:-"inbe-$release_version.apk"}
|
||||
case "$android_apk_asset" in
|
||||
"inbe-$release_version-arm64-v8a.apk")
|
||||
android_apk_label="ARM64 APK"
|
||||
;;
|
||||
"inbe-$release_version.apk")
|
||||
android_apk_label="Universal APK"
|
||||
;;
|
||||
*)
|
||||
printf 'Error: invalid Android download asset for this release\n' >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
asset_version=${SITE_ASSET_VERSION:-}
|
||||
if [ -z "$asset_version" ]; then
|
||||
if git -C "$root_dir" diff --quiet --ignore-submodules HEAD -- 2>/dev/null; then
|
||||
@@ -199,6 +215,10 @@ copy_path "$script_dir/themes/inbe.css" "$out_dir/theme.css"
|
||||
write_site_imports "$asset_version"
|
||||
copy_template_dir "$script_dir/static" "$out_dir" "$version" "$asset_version"
|
||||
expand_template_file "$script_dir/index.html" "$out_dir/index.html" "$release_version" "$asset_version"
|
||||
if [ "$android_apk_asset" = "inbe-$release_version.apk" ]; then
|
||||
sed '/data-universal-apk/d' "$out_dir/index.html" > "$out_dir/index.html.tmp"
|
||||
mv "$out_dir/index.html.tmp" "$out_dir/index.html"
|
||||
fi
|
||||
mkdir -p "$out_dir/legacy-converter"
|
||||
cp "$out_dir/legacy-converter.html" "$out_dir/legacy-converter/index.html"
|
||||
|
||||
|
||||
+2
-2
@@ -85,8 +85,8 @@
|
||||
<div class="link-row">
|
||||
<a href="https://play.google.com/store/apps/details?id=xyz.waozi.inbe" target="_blank" rel="noopener">Google Play</a>
|
||||
<a href="https://f-droid.org/packages/xyz.waozi.inbe/" target="_blank" rel="noopener">F-Droid</a>
|
||||
<a href="https://github.com/waozixyz/inbe/releases/download/v${version}/inbe-${version}-arm64-v8a.apk" target="_blank" rel="noopener">APK for modern phones</a>
|
||||
<a href="https://github.com/waozixyz/inbe/releases/download/v${version}/inbe-${version}.apk" target="_blank" rel="noopener">Universal APK</a>
|
||||
<a href="https://github.com/waozixyz/inbe/releases/download/v${version}/${android_apk_asset}" target="_blank" rel="noopener">${android_apk_label}</a>
|
||||
<a data-universal-apk href="https://github.com/waozixyz/inbe/releases/download/v${version}/inbe-${version}.apk" target="_blank" rel="noopener">Universal APK</a>
|
||||
</div>
|
||||
</article>
|
||||
<article>
|
||||
|
||||
Reference in new issue
Block a user